-
Notifications
You must be signed in to change notification settings - Fork 251
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
BN, add timeout for sync workers which are waiting in queue. #5831
base: unstable
Are you sure you want to change the base?
Changes from all commits
bb3269e
662c365
642be87
423a8bc
727b3f6
f2b3c70
d02376a
7843d8f
0a4d3ac
99f657e
79dd6c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
|
||
import std/[strutils, sequtils] | ||
import unittest2 | ||
import chronos | ||
import chronos, chronos/unittest2/asynctests | ||
import ../beacon_chain/gossip_processing/block_processor, | ||
../beacon_chain/sync/sync_manager, | ||
../beacon_chain/spec/forks | ||
|
@@ -1135,8 +1135,6 @@ suite "SyncManager test suite": | |
check: | ||
groupedRes3.isErr() | ||
|
||
|
||
|
||
test "[SyncQueue#Forward] getRewindPoint() test": | ||
let aq = newAsyncQueue[BlockEntry]() | ||
block: | ||
|
@@ -1208,3 +1206,69 @@ suite "SyncManager test suite": | |
let safeSlot = getSafeSlot() | ||
for i in countdown(1023, 0): | ||
check queue.getRewindPoint(Slot(i), safeSlot) == safeSlot | ||
|
||
template workerTimeoutTest(startSlot, finishSlot: Slot, | ||
kind: SyncQueueKind) = | ||
let aq = newAsyncQueue[BlockEntry]() | ||
var | ||
chain = createChain(startSlot, finishSlot) | ||
queue = | ||
case kind | ||
of SyncQueueKind.Forward: | ||
SyncQueue.init(SomeTPeer, kind, startSlot, finishSlot, | ||
1'u64, getStaticSlotCb(startSlot), | ||
collector(aq), 1, "worker-timeout-test", | ||
100.milliseconds) | ||
of SyncQueueKind.Backward: | ||
SyncQueue.init(SomeTPeer, kind, finishSlot, startSlot, | ||
1'u64, getStaticSlotCb(finishSlot), | ||
collector(aq), 1, "worker-timeout-test", | ||
100.milliseconds) | ||
|
||
let | ||
p1 = SomeTPeer() | ||
p2 = SomeTPeer() | ||
p3 = SomeTPeer() | ||
p4 = SomeTPeer() | ||
r11 {.used.} = queue.pop(finishSlot, p1) | ||
r12 = queue.pop(finishSlot, p2) | ||
r13 = queue.pop(finishSlot, p3) | ||
r14 = queue.pop(finishSlot, p4) | ||
f12 = queue.push( | ||
r12, chain.getSlice(Slot(0), r12), Opt.none(seq[BlobSidecars])) | ||
f13 = queue.push( | ||
r13, chain.getSlice(Slot(0), r13), Opt.none(seq[BlobSidecars])) | ||
f14 = queue.push( | ||
r14, chain.getSlice(Slot(0), r14), Opt.none(seq[BlobSidecars])) | ||
|
||
check: | ||
f12.finished() == false | ||
f13.finished() == false | ||
f14.finished() == false | ||
|
||
# Current timeout value is 100.milliseconds per block. | ||
await sleepAsync(400.milliseconds) | ||
|
||
check: | ||
f12.finished() == true | ||
f13.finished() == true | ||
f14.finished() == true | ||
|
||
let | ||
r22 = queue.pop(finishSlot, p2) | ||
r23 = queue.pop(finishSlot, p3) | ||
r24 = queue.pop(finishSlot, p4) | ||
|
||
check: | ||
r22.slot == r12.slot | ||
r22.count == r12.count | ||
r23.slot == r13.slot | ||
r23.count == r13.count | ||
r24.slot == r14.slot | ||
r24.count == r14.count | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. and, also, if otherwise, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep in old version |
||
|
||
asyncTest "[SyncQueue#Forward] SyncQueue worker timeout test": | ||
workerTimeoutTest(Slot(0), Slot(200), SyncQueueKind.Forward) | ||
|
||
asyncTest "[SyncQueue#Backward] SyncQueue worker timeout test": | ||
workerTimeoutTest(Slot(0), Slot(200), SyncQueueKind.Backward) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the value if every single request takes the maximum time to complete a single time.
I wonder if a simpler mechanism with a static, e.g., 30sec timeout, could also mitigate the risk of getting stuck. It would take a bit longer to unstuck than the current solution, but is simpler to reason about.
Alternatively, to get it fully correct may involve having to re-schedule the timeouts whenever a prior request completes.