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

Concurrency issues (resource temporarily unavailable) #13

Closed
smecsia opened this issue Dec 8, 2019 · 3 comments
Closed

Concurrency issues (resource temporarily unavailable) #13

smecsia opened this issue Dec 8, 2019 · 3 comments

Comments

@smecsia
Copy link

smecsia commented Dec 8, 2019

Currently it is impossible to use local-kms concurrently from multiple processes, because the underlying goleveldb library assumes database would be consumed from a single thread only. As a result the following error occurs when I run multiple nodes accessing local-kms in my test environment:

resource temporarily unavailable
goroutine 56 [running]:
net/http.(*conn).serve.func1(0xc0000b2b40)
	/usr/local/go/src/net/http/server.go:1769 +0x139
panic(0x8d5100, 0xdde600)
	/usr/local/go/src/runtime/panic.go:522 +0x1b5
github.com/nsmithuk/local-kms/src/data.NewDatabase(...)
	/go/src/github.com/nsmithuk/local-kms/src/data/database.go:19
github.com/nsmithuk/local-kms/src.getDatabase(0xc00002c6c0)
	/go/src/github.com/nsmithuk/local-kms/src/init.go:23 +0xb8
github.com/nsmithuk/local-kms/src.handleRequest(0xae6340, 0xc0001b22a0, 0xc000606300)
	/go/src/github.com/nsmithuk/local-kms/src/server.go:31 +0x14b
net/http.HandlerFunc.ServeHTTP(0x95fcc0, 0xae6340, 0xc0001b22a0, 0xc000606300)
	/usr/local/go/src/net/http/server.go:1995 +0x44
net/http.(*ServeMux).ServeHTTP(0xe18640, 0xae6340, 0xc0001b22a0, 0xc000606300)
	/usr/local/go/src/net/http/server.go:2375 +0x1d6
net/http.serverHandler.ServeHTTP(0xc000108000, 0xae6340, 0xc0001b22a0, 0xc000606300)
	/usr/local/go/src/net/http/server.go:2774 +0xa8
net/http.(*conn).serve(0xc0000b2b40, 0xae7580, 0xc0000f6300)
	/usr/local/go/src/net/http/server.go:1878 +0x851
created by net/http.(*Server).Serve
	/usr/local/go/src/net/http/server.go:2884 +0x2f4

Ideally we should either reuse leveldb reference or open it in read-only mode, which might be tricky though.

@nsmithuk
Copy link
Owner

Hi @smecsia. Thank you for reporting the issue. I'll have a fix out for this in the next day or so.

@nsmithuk
Copy link
Owner

@smecsia A fix has been pushed to master.

@smecsia
Copy link
Author

smecsia commented Dec 13, 2019

Hi @nsmithuk I've tested latest Docker image multiple times and it works nicely! Thank you for a blazing-fast fix!

@smecsia smecsia closed this as completed Dec 13, 2019
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

2 participants