statedb: Minor fixes to write transactions - #204
Merged
Merged
Conversation
WriteTxn() clones the root and Commit() publishes that clone after refreshing the entries of the tables it did not lock from the current root. If a table was registered while the write transaction was open the current root is longer than the clone and the newly registered table was dropped from the committed root, leading to an index out of range panic when accessing the table. Append the entries of any tables registered after the write transaction was created when committing. AIL:3 Signed-off-by: Jussi Maki <jussi@isovalent.com>
CompareAndSwap() and CompareAndDelete() first modified the primary index and then reverted the change if the guard revision did not match or the object did not exist. The revert left the index transaction dirty and the watch channels of the key and the root marked for closing, waking up watchers on commit even though nothing had changed. Check the guard revision with a lookup before modifying the index. This costs an extra lookup for CompareAndSwap() and CompareAndDelete() but failures now leave the indexes untouched. AIL:3 Signed-off-by: Jussi Maki <jussi@isovalent.com>
The index transaction of a partIndex is stored in the partIndex itself to avoid allocating it. The partIndex is shared with the committed root and Abort() did not clear it. This kept all the cloned nodes and the objects inserted in the aborted write transaction alive until the next write transaction against the index. Add abort() to the tableIndex interface and call it on the indexes of the locked tables on Abort(). partIndexTxn drops its transaction and for the other implementations it is a no-op. AIL:3 Signed-off-by: Jussi Maki <jussi@isovalent.com>
joamaki
force-pushed
the
pr/joamaki/minor-writetxn-fixes
branch
from
September 25, 2026 10:11
b3dd6da to
bf51338
Compare
|
bimmlerd
approved these changes
Sep 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
AIL:3