pingcap / badger

Fast key-value DB in Go.
https://open.dgraph.io/post/badger/
Apache License 2.0
25 stars 19 forks source link

deadlock or panic on closing #170

Open Connor1996 opened 4 years ago

Connor1996 commented 4 years ago

based on the commit eaffd0ec7a8cef1a3180ea23d0ed45f6947d19f7

panic

2020/02/29 21:12:19 db.go:518: [info] Closing database
panic: send on closed channel

goroutine 49 [running]:
github.com/Connor1996/badger.(*writeWorker).runFlusher(0xc000018080, 0xc000018040)
        /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/writer.go:81 +0x2fd
created by github.com/Connor1996/badger.startWriteWorker
        /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/writer.go:61 +0x226

deadlock

goroutine 68 [running]:
runtime/pprof.writeGoroutineStacks(0x4a1e2c0, 0xc0002062a0, 0x1, 0x1000000000000)
    /usr/local/Cellar/go/1.13.5/libexec/src/runtime/pprof/pprof.go:679 +0x9d
runtime/pprof.writeGoroutine(0x4a1e2c0, 0xc0002062a0, 0x2, 0x400e456, 0xc000166580)
    /usr/local/Cellar/go/1.13.5/libexec/src/runtime/pprof/pprof.go:668 +0x44
runtime/pprof.(*Profile).WriteTo(0x4f2bb20, 0x4a1e2c0, 0xc0002062a0, 0x2, 0xc0002062a0, 0xd)
    /usr/local/Cellar/go/1.13.5/libexec/src/runtime/pprof/pprof.go:329 +0x3da
net/http/pprof.handler.ServeHTTP(0xc000036041, 0x9, 0x4a2f960, 0xc0002062a0, 0xc0001f4300)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/http/pprof/pprof.go:245 +0x33a
net/http/pprof.Index(0x4a2f960, 0xc0002062a0, 0xc0001f4300)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/http/pprof/pprof.go:268 +0x6f1
net/http.HandlerFunc.ServeHTTP(0x495b948, 0x4a2f960, 0xc0002062a0, 0xc0001f4300)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/http/server.go:2007 +0x44
net/http.(*ServeMux).ServeHTTP(0x4f3f380, 0x4a2f960, 0xc0002062a0, 0xc0001f4300)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/http/server.go:2387 +0x1bd
net/http.serverHandler.ServeHTTP(0xc000206000, 0x4a2f960, 0xc0002062a0, 0xc0001f4300)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/http/server.go:2802 +0xa4
net/http.(*conn).serve(0xc000186000, 0x4a31b60, 0xc0001def40)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/http/server.go:1890 +0x875
created by net/http.(*Server).Serve
    /usr/local/Cellar/go/1.13.5/libexec/src/net/http/server.go:2928 +0x384

goroutine 1 [chan receive, 2 minutes]:
testing.(*T).Run(0xc0001f4100, 0x493747b, 0x1e, 0x495b040, 0x4088901)
    /usr/local/Cellar/go/1.13.5/libexec/src/testing/testing.go:961 +0x377
testing.runTests.func1(0xc0001f4000)
    /usr/local/Cellar/go/1.13.5/libexec/src/testing/testing.go:1202 +0x78
testing.tRunner(0xc0001f4000, 0xc0000d9dc0)
    /usr/local/Cellar/go/1.13.5/libexec/src/testing/testing.go:909 +0xc9
testing.runTests(0xc00012ccc0, 0x4f328e0, 0x7, 0x7, 0x0)
    /usr/local/Cellar/go/1.13.5/libexec/src/testing/testing.go:1200 +0x2a7
testing.(*M).Run(0xc0001e4080, 0x0)
    /usr/local/Cellar/go/1.13.5/libexec/src/testing/testing.go:1117 +0x176
main.main()
    _testmain.go:56 +0x135

goroutine 27 [semacquire, 2 minutes]:
sync.runtime_Semacquire(0xc00001ce50)
    /usr/local/Cellar/go/1.13.5/libexec/src/runtime/sema.go:56 +0x42
sync.(*WaitGroup).Wait(0xc00001ce48)
    /usr/local/Cellar/go/1.13.5/libexec/src/sync/waitgroup.go:130 +0x64
github.com/Connor1996/badger/y.(*Closer).Wait(...)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/y/y.go:208
github.com/Connor1996/badger/y.(*Closer).SignalAndWait(...)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/y/y.go:214
github.com/Connor1996/badger.(*DB).Close(0xc0000e4480, 0x0, 0x0)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/db.go:521 +0xb1
github.com/pingcap-incubator/tinykv/kv/util/engine_util.(*Engines).Close(0xc00013eed0, 0x495b080, 0xc0000d55d8)
    /Users/Connor/Coding/src/github.com/pingcap-incubator/tinykv/kv/util/engine_util/engines.go:43 +0x32
github.com/pingcap-incubator/tinykv/kv/util/engine_util.(*Engines).Destroy(0xc00013eed0, 0x0, 0x0)
    /Users/Connor/Coding/src/github.com/pingcap-incubator/tinykv/kv/util/engine_util/engines.go:53 +0x2f
github.com/pingcap-incubator/tinykv/kv/tikv/raftstore.TestHandleRaftCommittedEntries(0xc0001f4100)
    /Users/Connor/Coding/src/github.com/pingcap-incubator/tinykv/kv/tikv/raftstore/raft_worker_test.go:288 +0x415b
testing.tRunner(0xc0001f4100, 0x495b040)
    /usr/local/Cellar/go/1.13.5/libexec/src/testing/testing.go:909 +0xc9
created by testing.(*T).Run
    /usr/local/Cellar/go/1.13.5/libexec/src/testing/testing.go:960 +0x350

goroutine 28 [IO wait, 2 minutes]:
internal/poll.runtime_pollWait(0x5177f28, 0x72, 0x0)
    /usr/local/Cellar/go/1.13.5/libexec/src/runtime/netpoll.go:184 +0x55
internal/poll.(*pollDesc).wait(0xc0000fa198, 0x72, 0x0, 0x0, 0x4925090)
    /usr/local/Cellar/go/1.13.5/libexec/src/internal/poll/fd_poll_runtime.go:87 +0x45
internal/poll.(*pollDesc).waitRead(...)
    /usr/local/Cellar/go/1.13.5/libexec/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Accept(0xc0000fa180, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.13.5/libexec/src/internal/poll/fd_unix.go:384 +0x1f8
net.(*netFD).accept(0xc0000fa180, 0xc0162308ab, 0x1206162308ab, 0x100000001)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/fd_unix.go:238 +0x42
net.(*TCPListener).accept(0xc00000eb20, 0x5e5a6504, 0xc000067db0, 0x4088986)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/tcpsock_posix.go:139 +0x32
net.(*TCPListener).Accept(0xc00000eb20, 0xc000067e00, 0x18, 0xc000086900, 0x4389234)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/tcpsock.go:261 +0x47
net/http.(*Server).Serve(0xc000206000, 0x4a2f6a0, 0xc00000eb20, 0x0, 0x0)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/http/server.go:2896 +0x280
net/http.(*Server).ListenAndServe(0xc000206000, 0xc000206000, 0x40609a1)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/http/server.go:2825 +0xb7
net/http.ListenAndServe(...)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/http/server.go:3081
github.com/pingcap-incubator/tinykv/kv/tikv/raftstore.TestHandleRaftCommittedEntries.func1()
    /Users/Connor/Coding/src/github.com/pingcap-incubator/tinykv/kv/tikv/raftstore/raft_worker_test.go:119 +0x73
created by github.com/pingcap-incubator/tinykv/kv/tikv/raftstore.TestHandleRaftCommittedEntries
    /Users/Connor/Coding/src/github.com/pingcap-incubator/tinykv/kv/tikv/raftstore/raft_worker_test.go:118 +0x4a

goroutine 52 [select, 2 minutes]:
github.com/dgraph-io/ristretto.(*defaultPolicy).processItems(0xc0000a0510)
    /Users/Connor/Coding/pkg/mod/github.com/dgraph-io/ristretto@v0.0.0-20191010170704-2ba187ef9534/policy.go:96 +0xbe
created by github.com/dgraph-io/ristretto.newDefaultPolicy
    /Users/Connor/Coding/pkg/mod/github.com/dgraph-io/ristretto@v0.0.0-20191010170704-2ba187ef9534/policy.go:80 +0x129

goroutine 53 [select, 2 minutes]:
github.com/dgraph-io/ristretto.(*Cache).processItems(0xc0000a4240)
    /Users/Connor/Coding/pkg/mod/github.com/dgraph-io/ristretto@v0.0.0-20191010170704-2ba187ef9534/cache.go:250 +0xbc
created by github.com/dgraph-io/ristretto.NewCache
    /Users/Connor/Coding/pkg/mod/github.com/dgraph-io/ristretto@v0.0.0-20191010170704-2ba187ef9534/cache.go:152 +0x1f3

goroutine 54 [select, 2 minutes]:
github.com/Connor1996/badger.Open.func4(0xc0001320e8)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/db.go:287 +0x15f
created by github.com/Connor1996/badger.Open
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/db.go:284 +0xcdf

goroutine 55 [select, 2 minutes]:
github.com/Connor1996/badger.(*DB).updateSize(0xc0000e4480, 0xc000102560)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/db.go:1011 +0x157
created by github.com/Connor1996/badger.Open
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/db.go:299 +0xdb3

goroutine 66 [chan receive]:
github.com/Connor1996/badger/epoch.(*ResourceManager).collectLoop(0xc000096060)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/epoch/manager.go:96 +0x85
created by github.com/Connor1996/badger/epoch.NewResourceManager
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/epoch/manager.go:76 +0x7a

goroutine 57 [chan receive, 2 minutes]:
github.com/Connor1996/badger.(*blobGCHandler).run(0xc0000d2700)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/blob.go:464 +0x52
created by github.com/Connor1996/badger.(*blobManager).Open
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/blob.go:290 +0x58a

goroutine 58 [select]:
github.com/Connor1996/badger.(*levelsController).runWorker(0xc000016000, 0xc000102760)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/levels.go:198 +0x1a8
created by github.com/Connor1996/badger.(*levelsController).startCompact
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/levels.go:183 +0x88

goroutine 59 [select]:
github.com/Connor1996/badger.(*levelsController).runWorker(0xc000016000, 0xc000102760)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/levels.go:198 +0x1a8
created by github.com/Connor1996/badger.(*levelsController).startCompact
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/levels.go:183 +0x88

goroutine 60 [select]:
github.com/Connor1996/badger.(*levelsController).runWorker(0xc000016000, 0xc000102760)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/levels.go:198 +0x1a8
created by github.com/Connor1996/badger.(*levelsController).startCompact
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/levels.go:183 +0x88

goroutine 61 [chan receive, 2 minutes]:
github.com/Connor1996/badger.(*DB).runFlushMemTable(0xc0000e4480, 0xc000102520, 0x0, 0x0)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/db.go:892 +0xff
created by github.com/Connor1996/badger.Open
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/db.go:317 +0x146b

goroutine 32 [IO wait]:
internal/poll.runtime_pollWait(0x5177e58, 0x72, 0xffffffffffffffff)
    /usr/local/Cellar/go/1.13.5/libexec/src/runtime/netpoll.go:184 +0x55
internal/poll.(*pollDesc).wait(0xc00017a018, 0x72, 0x0, 0x1, 0xffffffffffffffff)
    /usr/local/Cellar/go/1.13.5/libexec/src/internal/poll/fd_poll_runtime.go:87 +0x45
internal/poll.(*pollDesc).waitRead(...)
    /usr/local/Cellar/go/1.13.5/libexec/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Read(0xc00017a000, 0xc0001cc401, 0x1, 0x1, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.13.5/libexec/src/internal/poll/fd_unix.go:169 +0x22b
net.(*netFD).Read(0xc00017a000, 0xc0001cc401, 0x1, 0x1, 0xc0001defd8, 0xc004220f68, 0x406cb6c)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/fd_unix.go:202 +0x4f
net.(*conn).Read(0xc00010a068, 0xc0001cc401, 0x1, 0x1, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/net.go:184 +0x68
net/http.(*connReader).backgroundRead(0xc0001cc3f0)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/http/server.go:677 +0x58
created by net/http.(*connReader).startBackgroundRead
    /usr/local/Cellar/go/1.13.5/libexec/src/net/http/server.go:673 +0xd4

goroutine 48 [chan send, 2 minutes]:
github.com/Connor1996/badger.(*writeWorker).writeVLog(0xc00001ce80, 0xc04c1e8000, 0x1, 0x1, 0xc04c1e8000, 0x0)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/writer.go:127 +0xe5
github.com/Connor1996/badger.(*writeWorker).runWriteVLog(0xc00001ce80, 0xc00001ce40)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/writer.go:99 +0x286
created by github.com/Connor1996/badger.startWriteWorker
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/writer.go:63 +0x193

goroutine 49 [chan receive, 2 minutes, locked to thread]:
github.com/Connor1996/badger.(*writeWorker).runWriteLSM(0xc00001ce80, 0xc00001ce40)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/writer.go:138 +0x1aa
created by github.com/Connor1996/badger.startWriteWorker
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/writer.go:64 +0x1bf

goroutine 82 [chan receive, 2 minutes]:
github.com/Connor1996/badger.(*writeWorker).runMergeLSM(0xc00001ce80, 0xc00001ce40)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/writer.go:151 +0xba
created by github.com/Connor1996/badger.startWriteWorker
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/writer.go:65 +0x1eb

goroutine 62 [select, 2 minutes]:
github.com/dgraph-io/ristretto.(*defaultPolicy).processItems(0xc00001fd10)
    /Users/Connor/Coding/pkg/mod/github.com/dgraph-io/ristretto@v0.0.0-20191010170704-2ba187ef9534/policy.go:96 +0xbe
created by github.com/dgraph-io/ristretto.newDefaultPolicy
    /Users/Connor/Coding/pkg/mod/github.com/dgraph-io/ristretto@v0.0.0-20191010170704-2ba187ef9534/policy.go:80 +0x129

goroutine 63 [select, 2 minutes]:
github.com/dgraph-io/ristretto.(*Cache).processItems(0xc0000a4720)
    /Users/Connor/Coding/pkg/mod/github.com/dgraph-io/ristretto@v0.0.0-20191010170704-2ba187ef9534/cache.go:250 +0xbc
created by github.com/dgraph-io/ristretto.NewCache
    /Users/Connor/Coding/pkg/mod/github.com/dgraph-io/ristretto@v0.0.0-20191010170704-2ba187ef9534/cache.go:152 +0x1f3

goroutine 64 [select, 2 minutes]:
github.com/Connor1996/badger.Open.func4(0xc0000100c8)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/db.go:287 +0x15f
created by github.com/Connor1996/badger.Open
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/db.go:284 +0xcdf

goroutine 65 [select]:
github.com/Connor1996/badger.(*DB).updateSize(0xc0000e4900, 0xc00001d760)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/db.go:1011 +0x157
created by github.com/Connor1996/badger.Open
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/db.go:299 +0xdb3

goroutine 98 [chan receive]:
github.com/Connor1996/badger/epoch.(*ResourceManager).collectLoop(0xc0000a5080)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/epoch/manager.go:96 +0x85
created by github.com/Connor1996/badger/epoch.NewResourceManager
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/epoch/manager.go:76 +0x7a

goroutine 99 [chan receive, 2 minutes]:
github.com/Connor1996/badger.(*blobGCHandler).run(0xc0000d2880)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/blob.go:464 +0x52
created by github.com/Connor1996/badger.(*blobManager).Open
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/blob.go:290 +0x58a

goroutine 100 [select]:
github.com/Connor1996/badger.(*levelsController).runWorker(0xc0000160c0, 0xc000134700)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/levels.go:198 +0x1a8
created by github.com/Connor1996/badger.(*levelsController).startCompact
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/levels.go:183 +0x88

goroutine 101 [select]:
github.com/Connor1996/badger.(*levelsController).runWorker(0xc0000160c0, 0xc000134700)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/levels.go:198 +0x1a8
created by github.com/Connor1996/badger.(*levelsController).startCompact
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/levels.go:183 +0x88

goroutine 102 [select]:
github.com/Connor1996/badger.(*levelsController).runWorker(0xc0000160c0, 0xc000134700)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/levels.go:198 +0x1a8
created by github.com/Connor1996/badger.(*levelsController).startCompact
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/levels.go:183 +0x88

goroutine 103 [chan receive, 2 minutes]:
github.com/Connor1996/badger.(*DB).runFlushMemTable(0xc0000e4900, 0xc00001d720, 0x0, 0x0)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/db.go:892 +0xff
created by github.com/Connor1996/badger.Open
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/db.go:317 +0x146b

goroutine 110 [chan receive, 2 minutes, locked to thread]:
github.com/Connor1996/badger.(*writeWorker).runWriteLSM(0xc000134820, 0xc0001347e0)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/writer.go:138 +0x1aa
created by github.com/Connor1996/badger.startWriteWorker
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/writer.go:64 +0x1bf

goroutine 109 [select, 2 minutes]:
github.com/Connor1996/badger.(*writeWorker).runWriteVLog(0xc000134820, 0xc0001347e0)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/writer.go:92 +0x167
created by github.com/Connor1996/badger.startWriteWorker
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/writer.go:63 +0x193

goroutine 108 [select, 2 minutes]:
github.com/Connor1996/badger.(*writeWorker).runFlusher(0xc000134820, 0xc0001347e0)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/writer.go:72 +0x116
created by github.com/Connor1996/badger.startWriteWorker
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/writer.go:61 +0x226

goroutine 111 [chan receive, 2 minutes]:
github.com/Connor1996/badger.(*writeWorker).runMergeLSM(0xc000134820, 0xc0001347e0)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/writer.go:151 +0xba
created by github.com/Connor1996/badger.startWriteWorker
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/writer.go:65 +0x1eb

goroutine 112 [semacquire, 2 minutes]:
sync.runtime_Semacquire(0xc0000d2a60)
    /usr/local/Cellar/go/1.13.5/libexec/src/runtime/sema.go:56 +0x42
sync.(*WaitGroup).Wait(0xc0000d2a58)
    /usr/local/Cellar/go/1.13.5/libexec/src/sync/waitgroup.go:130 +0x64
github.com/Connor1996/badger.(*request).Wait(0xc0000d2a40, 0xc04c1e4000, 0x2)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/value.go:491 +0x35
github.com/Connor1996/badger.(*Txn).Commit(0xc04c1e0000, 0x0, 0x0)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/transaction.go:490 +0x5b1
github.com/Connor1996/badger.(*DB).Update(0xc0000e4480, 0xc0000d7e30, 0x0, 0x0)
    /Users/Connor/Coding/pkg/mod/github.com/!connor1996/badger@v1.5.1-0.20200220043901-cee19f7bcf4f/transaction.go:562 +0xcb
github.com/pingcap-incubator/tinykv/kv/util/engine_util.(*WriteBatch).WriteToDB(0xc0000d2980, 0xc0000e4480, 0xfb0000c0000101d0, 0x0)
    /Users/Connor/Coding/src/github.com/pingcap-incubator/tinykv/kv/util/engine_util/write_batch.go:83 +0x70
github.com/pingcap-incubator/tinykv/kv/tikv/raftstore.(*applyContext).writeToDB(0xc000107500)
    /Users/Connor/Coding/src/github.com/pingcap-incubator/tinykv/kv/tikv/raftstore/applier.go:249 +0x3f
github.com/pingcap-incubator/tinykv/kv/tikv/raftstore.(*applyContext).flush(0xc000107500)
    /Users/Connor/Coding/src/github.com/pingcap-incubator/tinykv/kv/tikv/raftstore/applier.go:276 +0x2f
github.com/pingcap-incubator/tinykv/kv/tikv/raftstore.(*applyWorker).run(0xc000134860, 0xc000038280)
    /Users/Connor/Coding/src/github.com/pingcap-incubator/tinykv/kv/tikv/raftstore/raft_worker.go:158 +0x13a
created by github.com/pingcap-incubator/tinykv/kv/tikv/raftstore.TestHandleRaftCommittedEntries
    /Users/Connor/Coding/src/github.com/pingcap-incubator/tinykv/kv/tikv/raftstore/raft_worker_test.go:135 +0x385

goroutine 31 [IO wait, 2 minutes]:
internal/poll.runtime_pollWait(0x5177d88, 0x72, 0xffffffffffffffff)
    /usr/local/Cellar/go/1.13.5/libexec/src/runtime/netpoll.go:184 +0x55
internal/poll.(*pollDesc).wait(0xc0001e4198, 0x72, 0x1000, 0x1000, 0xffffffffffffffff)
    /usr/local/Cellar/go/1.13.5/libexec/src/internal/poll/fd_poll_runtime.go:87 +0x45
internal/poll.(*pollDesc).waitRead(...)
    /usr/local/Cellar/go/1.13.5/libexec/src/internal/poll/fd_poll_runtime.go:92
internal/poll.(*FD).Read(0xc0001e4180, 0xc04c1ec000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.13.5/libexec/src/internal/poll/fd_unix.go:169 +0x22b
net.(*netFD).Read(0xc0001e4180, 0xc04c1ec000, 0x1000, 0x1000, 0xc04c46b1c0, 0xc03614e7e8, 0x437e653)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/fd_unix.go:202 +0x4f
net.(*conn).Read(0xc000132150, 0xc04c1ec000, 0x1000, 0x1000, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/net.go:184 +0x68
net/http.(*connReader).Read(0xc0001c8630, 0xc04c1ec000, 0x1000, 0x1000, 0x0, 0x0, 0x203000)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/http/server.go:785 +0xf4
bufio.(*Reader).fill(0xc0000971a0)
    /usr/local/Cellar/go/1.13.5/libexec/src/bufio/bufio.go:100 +0x103
bufio.(*Reader).ReadSlice(0xc0000971a0, 0xa, 0x28, 0xc03614e9a8, 0x400e456, 0xc04c366100, 0x100)
    /usr/local/Cellar/go/1.13.5/libexec/src/bufio/bufio.go:359 +0x3d
bufio.(*Reader).ReadLine(0xc0000971a0, 0xc03614e9b0, 0xc000058800, 0x51136d0, 0x0, 0x400ecc8, 0x30)
    /usr/local/Cellar/go/1.13.5/libexec/src/bufio/bufio.go:388 +0x34
net/textproto.(*Reader).readLineSlice(0xc0001c8660, 0xc04c366100, 0xc0001e4180, 0x0, 0x0, 0x40622e0)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/textproto/reader.go:57 +0x6c
net/textproto.(*Reader).ReadLine(...)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/textproto/reader.go:38
net/http.readRequest(0xc0000971a0, 0x0, 0xc04c366100, 0x0, 0x0)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/http/request.go:1012 +0x92
net/http.(*conn).readRequest(0xc0001ea140, 0x4a31b60, 0xc04c46b180, 0x0, 0x0, 0x0)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/http/server.go:965 +0x15f
net/http.(*conn).serve(0xc0001ea140, 0x4a31b60, 0xc04c46b180)
    /usr/local/Cellar/go/1.13.5/libexec/src/net/http/server.go:1817 +0x6d4
created by net/http.(*Server).Serve
    /usr/local/Cellar/go/1.13.5/libexec/src/net/http/server.go:2928 +0x384
coocood commented 4 years ago

@Connor1996 Please try and check if this https://github.com/coocood/badger/pull/171 change fixes this issue.

Connor1996 commented 4 years ago

@coocood Thanks, I'll have a try

Connor1996 commented 4 years ago

@coocood The panic never occurs after running couples of times, but the blocking issue still exists.