Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic in transport mock #98

Closed
phifty opened this issue Jun 3, 2016 · 3 comments
Closed

Panic in transport mock #98

phifty opened this issue Jun 3, 2016 · 3 comments

Comments

@phifty
Copy link

phifty commented Jun 3, 2016

A client call seems to panic when the transport mock is used.

if err := d.client.Call(context.Background(), client.NewRequest("dispatcher", "Notification.Create", request), response); err != nil {
    return "", err
}

The stack trace is

panic: close of closed channel

goroutine 21 [running]:
panic(0x9f8260, 0xc820146370)
    /opt/go/src/runtime/panic.go:464 +0x3e6
github.com/micro/go-micro/transport/mock.(*mockSocket).Close(0xc82010e7c0, 0x0, 0x0)
    /home/philipp/projects/go/src/github.com/micro/go-micro/transport/mock/mock.go:66 +0x31
github.com/micro/go-micro/client.(*rpcPlusCodec).Close(0xc820148030, 0x0, 0x0)
    /home/philipp/projects/go/src/github.com/micro/go-micro/client/rpc_codec.go:146 +0x82
github.com/micro/go-micro/client.(*rpcStream).Close(0xc820144150, 0x0, 0x0)
    /home/philipp/projects/go/src/github.com/micro/go-micro/client/rpc_stream.go:117 +0x9e
github.com/micro/go-micro/client.(*rpcClient).call(0xc82001a1c0, 0x7fa453c2e830, 0xc8201148a0, 0xc8201128d0, 0x8, 0x7fa453c2e7b8, 0xc820061560, 0xb98dc0, 0xc820114840, 0x0, ...)
    /home/philipp/projects/go/src/github.com/micro/go-micro/client/rpc_client.go:110 +0xd88
github.com/micro/go-micro/client.(*rpcClient).Call.func1(0x0, 0x0, 0x0)
    /home/philipp/projects/go/src/github.com/micro/go-micro/client/rpc_client.go:255 +0xa82
github.com/micro/go-micro/client.(*rpcClient).Call.func2(0xc820061680, 0xc82007d770, 0xc8201128b0)
    /home/philipp/projects/go/src/github.com/micro/go-micro/client/rpc_client.go:265 +0x29
created by github.com/micro/go-micro/client.(*rpcClient).Call
    /home/philipp/projects/go/src/github.com/micro/go-micro/client/rpc_client.go:266 +0xbd3

In rare cases the call is successful without a panic. There seem to be some kind of race condition. Some advice is very welcome.

@asim
Copy link
Member

asim commented Jun 3, 2016

Fixed. Pull master. If OK, please close the issue.

@phifty
Copy link
Author

phifty commented Jun 3, 2016

Wow, that was quick. Looks good to me. Many thanks!

@phifty phifty closed this as completed Jun 3, 2016
@mytototo
Copy link

It looks like I have the same issue, using the default selector:

panic: close of closed channel

goroutine 24 [running]:
github.com/micro/go-micro/registry/cache.(*cache).Stop(0xc00045c2d0)
        /Users/mytototo/Go/pkg/mod/github.com/micro/go-micro@v1.6.0/registry/cache/rcache.go:402 +0x5b
github.com/micro/go-micro/selector.(*registrySelector).Init(0xc0000e1900, 0xc0004b0030, 0x1, 0x1, 0xc0003ae0e0, 0xc000443860)
        /Users/mytototo/Go/pkg/mod/github.com/micro/go-micro@v1.6.0/selector/default.go:30 +0x6c
github.com/micro/go-micro.Registry.func1(0xc0001bc000)
        /Users/mytototo/Go/pkg/mod/github.com/micro/go-micro@v1.6.0/options.go:99 +0x239
github.com/micro/go-micro.newOptions(0xc0001afe78, 0x8, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
        /Users/mytototo/Go/pkg/mod/github.com/micro/go-micro@v1.6.0/options.go:48 +0x182
github.com/micro/go-micro.newService(0xc0005c7e78, 0x8, 0x8, 0xc0004a6460, 0xc0000c9080)
        /Users/mytototo/Go/pkg/mod/github.com/micro/go-micro@v1.6.0/service.go:22 +0x5d
github.com/micro/go-micro.NewService(...)
        /Users/mytototo/Go/pkg/mod/github.com/micro/go-micro@v1.6.0/micro.go:50

...

I run two go routines. One starts a HTTP service and another one starts a gRPC service so I can receive both HTTP and gRPC requests on the same server.

They both use the same interfaces (broker and registry) but use different server and transport.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants