-
Notifications
You must be signed in to change notification settings - Fork 7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
QueryCache: Fix odd bugs with user quota
- SYSTEM DROP QUERY CACHE did not clear the user policy statistics, this made the cache block all inserts afterwards - Fixes two other oddities in the approval logic
- Loading branch information
Showing
4 changed files
with
68 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
tests/queries/0_stateless/02494_query_cache_user_quotas_after_drop.reference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
a | ||
b | ||
1 | ||
c | ||
d | ||
3 | ||
-- | ||
a | ||
b | ||
1 | ||
c | ||
d | ||
3 |
41 changes: 41 additions & 0 deletions
41
tests/queries/0_stateless/02494_query_cache_user_quotas_after_drop.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
-- Tags: no-parallel | ||
-- Tag no-parallel: Messes with internal cache | ||
|
||
-- Tests per-user quotas of the query cache. Settings 'query_cache_max_size_in_bytes' and 'query_cache_max_entries' are actually supposed to | ||
-- be used in a settings profile, together with a readonly constraint. For simplicity, test both settings stand-alone in a stateless test | ||
-- instead of an integration test - the relevant logic will still be covered by that. | ||
|
||
SYSTEM DROP QUERY CACHE; | ||
|
||
-- Run SELECT with quota that current user may write only 1 entry in the query cache | ||
SET query_cache_max_entries = 1; | ||
SELECT 'a' SETTINGS use_query_cache = true; | ||
SELECT 'b' SETTINGS use_query_cache = true; | ||
SELECT count(*) FROM system.query_cache; -- expect 1 entry | ||
|
||
-- Run SELECTs again but w/o quota | ||
SET query_cache_max_entries = DEFAULT; | ||
SELECT 'c' SETTINGS use_query_cache = true; | ||
SELECT 'd' SETTINGS use_query_cache = true; | ||
SELECT count(*) FROM system.query_cache; -- expect 3 entries | ||
|
||
SYSTEM DROP QUERY CACHE; | ||
|
||
-- Run the same as above after a DROP QUERY CACHE. | ||
SELECT '--'; | ||
|
||
SET query_cache_max_entries = 1; | ||
SELECT 'a' SETTINGS use_query_cache = true; | ||
SELECT 'b' SETTINGS use_query_cache = true; | ||
SELECT count(*) FROM system.query_cache; -- expect 1 entry | ||
|
||
-- Run SELECTs again but w/o quota | ||
SET query_cache_max_entries = DEFAULT; | ||
SELECT 'c' SETTINGS use_query_cache = true; | ||
SELECT 'd' SETTINGS use_query_cache = true; | ||
SELECT count(*) FROM system.query_cache; -- expect 3 entries | ||
|
||
SYSTEM DROP QUERY CACHE; | ||
|
||
-- SELECT '---'; | ||
|