xcherryio / xcherry

server and main repo of xCherry project
Apache License 2.0
26 stars 1 forks source link

Received local queue messages are not in correct order #85

Open longquanzheng opened 10 months ago

longquanzheng commented 10 months ago

Intemittent failure in Golang SDK integ test -- the test case expect the first message is a stirng and second is an object. But sometimes it recieved an object as first message.

https://github.com/xdblab/xdb-golang-sdk/blob/5445c78705a35a6987842f5b9bcce7fc02b12b34/integTests/command_request/any_of_timer_local_queue.go#L89

2023-11-09T19:58:51.1214516Z === RUN   TestAnyOfTimerLocalQueueWithLocalQueueMessagesReceived
2023-11-09T19:58:51.1215365Z process id: test1699559919017720907
2023-11-09T19:58:51.1216558Z [GIN] 2023/11/09 - 19:58:39 | 200 |      92.607µs |      172.18.0.3 | POST     "/api/v1/xdb/worker/async-state/wait-until"
2023-11-09T19:58:51.1218390Z 2023/11/09 19:58:39 panic is captured: json: cannot unmarshal object into Go value of type string , stacktrace: goroutine 120 [running]:
2023-11-09T19:58:51.1219693Z runtime/debug.Stack()
2023-11-09T19:58:51.1220423Z    /opt/hostedtoolcache/go/1.20.10/x64/src/runtime/debug/stack.go:24 +0x65
2023-11-09T19:58:51.1221968Z github.com/xdblab/xdb-golang-sdk/xdb.captureStateExecutionError({0x8aa540, 0xc00051e460}, 0xc0000e1400)
2023-11-09T19:58:51.1223519Z    /home/runner/work/xdb-golang-sdk/xdb-golang-sdk/xdb/errors_worker.go:34 +0x54
2023-11-09T19:58:51.1224998Z github.com/xdblab/xdb-golang-sdk/xdb.(*workerServiceImpl).HandleAsyncStateExecute.func1()
2023-11-09T19:58:51.1226527Z    /home/runner/work/xdb-golang-sdk/xdb-golang-sdk/xdb/worker_service_impl.go:47 +0x31
2023-11-09T19:58:51.1227621Z panic({0x8aa540, 0xc00051e460})
2023-11-09T19:58:51.1228381Z    /opt/hostedtoolcache/go/1.20.10/x64/src/runtime/panic.go:884 +0x213
2023-11-09T19:58:51.1230591Z github.com/xdblab/xdb-golang-sdk/xdb.LocalQueueCommandResult.GetFirstMessage({{{0xc000434468, 0x11}, {0xc0002545e0, 0xc}, {0xc00059a6c0, 0x2, 0x4}}, {0xa17580, 0xd4bcd8}}, {0x88bc40, ...})
2023-11-09T19:58:51.1232765Z    /home/runner/work/xdb-golang-sdk/xdb-golang-sdk/xdb/command_results.go:49 +0xc5
2023-11-09T19:58:51.1235263Z github.com/xdblab/xdb-golang-sdk/integTests/command_request.anyOfTimerLocalQState.Execute({{{}}}, {0xc0003c2800?, 0xc00058fc20?}, {0xa14940, 0xc000590930}, {{0xc00059f2d0, 0x1, 0x1}, {0xc00051e410, 0x1, ...}}, ...)
2023-11-09T19:58:51.1237924Z    /home/runner/work/xdb-golang-sdk/xdb-golang-sdk/integTests/command_request/any_of_timer_local_queue.go:52 +0x565
2023-11-09T19:58:51.1240903Z github.com/xdblab/xdb-golang-sdk/xdb.(*workerServiceImpl).HandleAsyncStateExecute(0xc0003c9c50, {0xc0001cb0a6?, 0xc0000e16d0?}, {{{0xc000434480, 0x17}, {0xc0003382d0, 0x24}, 0x0, 0xc00059f2c0, 0xc000254600, ...}, ...})
2023-11-09T19:58:51.1243275Z    /home/runner/work/xdb-golang-sdk/xdb-golang-sdk/xdb/worker_service_impl.go:63 +0x3ce
2023-11-09T19:58:51.1245111Z github.com/xdblab/xdb-golang-sdk/integTests/worker.worker.apiAsyncStateExecute({{0xa15918?, 0xc0003c9c50?}}, 0xc0003f4a00)
2023-11-09T19:58:51.1246964Z    /home/runner/work/xdb-golang-sdk/xdb-golang-sdk/integTests/worker/worker.go:57 +0x106
zklgame commented 10 months ago

Oh I think there is no guarantee of which local queue message will be dealt first, beucase the immeidate tasks are handled in parallel.