Skip to content

Attempt preventing "record store state is being used for queries" during index rebuild#4011

Merged
MMcM merged 6 commits intoFoundationDB:mainfrom
jjezra:rebuild_indexes_avoid_conflicts_small
Apr 9, 2026
Merged

Attempt preventing "record store state is being used for queries" during index rebuild#4011
MMcM merged 6 commits intoFoundationDB:mainfrom
jjezra:rebuild_indexes_avoid_conflicts_small

Conversation

@jjezra
Copy link
Copy Markdown
Contributor

@jjezra jjezra commented Mar 18, 2026

Addresses two issues:

  1. recordStoreStateRef.updateAndGet lambdas were non repeatble
  2. rebuildIndexes preset futures items could havce performed index state read

@jjezra jjezra added the bug fix Change that fixes a bug label Mar 18, 2026
@jjezra jjezra marked this pull request as ready for review March 18, 2026 22:26
@jjezra jjezra requested review from MMcM and alecgrieser March 19, 2026 13:18
* a future that holds a record store state read for a controlled duration, simulating
* a slow getSnapshotRecordCount FDB read.
*/
private static class SlowCountRecordStore extends FDBRecordStore {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know how necessary is this class? Without your fix, do we hit the error somewhat reliably if we use RepeatedTest for a reasonably small number?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had hit this error every single time I've tried it without my fix.
I hadn't tried "repeat until success", though.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was more curious about how reliable the test becomes if we take it out as it would be nice not to introduce sleeps into the code, even for tests

Copy link
Copy Markdown
Contributor Author

@jjezra jjezra Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, would you like me to eliminate the sleep?
(I do not know if before the change the tests could have consistently catch the problem without any sleep)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was at least curious to know if the test could work without the sleeps. It's probably fine to leave it as is, though

jjezra added 3 commits March 24, 2026 19:02
…ring index rebuild

   Addresses two issues:
   1. recordStoreStateRef.updateAndGet lambdas were non repeatble
   2. rebuildIndexes preset futures items could havce performed index state read
         + Add rebuildIndexesWithMixedRecordCount
         + Add rebuildIndexesWithDisabledAndMixedStates
@jjezra jjezra force-pushed the rebuild_indexes_avoid_conflicts_small branch from 148a04f to 8faefd2 Compare March 24, 2026 23:03
@jjezra jjezra requested a review from alecgrieser March 24, 2026 23:03
* a future that holds a record store state read for a controlled duration, simulating
* a slow getSnapshotRecordCount FDB read.
*/
private static class SlowCountRecordStore extends FDBRecordStore {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was more curious about how reliable the test becomes if we take it out as it would be nice not to introduce sleeps into the code, even for tests

Copy link
Copy Markdown
Collaborator

@alecgrieser alecgrieser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is better, and it should fix the bug I think that was manifesting between index builds and getting the index states. I've left some additional comments on the new fix, and I think there are a few outstanding from the last review

@jjezra jjezra requested a review from alecgrieser April 8, 2026 18:16
* a future that holds a record store state read for a controlled duration, simulating
* a slow getSnapshotRecordCount FDB read.
*/
private static class SlowCountRecordStore extends FDBRecordStore {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was at least curious to know if the test could work without the sleeps. It's probably fine to leave it as is, though

@MMcM MMcM merged commit b161cfb into FoundationDB:main Apr 9, 2026
13 checks passed
@jjezra jjezra deleted the rebuild_indexes_avoid_conflicts_small branch April 9, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug fix Change that fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants