Repository navigation
Clear INDEX_SLIDING_WINDOW_SPACE in clearIndexData and related lifecycle paths - #4232
Conversation
…cle paths
FDBRecordStore.clearIndexData did not clear the sliding window subspace,
so calling clearAndMarkIndexWriteOnly (which routes through it) left
stale window/overflow bookkeeping behind. After a subsequent online
rebuild, queries could observe state that did not reflect record
mutations that occurred while the index was write-only.
Audit-driven fixes:
- FDBRecordStore.clearIndexData: clear indexSlidingWindowSubspace.
- KeySpaceTreeResolver.resolveNonDirectory: add INDEX_SLIDING_WINDOW_SPACE
to the per-index switch so tooling resolves keys under it back to
their owning Index.
- OnlineIndexerTest.clearIndexData test helper: mirror the production
fix.
Tests:
- SlidingWindowIndexTest: focused regression for clearIndexData
leaving the sliding window subspace populated.
- FDBRecordStoreClearIndexDataTest: forward-looking, parameterized
over FDBRecordStoreKeyspace. Categorizes every enum value as
non-per-index or per-method "cleared by" so a future per-index
keyspace addition fails by design unless explicitly categorized.
Pins the lock-preservation contract for INDEX_BUILD_SPACE.
- KeySpaceTreeResolverTest: parameterized forward-looking coverage
for the per-index switch in resolveNonDirectory.
jjezra
left a comment
There was a problem hiding this comment.
(I don't know enough about KeySpaceTreeResolver, so limited my review to the index itself...)
| @@ -106,6 +106,7 @@ void clearIndexData(@Nonnull Index index) { | |||
There was a problem hiding this comment.
Since nobody calls this function (and it is not being tested) it might be a good idea to remove it altogether.
(If ever needed, it would be safer to use FDBRecordStore.clearIndexData)
| case INDEX_RANGE_SPACE: | ||
| case INDEX_UNIQUENESS_VIOLATIONS_SPACE: | ||
| case INDEX_BUILD_SPACE: | ||
| case INDEX_SLIDING_WINDOW_SPACE: |
There was a problem hiding this comment.
If I understand this correctly, this logic is trying to interpret a given subspace key. And if the first element in the key matches one of the known keys (2 for index, 3 for index secondary subspace and so on). It immediately resolves it to an index, meaning that the key we're trying to resolve must belong to an index. Is that correct?
There was a problem hiding this comment.
Yes, the next value in the tuple is expected to be an index subspace key.
FDBRecordStore.clearIndexDatadid not clear the sliding window subspace, so callingclearAndMarkIndexWriteOnly(which routes through it) left stale window/overflow bookkeeping behind. After a subsequent online rebuild, the window would be from the previous build, which may reference records that do not exist anymore.This includes 3 production fixes, one referenced above, plus two others that were missed in the original sliding window implementation:
In addition to basic regression tests, testing has expanded to help protect against missing this in the future.