-
Notifications
You must be signed in to change notification settings - Fork 16
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
state: fix locking issues during Commit #1102
Conversation
Pull Request Test Coverage Report for Build 6247858876
💛 - Coveralls |
ac6202a
to
951ddd0
Compare
i went down a deep rabbit hole until ac6202a trying to reproduce the issue with so i went the end2endtest way, and reproduced it by bruteforce 🥳
|
127b08f
to
df1b96b
Compare
so definitely the race is during app.Commit
|
48763c4
to
ac0b6d8
Compare
a58e7e8
to
8bdce52
Compare
8bdce52
to
fc75e10
Compare
so, some progress, but not enough (yet) on one hand, pau reminded me of #465 which i believe will be fixed by fc75e10 in theory my |
but on another hand, it looks like the https://github.com/vocdoni/vocdoni-node/actions/runs/6234524391/job/16921885853?pr=1102#step:4:7406
|
mapping the rabbit hole:
Lines 379 to 385 in e3a896d
Lines 585 to 586 in e3a896d
note vocdoni-node/vochain/state/process.go Lines 101 to 106 in e6fd61d
and mainTreeViewer returns a vocdoni-node/vochain/state/trees.go Lines 58 to 67 in f40bf38
which is, in turn, just a pointer vocdoni-node/vochain/state/trees.go Lines 46 to 50 in f40bf38
that is only ever updated using vocdoni-node/vochain/state/trees.go Lines 52 to 56 in f40bf38
vocdoni-node/vochain/state/state.go Lines 417 to 428 in b787fde
so my understanding is that when the API endpoint is queried during Commit, getProcess waits until v.tx.Unlock is released, then manages to get a |
f8bbceb
to
1ac248f
Compare
well, not exactly. getProcess doesn't really waits until i believe the correct fix is to make MainTreeView respect the lock as well vocdoni-node/vochain/state/trees.go Lines 48 to 52 in 1a75a39
(in addition to the vocdoni-node/vochain/state/state.go Line 413 in 76cfa6e
with these two changes, the issue is gone for good (both in CI and in my local tests, consistently). WDYT @mvdan @p4u? i understand this was no issue until now, since trees were never pruned, so the old trees were left intact and so Get would never fail. |
6837f02
to
6053601
Compare
ad87898
to
2615e7f
Compare
6053601
to
9bb6cd3
Compare
* State.MainTreeView needs to respect v.tx.RLock() * State.Save now defers v.tx.Unlock() until the end fix #1100 'while down, could not get value for key' that was returned on any query to the state during Commit of a block
f582c69
to
16f785d
Compare
the new test raceDuringCommit triggers issue #1100 reproducibly (i triggered 3 re-runs, all of them failed) and after applying the fix 6bca6cd, no more failures (2 re-runs) 🥳 |
( |
So, is this ready to merge @altergui ? |
state: fix locking issues during Commit
fix #1100 'while down, could not get value for key'
that was returned on any query to the state
during Commit of a block