vinyl: disable deferred deletes if there are upserts on disk
Normally, there shouldn't be any upserts on disk if the space has secondary indexes, because we can't generate an upsert without a lookup in the primary index hence we convert upserts to replace+delete in this case. The deferred delete optimization only makes sense if the space has secondary indexes. So we ignore upserts while generating deferred deletes, see vy_write_iterator_deferred_delete. There's an exception to this rule: a secondary index could be created after some upserts were used on the space. In this case, because of the deferred delete optimization, we may never generate deletes for some tuples for the secondary index, as demonstrated in #3638. We could fix this issue by properly handle upserts in the write iterator while generating deferred delete, but this wouldn't be easy, because in case of a minor compaction there may be no replace/insert to apply the upsert to so we'd have to keep intermediate upserts even if there is a newer delete statement. Since this situation is rare (happens only once in a space life time), it doesn't look like we should complicate the write iterator to fix it. Another way to fix it is to force major compaction of the primary index after a secondary index is created. This looks doable, but it could slow down creation of secondary indexes. Let's instead simply disable the deferred delete optimization if the primary index has upsert statements. This way the optimization will be enabled sooner or later, when the primary index major compaction occurs. After all, it's just an optimization and it can be disabled for other reasons (e.g. if the space has on_replace triggers). Closes #3638 NO_DOC=bug fix
Showing
- changelogs/unreleased/gh-3638-vy-defer-deletes-and-upserts.md 7 additions, 0 deletions...gelogs/unreleased/gh-3638-vy-defer-deletes-and-upserts.md
- src/box/vinyl.c 15 additions, 2 deletionssrc/box/vinyl.c
- test/vinyl-luatest/gh_3638_defer_deletes_and_upserts_test.lua 64 additions, 0 deletions.../vinyl-luatest/gh_3638_defer_deletes_and_upserts_test.lua
Loading
Please register or sign in to comment