MariaDB 10.2 and newer returns inconsistent results when query caching is enabled (query_cache_type=ON).
Steps to reproduce
1. Start a MariaDB 10.2+ database with default settings.
For example by running a docker container on port 3500:
shell> docker run --name mariadb-10.2.14 -p 3500:3306 -e MYSQL_ROOT_PASSWORD=test -e MYSQL_USER=test -e MYSQL_PASSWORD=test -e MYSQL_DATABASE=test -d mariadb:10.2.14
|
shell> mysqltest -h 127.0.0.1 --port=3500 --user=test --password=test --result-file=MDEV-16087.record test < MDEV-16087.mysqltest
|
It fails with:
--- MDEV-16087.record 2018-05-15 15:42:11.495372790 +0200
|
+++ MDEV-16087.reject 2018-05-15 15:52:24.547984967 +0200
|
@@ -18,7 +18,7 @@
|
1
|
select count(*) from table3;
|
count(*)
|
-1
|
+0
|
select sql_no_cache count(*) from table3;
|
count(*)
|
1
|
|
mysqltest: Result content mismatch
|
3. Disable query caching and re-run the mysqltest case:
shell> echo "set global query_cache_type = off;" | mysql -h 127.0.0.1 --port=3500 --user=root --password=test
|
shell> mysqltest -h 127.0.0.1 --port=3500 --user=test --password=test --result-file=MDEV-16087.record test < MDEV-16087.mysqltest
|
Mysqltest succeeds.
Environment
- Ubuntu
- MariaDB 10.2.14
- Query cache settings:
MariaDB [(none)]> show variables like '%query_cache%';
|
+------------------------------+----------+
|
| Variable_name | Value |
|
+------------------------------+----------+
|
| have_query_cache | YES |
|
| query_cache_limit | 131072 |
|
| query_cache_min_res_unit | 4096 |
|
| query_cache_size | 67108864 |
|
| query_cache_strip_comments | OFF |
|
| query_cache_type | ON |
|
| query_cache_wlock_invalidate | OFF |
|
+------------------------------+----------+
|
- relates to
-
MDEV-16251
Query caching should not be enabled by default in apt packages
-
-
Closed
- links to
-
{"report":{"fcp":1010.3000001907349,"ttfb":237.4000005722046,"pageVisibility":"visible","entityId":67215,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"78b29dcd-623f-4dcd-b622-3a013dfa0a9b","navigationType":0,"readyForUser":1102.1000003814697,"redirectCount":0,"resourceLoadedEnd":1448.9000005722046,"resourceLoadedStart":247,"resourceTiming":[{"duration":271.69999980926514,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":247,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":247,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":518.6999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":271.9000005722046,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":247.19999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":247.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":519.1000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":281.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/e9b27a47da5fb0f74a35acd57e9847fb-CDN/lu2bv2/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":247.4000005722046,"connectEnd":247.4000005722046,"connectStart":247.4000005722046,"domainLookupEnd":247.4000005722046,"domainLookupStart":247.4000005722046,"fetchStart":247.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":247.4000005722046,"responseEnd":528.9000005722046,"responseStart":528.9000005722046,"secureConnectionStart":247.4000005722046},{"duration":337.30000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/c32eb0da7ad9831253f8397e6cc26afd-CDN/lu2bv2/820016/12ta74/2380add21a9a1006587582385952de73/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true","startTime":247.60000038146973,"connectEnd":247.60000038146973,"connectStart":247.60000038146973,"domainLookupEnd":247.60000038146973,"domainLookupStart":247.60000038146973,"fetchStart":247.60000038146973,"redirectEnd":0,"redirectStart":0,"requestStart":247.60000038146973,"responseEnd":584.9000005722046,"responseStart":584.9000005722046,"secureConnectionStart":247.60000038146973},{"duration":341.0999994277954,"initiatorType":"script","name":"https://jira.mariadb.org/s/bc0bcb146314416123c992714ee00ff7-CDN/lu2bv2/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":247.9000005722046,"connectEnd":247.9000005722046,"connectStart":247.9000005722046,"domainLookupEnd":247.9000005722046,"domainLookupStart":247.9000005722046,"fetchStart":247.9000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":247.9000005722046,"responseEnd":589,"responseStart":589,"secureConnectionStart":247.9000005722046},{"duration":341.4000005722046,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":248,"connectEnd":248,"connectStart":248,"domainLookupEnd":248,"domainLookupStart":248,"fetchStart":248,"redirectEnd":0,"redirectStart":0,"requestStart":248,"responseEnd":589.4000005722046,"responseStart":589.4000005722046,"secureConnectionStart":248},{"duration":341.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":248.19999980926514,"connectEnd":248.19999980926514,"connectStart":248.19999980926514,"domainLookupEnd":248.19999980926514,"domainLookupStart":248.19999980926514,"fetchStart":248.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":248.19999980926514,"responseEnd":589.6999998092651,"responseStart":589.6999998092651,"secureConnectionStart":248.19999980926514},{"duration":423.69999980926514,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bv2/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":248.4000005722046,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":248.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":672.1000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":341.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":248.5,"connectEnd":248.5,"connectStart":248.5,"domainLookupEnd":248.5,"domainLookupStart":248.5,"fetchStart":248.5,"redirectEnd":0,"redirectStart":0,"requestStart":248.5,"responseEnd":590.1999998092651,"responseStart":590.1999998092651,"secureConnectionStart":248.5},{"duration":423.6000003814697,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bv2/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":248.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":248.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":672.3000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":341.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/s/719848dd97ebe0663199f49a3936487a-CDN/lu2bv2/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":249,"connectEnd":249,"connectStart":249,"domainLookupEnd":249,"domainLookupStart":249,"fetchStart":249,"redirectEnd":0,"redirectStart":0,"requestStart":249,"responseEnd":590.6999998092651,"responseStart":590.6999998092651,"secureConnectionStart":249},{"duration":1179.8999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":254.4000005722046,"connectEnd":254.4000005722046,"connectStart":254.4000005722046,"domainLookupEnd":254.4000005722046,"domainLookupStart":254.4000005722046,"fetchStart":254.4000005722046,"redirectEnd":0,"redirectStart":0,"requestStart":254.4000005722046,"responseEnd":1434.3000001907349,"responseStart":1434.3000001907349,"secureConnectionStart":254.4000005722046},{"duration":1165,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":269.6000003814697,"connectEnd":269.6000003814697,"connectStart":269.6000003814697,"domainLookupEnd":269.6000003814697,"domainLookupStart":269.6000003814697,"fetchStart":269.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":269.6000003814697,"responseEnd":1434.6000003814697,"responseStart":1434.6000003814697,"secureConnectionStart":269.6000003814697},{"duration":105.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":683.6999998092651,"connectEnd":683.6999998092651,"connectStart":683.6999998092651,"domainLookupEnd":683.6999998092651,"domainLookupStart":683.6999998092651,"fetchStart":683.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":683.6999998092651,"responseEnd":789.1999998092651,"responseStart":789.1999998092651,"secureConnectionStart":683.6999998092651},{"duration":502.20000076293945,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bv2/820016/12ta74/e65b778d185daf5aee24936755b43da6/_/download/contextbatch/js/browser-metrics-plugin.contrib,-_super,-project.issue.navigator,-jira.view.issue,-atl.general/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":946.6999998092651,"connectEnd":946.6999998092651,"connectStart":946.6999998092651,"domainLookupEnd":946.6999998092651,"domainLookupStart":946.6999998092651,"fetchStart":946.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":946.6999998092651,"responseEnd":1448.9000005722046,"responseStart":1448.9000005722046,"secureConnectionStart":946.6999998092651},{"duration":489.19999980926514,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1003.6000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1003.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1492.8000001907349,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":24,"responseStart":238,"responseEnd":269,"domLoading":245,"domInteractive":1496,"domContentLoadedEventStart":1496,"domContentLoadedEventEnd":1562,"domComplete":2219,"loadEventStart":2219,"loadEventEnd":2219,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1440.6999998092651},{"name":"bigPipe.sidebar-id.end","time":1441.5},{"name":"bigPipe.activity-panel-pipe-id.start","time":1441.6000003814697},{"name":"bigPipe.activity-panel-pipe-id.end","time":1450.3000001907349},{"name":"activityTabFullyLoaded","time":1587.8000001907349}],"measures":[],"correlationId":"ee189b56f45340","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":139,"dbReadsTimeInMs":11,"dbConnsTimeInMs":18,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Easy to reproduce with 10.3.6, for example:
openxs@ao756:~/dbs/maria10.3$ bin/mysql --host=127.0.0.1 --port=3308 -uroot -e"select @@query_cache_type, version()"
+--------------------+----------------+
| @@query_cache_type | version() |
+--------------------+----------------+
| OFF | 10.3.6-MariaDB |
+--------------------+----------------+
openxs@ao756:~/dbs/maria10.3$ bin/mysqltest --host=127.0.0.1 --port=3308 -uroot test < /tmp/MDEV-16087.mysqltest
connect conn1, 127.0.0.1, root, , test, 3308;
connect conn2, 127.0.0.1, root, , test, 3308;
connect conn3, 127.0.0.1, root, , test, 3308;
connection conn1;
create table table1 (id bigint(20) auto_increment, primary key (id)) ENGINE=InnoDB;
create table table2 (id bigint(20) auto_increment, primary key (id)) ENGINE=InnoDB;
create table table3 (id bigint(20) auto_increment, primary key (id)) ENGINE=InnoDB;
connection conn2;
set autocommit=0;
select * from table2;
id
connection conn1;
insert into table3 () values ();
connection conn2;
insert into table1 () values ();
select count(*) from table3;
count(*)
0
connection conn3;
set autocommit=0;
select count(*) from table3;
count(*)
1
select count(*) from table3;
count(*)
1
select sql_no_cache count(*) from table3;
count(*)
1
rollback;
connection conn2;
rollback;
connection conn1;
drop table table1;
drop table table2;
drop table table3;
ok
openxs@ao756:~/dbs/maria10.3$ bin/mysql --host=127.0.0.1 --port=3308 -uroot -e"set global query_cache_type=on;"
openxs@ao756:~/dbs/maria10.3$ bin/mysql --host=127.0.0.1 --port=3308 -uroot -e"select @@query_cache_type, version()"
+--------------------+----------------+
| @@query_cache_type | version() |
+--------------------+----------------+
| ON | 10.3.6-MariaDB |
+--------------------+----------------+
openxs@ao756:~/dbs/maria10.3$ bin/mysqltest --host=127.0.0.1 --port=3308 -uroot test < /tmp/MDEV-16087.mysqltest
connect conn1, 127.0.0.1, root, , test, 3308;
connect conn2, 127.0.0.1, root, , test, 3308;
connect conn3, 127.0.0.1, root, , test, 3308;
connection conn1;
create table table1 (id bigint(20) auto_increment, primary key (id)) ENGINE=InnoDB;
create table table2 (id bigint(20) auto_increment, primary key (id)) ENGINE=InnoDB;
create table table3 (id bigint(20) auto_increment, primary key (id)) ENGINE=InnoDB;
connection conn2;
set autocommit=0;
select * from table2;
id
connection conn1;
insert into table3 () values ();
connection conn2;
insert into table1 () values ();
select count(*) from table3;
count(*)
0
connection conn3;
set autocommit=0;
select count(*) from table3;
count(*)
1
select count(*) from table3;
count(*)
0
select sql_no_cache count(*) from table3;
count(*)
1
rollback;
connection conn2;
rollback;
connection conn1;
drop table table1;
drop table table2;
drop table table3;
ok
openxs@ao756:~/dbs/maria10.3$
I can not reproduce with 10.2.12, fore example. so looks like a recent enough regression.