Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes regression in Schema Watch led schema caching #1684

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

vroldanbet
Copy link
Contributor

@vroldanbet vroldanbet commented Dec 13, 2023

Initialization of schema watch happens via the UnwrappableDatastore interface. Given the various proxies built around the datastore.Datastore interface, we came up with the notion of UnwrappableDatastore to be able to extract a particular type from the proxy chain.

The way this is correctly done is by unwrapping in a loop until the type is found. This was unfortunately not done in the Schema Watch initialization logic, which assumed the position of the actual underlying datastore at a specific level.

With the introduction of the datastore deduplication proxy in #1610, the proxy chain changed, and the assumed order became incorrect, making the initialization logic unable to find an instance of the SchemaWatchableDatastore, even though it was there. As a consequence, the logic fell back to JIT caching strategy.

This means schema watch-led caching is broken since the 1.27.0 release, but only for CRDB users: The Spanner datastore is not subject to this bug because the CRDB datastore has one extra proxy layer and the code as it was initially was able to check for the target interface in the immediate level and the next unwrapped level.

This replaces every bespoke piece of code handling the unwrapping logic with a new function that does this correctly and more conveniently, sparing duplicate code and being more concise.

@vroldanbet vroldanbet requested a review from a team December 13, 2023 09:55
@github-actions github-actions bot added area/CLI Affects the command line area/datastore Affects the storage system area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) labels Dec 13, 2023
@vroldanbet vroldanbet self-assigned this Dec 13, 2023
Initialization of schema watch happens via the UnwrappableDatastore
interface. Given the various proxies built around the datastore.Datastore
interface, we came up with the notion of UnwrappableDatastore to be able
to extract a particular type from the proxy chain.

The way this is correctly done is by unwrapping in a loop until the type
is found. This was unfortunately not done in the Schema Watch
initialization logic, which assumed the position of the actual
underlying datastore at a specific level.

With recent changes in the datastore proxy chain, the assumed order
became incorrect, and the initialization logic was unable to
find an instance of the SchemaWatchableDatastore, even though
it was there.

As a consequence the logic fell back to JIT caching strategy.

This replaces every bespoke piece of code handling the unwrapping
logic with a new function that does this correctly and more conveniently,
sparing duplicate code and being more concise.
@vroldanbet vroldanbet force-pushed the regression-in-schema-watch-configuration branch from 1ed7791 to 8dca5cd Compare December 13, 2023 10:34
Copy link
Member

@josephschorr josephschorr left a comment

Choose a reason for hiding this comment

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

LGTM

@vroldanbet vroldanbet added this pull request to the merge queue Dec 13, 2023
Merged via the queue into main with commit fe6aebc Dec 13, 2023
20 checks passed
@vroldanbet vroldanbet deleted the regression-in-schema-watch-configuration branch December 13, 2023 17:37
@github-actions github-actions bot locked and limited conversation to collaborators Dec 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/CLI Affects the command line area/datastore Affects the storage system area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants