-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
76959: sql: fix bug in inverted index creation r=ajwerner,rhu713 a=stevendanna When updating an inverted index, we calculate all index entries for the old values and new values with the intent of issuing a Delete for every old entry and a Put for every new entry. To try to save on work, the updater looks for Del's that are followed by identical Put's and removes both from the set of index entries to process. This de-duplication is incorrect for temporary indexes used in the mvcc-compatible index backfilling process. Consider the following: ``` t1: Write of k=1, v={"a": 1} t2: CREATE INDEX (i2 is in BACKFILLING, i3 (temporary) is in DELETE_ONLY) t3: i3 moves to DELETE_AND_WRITE_ONLY t4: AddSSTable backfill into i2 t5: i2 moves to DELETE_ONLY ``` At this point, `i2` contains 1 inverted entry for k=1. and i3 is empty. Now, say an update is issued: ``` t6: Write of k=1, v={"a": 1, "b": 2} ``` Index `i2` is in DELETE_ONLY. The delete path has no deduplication logic, so we just see the delete for a key that looks something like ``` Del /Table/106/2/"a"/1/1/0 ``` But, `i3` is in DELETE_AND_WRITE ONLY, so both the delete _and the associated write_ is elided, so instead of: ``` Put /Table/106/3/"a"/1/1/0 Put (delete) /Table/106/3/"a"/1/1/0 Put /Table/106/3/"b"/2/1/0 ``` it only sees a single Put: ``` Put /Table/106/3/"b"/2/1/0 ``` Thus, we now have an empty `i2` and a single entry in `i3`. When we go to merge i3 into i2, we will get our single entry. But, we are supposed to have two entries. When we eventually try to validate `i2`, it will fail because of the missing entry. To account for this, we skip de-duplication on temporary indexes. Release note: None Co-authored-by: Steven Danna <[email protected]>
- Loading branch information
Showing
6 changed files
with
132 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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