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

Invalidate query compilation cache entries with outdated VIEWs (#1960) #2479

Merged
merged 1 commit into from
Mar 6, 2024

Conversation

jepett0
Copy link
Collaborator

@jepett0 jepett0 commented Mar 6, 2024

KIKIMR-21002

In this PR we add the following algorithm for invalidating cache entries for outdated VIEWs:

  1. Store path ids and schema versions of the views that were used in the query in the cache entries, so they can be accessed later.
  2. Whenever we retrieve a compilation result from cache, send a request for SchemeCache to check if the schema version of the views used in this query (if any) has not changed since we compiled this query.
  3. Send a recompilation request if any view is outdated.

There are two important things to note about this solution:

  • We make a SchemeCache request for each repeated query and there is a lot of these in an OLTP-focused database like YDB. However, we have already been sending these request for preliminary (this is not the last check of schema version mismatch (at least for tables)) cache invalidation for tables, so views should not incur an additional performance impact here.
  • This solution does not guarantee strong consistency for queries using views, because query cache invalidation will not happen instantly after the view definition is updated. The node should get an update from the SchemeCache, which takes some time.

@jepett0 jepett0 requested review from ijon and spuchin March 6, 2024 09:08
Copy link

github-actions bot commented Mar 6, 2024

2024-03-06 09:11:33 UTC Pre-commit check for 2457b23 has started.
2024-03-06 09:11:36 UTC Build linux-x86_64-relwithdebinfo is running...
2024-03-06 09:34:55 UTC Check cancelled

Copy link

github-actions bot commented Mar 6, 2024

2024-03-06 09:11:41 UTC Pre-commit check for 2457b23 has started.
2024-03-06 09:11:44 UTC Build linux-x86_64-release-asan is running...
2024-03-06 09:34:55 UTC Check cancelled

…latform#1960)

KIKIMR-21002

In this PR we add the following algorithm for invalidating cache entries for outdated VIEWs:

1. Store path ids and schema versions of the views that were used in the query in the cache entries, so they can be accessed later.
2. Whenever we retrieve a compilation result from cache, send a request for SchemeCache to check if the schema version of the views used in this query (if any) has not changed since we compiled this query.
3. Send a recompilation request if any view is outdated.

There are two important things to note about this solution:

- We make a SchemeCache request for each repeated query and there is a lot of these in an OLTP-focused database like YDB. However, we have already been sending these request for preliminary (this is not the last check of schema version mismatch (at least for tables)) cache invalidation for tables, so views should not incur an additional performance impact here.
- This solution does not guarantee strong consistency for queries using views, because query cache invalidation will not happen instantly after the view definition is updated. The node should get an update from the SchemeCache, which takes some time.
Copy link

github-actions bot commented Mar 6, 2024

2024-03-06 09:36:00 UTC Pre-commit check for e0ea543 has started.
2024-03-06 09:36:02 UTC Build linux-x86_64-relwithdebinfo is running...
🟢 2024-03-06 09:51:50 UTC Build successful.
2024-03-06 09:52:02 UTC Tests are running...
🔴 2024-03-06 11:15:33 UTC Some tests failed, follow the links below.

Test history

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
60268 50867 0 1 9340 60

Copy link

github-actions bot commented Mar 6, 2024

2024-03-06 09:38:07 UTC Pre-commit check for e0ea543 has started.
2024-03-06 09:38:10 UTC Build linux-x86_64-release-asan is running...
🟢 2024-03-06 09:55:21 UTC Build successful.
2024-03-06 09:55:33 UTC Tests are running...
🔴 2024-03-06 11:35:30 UTC Some tests failed, follow the links below.

Test history

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
16056 15918 0 30 67 41

@jepett0 jepett0 marked this pull request as ready for review March 6, 2024 12:28
@jepett0 jepett0 requested a review from a team as a code owner March 6, 2024 12:28
@jepett0 jepett0 merged commit 0378eff into ydb-platform:stable-24-1 Mar 6, 2024
2 of 4 checks passed
@mregrock mregrock mentioned this pull request May 15, 2024
This was referenced Jun 7, 2024
@CyberROFL CyberROFL mentioned this pull request Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants