Skip to content

Change deleteStore to check StoreHeader before bumping MetaDataVersionStamp#4354

Draft
ScottDugas wants to merge 5 commits into
FoundationDB:mainfrom
ScottDugas:subissue-4335
Draft

Change deleteStore to check StoreHeader before bumping MetaDataVersionStamp#4354
ScottDugas wants to merge 5 commits into
FoundationDB:mainfrom
ScottDugas:subissue-4335

Conversation

@ScottDugas

@ScottDugas ScottDugas commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

This changes deleteStore to only bump the MetaDataVersionStamp if it is deleting a store that is cacheable.
By being more restrictive, deleting stores that aren't caching the header means that we won't force a refresh on stores that are using the store header cache. This can be pretty valuable, since you would generally use the store state cache for stores that have a lot of activity, but rarely change store state. Those are unlikely to be deleted, and would be most impacted by a spurious meta-data version-stamp bump.

In particular the catalog uses the MetaDataVersion-based store cache, and when you delete a schema (as part of a test cleanup), the old deleteStore would invalidate the metaDataVersion cache, which would cause any catalog operations (which opened the store) to conflict.

Closes #4335

…nStamp

In particular the catalog uses the MetaDataVersion-based store cache,
and when you delete a schema (as part of a test cleanup), the old
deleteStore would invalidate the metadataversion cache, which would
cause any catalog operations (which opened the store) to conflict.
By being more restrictive, deleting stores that aren't caching the
header means that we won't force a refresh on stores that are using
the store header cache.

Closes FoundationDB#4335
deleteStore reads STORE_INFO_KEY at snapshot isolation to avoid adding
a read conflict on every delete. This leaves a race with a concurrent
commit that flips the store to cacheable via setStateCacheability(true)
and bumps the meta-data version stamp: our snapshot read misses the
flip, we skip our own bump, and the delete lands. Sibling clients that
populated their caches from the flipper committed state then keep
serving reads out of a header for a store that no longer exists.

Fix: only on the branches where we decide NOT to bump (header absent,
or header parses as non-cacheable), add an explicit point read conflict
on STORE_INFO_KEY. That way:

  - the common case (delete of a store that was and stays non-cacheable)
    still contributes zero read conflicts, and
  - the racy case (concurrent flip to cacheable) is detected: the
    writer SET on STORE_INFO_KEY overlaps our added read conflict
    and we lose the commit race.

The cacheable-header branch and the invalid-header fallback continue
to bump unconditionally without a read conflict -- bumping is safe
regardless of what a concurrent writer does.

Also updates the javadoc to describe the new semantics.

Adds a regression test (concurrentSetCacheabilityAndDeleteDoesNotLoseTheBump)
that fails against the pre-fix implementation: it runs the two racing
transactions with pinned read versions, forces the writer to commit
first, and asserts that if the delete then commits the stamp must have
advanced past the writer post-commit value.

Closes FoundationDB#4335
A bunch of DRY and removing unnecessary logic.
Also have a version of the conflict test with the commits in the
other order
@ScottDugas ScottDugas added the enhancement New feature or request label Jul 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

FDBRecordStore.deleteStore — only bump metadata-version stamp when the store was cacheable

1 participant