lni / dragonboat

A feature complete and high performance multi-group Raft library in Go.
Apache License 2.0
4.99k stars 534 forks source link

`SyncRequestSnapshot` panic if `SaveSnapshot` return `ErrSnapshotAborted` #260

Closed hulucc closed 1 year ago

hulucc commented 1 year ago

Note: for reported bugs, please fill in the following details. bug reports without detailed steps on how to reproduce will be automatically closed.

Dragonboat version

v3.3.5

Expected behavior

SyncRequestSnapshot return abort error.

Actual behavior

|| panic: unknown v code {5 {0 []} true} [recovered]
||  panic: unknown v code {5 {0 []} true}
|| 
|| goroutine 34 [running]:
|| testing.tRunner.func1.2({0x7ff6629f1860, 0xc0003066a0})
||  C:/Users/hulucc/scoop/apps/go/current/src/testing/testing.go:1396 +0x24e
|| testing.tRunner.func1()
||  C:/Users/hulucc/scoop/apps/go/current/src/testing/testing.go:1399 +0x39f
|| panic({0x7ff6629f1860, 0xc0003066a0})
||  C:/Users/hulucc/scoop/apps/go/current/src/runtime/panic.go:884 +0x212
|| github.com/lni/goutils/logutil/capnslog.(*PackageLogger).Panicf(0x18?, {0x7ff662b17157?, 0xc000290058?}, {0xc000306660?, 0xc0002862d0?, 0xc00179fa50?})
||  C:/Users/hulucc/go/pkg/mod/github.com/!lilith!games/goutils@v1.3.3/logutil/capnslog/pkg_logger.go:88 +0xbb
|| github.com/lni/dragonboat/v3/logger.(*capnsLog).Panicf(0xc0002862d0?, {0x7ff662b17157?, 0xc000687830?}, {0xc000306660?, 0xc000687830?, 0xc00179fb50?})
||  C:/Users/hulucc/go/pkg/mod/github.com/lni/dragonboat/v3@v3.3.5/logger/capnslogger.go:74 +0x26
|| github.com/lni/dragonboat/v3/logger.(*dragonboatLogger).Panicf(0x7ff662a79980?, {0x7ff662b17157, 0x11}, {0xc000306660, 0x1, 0x1})
||  C:/Users/hulucc/go/pkg/mod/github.com/lni/dragonboat/v3@v3.3.5/logger/logger.go:132 +0x57
|| github.com/lni/dragonboat/v3.getRequestState({0x7ff662c4b2c8, 0xc00112ec60}, 0x0?)
||  C:/Users/hulucc/go/pkg/mod/github.com/lni/dragonboat/v3@v3.3.5/nodehost.go:2003 +0x338
|| github.com/lni/dragonboat/v3.(*NodeHost).SyncRequestSnapshot(0x7ff662c4b290?, {0x7ff662c4b2c8, 0xc00112ec60}, 0x0?, {0x0?, {0x0?, 0xc000d29c00?}, 0x70?, 0x6b?})
||  C:/Users/hulucc/go/pkg/mod/github.com/lni/dragonboat/v3@v3.3.5/nodehost.go:957 +0xaf
|| github.com/LilithGames/protoc-gen-dragonboat.taskSnapshot(0xc0002c4a80, 0xc000286ba0?)
||  d:/project/syncd-ws/protoc-gen-dragonboat/example_test.go:98 +0xa9
|| github.com/LilithGames/protoc-gen-dragonboat.TestSnapshot4(0x0?)
||  d:/project/syncd-ws/protoc-gen-dragonboat/example_test.go:144 +0x139
|| testing.tRunner(0xc000284820, 0x7ff662b5f840)
||  C:/Users/hulucc/scoop/apps/go/current/src/testing/testing.go:1446 +0x10b
|| created by testing.(*T).Run
||  C:/Users/hulucc/scoop/apps/go/current/src/testing/testing.go:1493 +0x35f
|| exit status 2

Steps to reproduce the behavior

As the title

lni commented 1 year ago

it seems to me that the Aborted state is not covered in the getRequestState method. Seems to be an easy fix, just need to recall & confirm why it was not covered in the first place.

lni commented 1 year ago

fixed in master, please let me know if you see anything else broken/strange. https://github.com/lni/dragonboat/commit/6e5afcc9ac54d5df853ca8430dcc878c8b03ec14

will leave it there for a few days, if nothing surprise me, will patch the v3.3 branch during the coming weekend.

thanks again for reporting the bug.

lni commented 1 year ago

v3.3.6 has been released with the above mentioned fix.

https://github.com/lni/dragonboat/releases/tag/v3.3.6