vinyl: don't eliminate insert+delete during index build
In 0e37af31 an optimization eliminating INSERT+DELETE and DELETE+INSERT statements by the same key in write set was introduced. It is fine until it comes for secondary index build. While we are building secondary index we save current lsn, set on_replace trigger forwarding new requests to the secondary index and copy row-by-row tuples (to be more precise keys) to secondary index until lsn of tuple is less than the one we preserved at the start. Now, if during index build we execute request replacing key that hasn't been already transferred to secondary index, we will get missing key in secondary index since: a) In on_replace trigger replace is split into DELETE+INSERT and eliminated by mentioned optimization (the same concerns simple pair of DELETE+INSERT requests made in single transaction - so that they get into one write set); b) It is skipped in the main loop transferring tuples from PK to SK since lsn of modified tuples is greater than saved lsn. In this respect, we may get missing tuples in secondary index. The proposed solution is quite trivial: we are able to track that index is still being created (see previous commit) so we won't apply INSERT+DELETE annihilation if index build is not finished. Closes #6045
Showing
- changelogs/unreleased/gh-6045-missing-tuples-in-sk.md 4 additions, 0 deletionschangelogs/unreleased/gh-6045-missing-tuples-in-sk.md
- src/box/vy_tx.c 14 additions, 1 deletionsrc/box/vy_tx.c
- test/vinyl/gh-6045-missing-tuples-after-sc-build.result 86 additions, 0 deletionstest/vinyl/gh-6045-missing-tuples-after-sc-build.result
- test/vinyl/gh-6045-missing-tuples-after-sc-build.test.lua 43 additions, 0 deletionstest/vinyl/gh-6045-missing-tuples-after-sc-build.test.lua
Loading
Please register or sign in to comment