Skip to content

MDEV-39828 Stabilize query_cache_executable_comments counter checks#5228

Open
tonychen2001 wants to merge 1 commit into
MariaDB:13.0from
tonychen2001:MDEV-39828
Open

MDEV-39828 Stabilize query_cache_executable_comments counter checks#5228
tonychen2001 wants to merge 1 commit into
MariaDB:13.0from
tonychen2001:MDEV-39828

Conversation

@tonychen2001

@tonychen2001 tonychen2001 commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Description

The test main.query_cache_executable_comments is unreliable and fails on
the builders (MDEV-39828).
It asserts the absolute values of the global status counters Qcache_inserts
and Qcache_hits, but resets them per case with FLUSH STATUS.

FLUSH STATUS does not reset the global counters query_cache.hits /
query_cache.inserts. As a result the recorded values were
actually cumulative from server start, and the test only passed against a
pristine mysqld. When the server instance is reused with prior query-cache
activity (server reuse, --repeat), the leftover counter values are
added to every assertion, producing a constant offset and a "Result length
mismatch".

Fix: Replace the FLUSH STATUS calls with FLUSH GLOBAL STATUS which actually resets the Qcache counters. This is the idiomatic pattern
already used by every other query-cache test (query_cache.test,
query_cache_with_views.test, subselect_cache.test, the query_cache*.inc
includes, etc.).

How can this PR be tested?

Execute the main.query_cache_executable_comments test in mysql-test-run.

Before this change:

The test passes in isolation but fails whenever the server is reused with
prior query-cache activity. This is reproducible with --repeat=2 (the
second iteration reuses the same mysqld instance):

@@ -30,10 +30,10 @@
 SELECT /*!50300 c1 */ FROM t1;
 SHOW STATUS LIKE 'Qcache_inserts';
 Variable_name	Value
-Qcache_inserts	1
+Qcache_inserts	7
 SHOW STATUS LIKE 'Qcache_hits';
 Variable_name	Value
-Qcache_hits	1
+Qcache_hits	3
 SHOW STATUS LIKE 'Qcache_queries_in_cache';
 Variable_name	Value
 Qcache_queries_in_cache	1
...
Result length mismatch

After this change:

Running the test with --repeat=2 in
mysql-test-run shows no failures, with the server reused throughout:

==============================================================================

TEST                                      RESULT   TIME (ms) or COMMENT
--------------------------------------------------------------------------

worker[01] Using MTR_BUILD_THREAD 300, with reserved ports 19000..19029
worker[01] mysql-test-run: WARNING: running this script as _root_ will cause some tests to be skipped
main.query_cache_executable_comments     [ pass ]    108
main.query_cache_executable_comments     [ 2 pass ]     28
--------------------------------------------------------------------------
The servers were restarted 0 times

Completed: All 2 tests were successful.

Basing the PR against the correct MariaDB version

  • This is a bug fix, and the PR is based against the branch 13.0.

Copyright

All new code of the whole pull request, including one or several files that are either new files or modified ones, are contributed under the BSD-new license. I am contributing on behalf of my employer Amazon Web Services, Inc.

The test asserted absolute Qcache_inserts/Qcache_hits values but reset them
with FLUSH STATUS which  does not clear those global counters.
The expected values were therefore cumulative from a pristine server, so the
test drifted by a constant offset whenever the mysqld instance was reused with
prior query cache activity (fulltest server reuse, --repeat).

E.g:

```
./build/mysql-test/mysql-test-run.pl --parallel=1 --repeat=2 main.query_cache_executable_comments
```

Use FLUSH GLOBAL STATUS instead, matching every other query cache test
(query_cache.test, query_cache_with_views.test, subselect_cache.test).
This zeroes the SHOW Qcache counters, making each case independent
of server history.

All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license. I am contributing on behalf of my employer Amazon Web
Services, Inc.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request updates the query cache executable comments test suite by replacing FLUSH STATUS with FLUSH GLOBAL STATUS in both the test and result files. This change also updates the expected status variable values, such as Qcache_inserts and Qcache_hits, in the test results. I have no feedback to provide as there are no review comments.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant