memtx: rework transaction rollback
When we rollback a transaction statement, we relink its read trackers to a newer story in the history chain, if present (6c990a7b), but we do not handle the case when there is no newer story. If there is an older story in the history chain, we can relink the rollbacked story's reader to it, but if the rollbacked story is the only one left, we need to retain it, because it stores the reader list needed for conflict resolution — such stories are distinguished by the rollbacked flag, and there can be no more than one such story located strictly at the end of a given history chain (which means a story can be fully unlinked from some indexes and present at the end of others). There are several nuances we need to account for: Firstly, such rollbacked stories must be impossible to read from an index: this is ensured by `memtx_tx_story_is_visible`. Secondly, rollbacked transactions need to be treated as prepared with stories that have `add_psn == del_psn`, so that they are correctly deleted during garbage collection. After this logical change we have the following partially ordered set over tuple stories: ———————————————————————————————————————————————————————> serialization time |- - - - - - - -|— — — — — -|— — — — — |— — — — — — -|— — — — — — — - | No more than | Committed | Prepared | In-progress | One dirty | one rollbacked| | | | story in index | story | | | | |- - - - - - - -|— — — — — -| — — — — —|— — — — — — -|— — — — — — — — Closes #7343 NO_DOC=bugfix
Showing
- changelogs/unreleased/gh-7343-unserializable-read-tracked-incorrectly-after-rollback.md 4 additions, 0 deletions...unserializable-read-tracked-incorrectly-after-rollback.md
- src/box/memtx_tx.c 76 additions, 26 deletionssrc/box/memtx_tx.c
- src/box/memtx_tx.h 8 additions, 0 deletionssrc/box/memtx_tx.h
- src/box/txn.c 27 additions, 0 deletionssrc/box/txn.c
- test/box-luatest/gh_7343_unserializable_read_tracked_incorrectly_after_rollback_test.lua 53 additions, 0 deletions...alizable_read_tracked_incorrectly_after_rollback_test.lua