Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Crash in future when connection close after error. #10

Closed
filonenko-mikhail opened this issue Apr 28, 2022 · 3 comments
Closed

Crash in future when connection close after error. #10

filonenko-mikhail opened this issue Apr 28, 2022 · 3 comments

Comments

@filonenko-mikhail
Copy link

Sorry no clean repro yet.

There is error when connection close after error.

Nonrepro but logical equivalent.

# No grants
tarantool  -e 'box.cfg{listen=3303}' -e 'require("console").start()'
package main

import (
	"context"
	"log"
	"time"

	"github.com/FZambia/tarantool"
)

type Row struct {
	ID    uint64
	Value string
}

func main() {
	opts := tarantool.Opts{
		RequestTimeout: 500 * time.Millisecond,
		User:           "guest",
	}
	conn, err := tarantool.Connect("127.0.0.1:3303", opts)
	if err != nil {
		log.Fatalf("Connection refused: %v", err)
	}
	defer func() { _ = conn.Close() }()

	ctx, cancel := context.WithDeadline(context.Background(), time.Now().Add(time.Second))
	_, err = conn.ExecContext(ctx, tarantool.Insert("examples", Row{ID: 999, Value: "hello"}))
	if err != nil {
		log.Fatalf("Insert failed: %v", err)
	}
	log.Println("Insert succeeded")
	conn.Close()
	cancel()
}

We have stacktrace:


goroutine 22 [running]:
runtime/debug.Stack()
        /usr/local/Cellar/go/1.18/libexec/src/runtime/debug/stack.go:24 +0x65
runtime/debug.PrintStack()
        /usr/local/Cellar/go/1.18/libexec/src/runtime/debug/stack.go:16 +0x19
github.com/99designs/gqlgen/graphql.DefaultRecover({0xc00048e500?, 0x1?}, {0x46baba0?, 0x4a43a90?})
        /Users/michael.filonenko/go/pkg/mod/github.com/99designs/[email protected]/graphql/recovery.go:17 +0x71
github.com/99designs/gqlgen/graphql.(*OperationContext).Recover(0x1e?, {0x4a480e8, 0xc00027d200}, {0x46baba0?, 0x4a43a90?})
        /Users/michael.filonenko/go/pkg/mod/github.com/99designs/[email protected]/graphql/context_operation.go:114 +0x3e
helloworld/graph/generated.(*executionContext)._Instance_runtimeInfo.func1()
        /Users/michael.filonenko/work/helloworld/server/graph/generated/generated.go:2576 +0x6a
panic({0x46baba0, 0x4a43a90})
        /usr/local/Cellar/go/1.18/libexec/src/runtime/panic.go:838 +0x207
github.com/FZambia/tarantool.(*futureImpl).markReady(...)
        /Users/michael.filonenko/go/pkg/mod/github.com/!f!zambia/[email protected]/future.go:113
github.com/FZambia/tarantool.(*Connection).closeConnection(0xc00042a360, {0x4a452e0?, 0xc0005c9338}, 0x1)
        /Users/michael.filonenko/go/pkg/mod/github.com/!f!zambia/[email protected]/connection.go:668 +0x285
github.com/FZambia/tarantool.(*Connection).Close(0xc00042a360)
        /Users/michael.filonenko/go/pkg/mod/github.com/!f!zambia/[email protected]/connection.go:359 +0xd0
helloworld/cluster.(*Connection).Dec(...)
        /Users/michael.filonenko/work/helloworld/server/cluster/registry.go:73
helloworld/cluster.(*Registry).ExecSingle.func2()
        /Users/michael.filonenko/work/helloworld/server/cluster/registry.go:159 +0x30
helloworld/cluster.(*Registry).ExecSingle(0xc000037ec0, {0x4a480e8, 0xc00027d200}, {0xc000896d90, 0xe}, 0x0?)
        /Users/michael.filonenko/work/helloworld/server/cluster/registry.go:165 +0x1a7
helloworld/cluster.(*Registry).GetRuntimeInfo(0xc000010230?, {0x4a480e8, 0xc00027d200}, {0xc000896d90, 0xe})
        /Users/michael.filonenko/work/helloworld/server/cluster/registry.go:195 +0x132
helloworld/graph/resolvers.(*instanceResolver).RuntimeInfo(0xc0000103a0, {0x4a480e8, 0xc00027d200}, 0xc0001ad380)
        /Users/michael.filonenko/work/helloworld/server/graph/resolvers/instance.resolvers.go:34 +0x14a
helloworld/graph/generated.(*executionContext)._Instance_runtimeInfo.func2({0x4a480e8?, 0xc00027d200})
        /Users/michael.filonenko/work/helloworld/server/graph/generated/generated.go:2591 +0x82
github.com/99designs/gqlgen/graphql/executor.processExtensions.func4({0x4a480e8?, 0xc00027d200?}, 0xc0001ad620?)
        /Users/michael.filonenko/go/pkg/mod/github.com/99designs/[email protected]/graphql/executor/extensions.go:72 +0x26
helloworld/graph/generated.(*executionContext)._Instance_runtimeInfo(0xc00078fe50, {0x4a480e8, 0xc00027c9c0}, {0xc000631400?, {0xc000168ee0?, 0x400eca5?, 0xc0000e0b60?}}, 0xc0001ad380)
        /Users/michael.filonenko/work/helloworld/server/graph/generated/generated.go:2589 +0x26c
helloworld/graph/generated.(*executionContext)._Instance.func6({0x4a480e8?, 0xc00027c9c0?})
        /Users/michael.filonenko/work/helloworld/server/graph/generated/generated.go:6633 +0xb8
helloworld/graph/generated.(*executionContext)._Instance.func7()
        /Users/michael.filonenko/work/helloworld/server/graph/generated/generated.go:6641 +0x25
github.com/99designs/gqlgen/graphql.(*FieldSet).Dispatch(0xc000117e00)
        /Users/michael.filonenko/go/pkg/mod/github.com/99designs/[email protected]/graphql/fieldset.go:34 +0x96
helloworld/graph/generated.(*executionContext)._Instance(0xc00078fe50, {0x4a480e8?, 0xc00027c9c0}, {0xc0001ad260, 0x6, 0x6}, 0xc0001ad380)
        /Users/michael.filonenko/work/helloworld/server/graph/generated/generated.go:6648 +0x245
helloworld/graph/generated.(*executionContext).marshalNInstance2ᚖtarantoolᚑclusterᚑmanagerᚋgraphᚋmodelᚐInstance(0x4a480e8?, {0x4a480e8?, 0xc00027c9c0?}, {0xc0001ad260?, 0x3?, 0xc000631280?}, 0x4f0d8e0?)
        /Users/michael.filonenko/work/helloworld/server/graph/generated/generated.go:8592 +0xc5
helloworld/graph/generated.(*executionContext)._InstanceMutations_add(0xc00078fe50, {0x4a480e8, 0xc00027c990}, {0xc000630e80?, {0xc0001ad260?, 0x400eca5?, 0x0?}}, 0xc0005c8618)
        /Users/michael.filonenko/work/helloworld/server/graph/generated/generated.go:2647 +0x388
helloworld/graph/generated.(*executionContext)._InstanceMutations.func1({0x4a480e8?, 0xc00027c990?})
        /Users/michael.filonenko/work/helloworld/server/graph/generated/generated.go:6674 +0xb8
helloworld/graph/generated.(*executionContext)._InstanceMutations.func2()
        /Users/michael.filonenko/work/helloworld/server/graph/generated/generated.go:6682 +0x25
github.com/99designs/gqlgen/graphql.(*FieldSet).Dispatch(0xc000117950)
        /Users/michael.filonenko/go/pkg/mod/github.com/99designs/[email protected]/graphql/fieldset.go:34 +0x96
helloworld/graph/generated.(*executionContext)._InstanceMutations(0xc00078fe50, {0x4a480e8?, 0xc00027c990}, {0xc00078fe70, 0x1, 0x1}, 0xc0005c8618)
        /Users/michael.filonenko/work/helloworld/server/graph/generated/generated.go:6749 +0x21e
helloworld/graph/generated.(*executionContext).marshalNInstanceMutations2ᚖtarantoolᚑclusterᚑmanagerᚋgraphᚋmodelᚐInstanceMutations(0x4a480e8?, {0x4a480e8?, 0xc00027c990?}, {0xc00078fe70?, 0x3f?, 0xc0000e1240?}, 0x400e40d?)
        /Users/michael.filonenko/work/helloworld/server/graph/generated/generated.go:8606 +0xc5
helloworld/graph/generated.(*executionContext)._Mutation_instance(0xc00078fe50, {0x4a480e8, 0xc00027c960}, {0xc000630a80?, {0xc00078fe70?, 0x4a480e8?, 0xc0000e12e0?}})
        /Users/michael.filonenko/work/helloworld/server/graph/generated/generated.go:3317 +0x2b9
helloworld/graph/generated.(*executionContext)._Mutation.func4({0x4a480e8?, 0xc00027c960?})
        /Users/michael.filonenko/work/helloworld/server/graph/generated/generated.go:6960 +0x45
github.com/99designs/gqlgen/graphql/executor.processExtensions.func3({0x4a480e8?, 0xc00027c960?}, 0x468b700?)
        /Users/michael.filonenko/go/pkg/mod/github.com/99designs/[email protected]/graphql/executor/extensions.go:69 +0x26
helloworld/graph/generated.(*executionContext)._Mutation(0xc00078fe50, {0x4a480e8, 0xc00027c8d0}, {0xc00078fba0, 0x1, 0x1})
        /Users/michael.filonenko/work/helloworld/server/graph/generated/generated.go:6963 +0xaa4
helloworld/graph/generated.(*executableSchema).Exec.func2({0x4a480e8?, 0xc00027c8d0?})
        /Users/michael.filonenko/work/helloworld/server/graph/generated/generated.go:995 +0x5b
github.com/99designs/gqlgen/graphql/executor.(*Executor).DispatchOperation.func1.1.1({0x4a480e8, 0xc00027c8d0})
        /Users/michael.filonenko/go/pkg/mod/github.com/99designs/[email protected]/graphql/executor/executor.go:106 +0x2b
github.com/99designs/gqlgen/graphql/executor.processExtensions.func2({0x4a480e8?, 0xc00027c8d0?}, 0x468b700?)
        /Users/michael.filonenko/go/pkg/mod/github.com/99designs/[email protected]/graphql/executor/extensions.go:66 +0x26
github.com/99designs/gqlgen/graphql/executor.(*Executor).DispatchOperation.func1.1({0x4a480e8, 0xc00027c870})
        /Users/michael.filonenko/go/pkg/mod/github.com/99designs/[email protected]/graphql/executor/executor.go:105 +0x113
github.com/99designs/gqlgen/graphql/handler/transport.POST.Do({}, {0x4a47d70, 0xc0007ca240}, 0xc000076700, {0x4a47350, 0xc00016a460})
        /Users/michael.filonenko/go/pkg/mod/github.com/99designs/[email protected]/graphql/handler/transport/http_post.go:52 +0x308
github.com/99designs/gqlgen/graphql/handler.(*Server).ServeHTTP(0xc0001470a0, {0x4a47d70, 0xc0007ca240}, 0xc000076700)
        /Users/michael.filonenko/go/pkg/mod/github.com/99designs/[email protected]/graphql/handler/server.go:120 +0x33d
github.com/go-chi/chi.(*Mux).routeHTTP(0xc0001acd80, {0x4a47d70, 0xc0007ca240}, 0xc000076600)
        /Users/michael.filonenko/go/pkg/mod/github.com/go-chi/[email protected]/mux.go:436 +0x1f9
net/http.HandlerFunc.ServeHTTP(0x1eeec708?, {0x4a47d70?, 0xc0007ca240?}, 0xc0926e6625d230a0?)
        /usr/local/Cellar/go/1.18/libexec/src/net/http/server.go:2084 +0x2f
helloworld/graph.Middleware.func1.1({0x4a47ce0?, 0xc0000fe0e0}, 0xc000076500)
        /Users/michael.filonenko/work/helloworld/server/graph/auth.go:116 +0x7d7
net/http.HandlerFunc.ServeHTTP(0x4a48040?, {0x4a47ce0?, 0xc0000fe0e0?}, 0x4d93f90?)
        /usr/local/Cellar/go/1.18/libexec/src/net/http/server.go:2084 +0x2f
github.com/go-chi/chi.(*Mux).ServeHTTP(0xc0001acd80, {0x4a47ce0, 0xc0000fe0e0}, 0xc000076400)
        /Users/michael.filonenko/go/pkg/mod/github.com/go-chi/[email protected]/mux.go:87 +0x442
net/http.serverHandler.ServeHTTP({0x4a465c0?}, {0x4a47ce0, 0xc0000fe0e0}, 0xc000076400)
        /usr/local/Cellar/go/1.18/libexec/src/net/http/server.go:2916 +0x43b
net/http.(*conn).serve(0xc0001b0280, {0x4a480e8, 0xc000093cb0})
        /usr/local/Cellar/go/1.18/libexec/src/net/http/server.go:1966 +0x5d7
created by net/http.(*Server).Serve
        /usr/local/Cellar/go/1.18/libexec/src/net/http/server.go:3071 +0x4db
@FZambia
Copy link
Owner

FZambia commented May 25, 2022

@filonenko-mikhail hello, thanks, the panic is:

panic: close of nil channel

?

@filonenko-mikhail
Copy link
Author

yes

@FZambia
Copy link
Owner

FZambia commented May 25, 2022

Released v0.3.1 which I believe should fix the issue (at least one possible path which could lead to it).

@FZambia FZambia closed this as completed May 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants