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":944.7999997138977,"ttfb":354.69999980926514,"pageVisibility":"visible","entityId":67215,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"0635f00e-4f8e-4d07-bd3d-f82cae4f8735","navigationType":0,"readyForUser":1051.5999999046326,"redirectCount":0,"resourceLoadedEnd":1031.2999997138977,"resourceLoadedStart":360.69999980926514,"resourceTiming":[{"duration":39.80000019073486,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":360.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":360.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":400.5,"responseStart":0,"secureConnectionStart":0},{"duration":40.59999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":361,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":361,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":401.59999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":95.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":361.19999980926514,"connectEnd":361.19999980926514,"connectStart":361.19999980926514,"domainLookupEnd":361.19999980926514,"domainLookupStart":361.19999980926514,"fetchStart":361.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":361.19999980926514,"responseEnd":457,"responseStart":457,"secureConnectionStart":361.19999980926514},{"duration":220.10000038146973,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/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&whisper-enabled=true","startTime":361.3999996185303,"connectEnd":361.3999996185303,"connectStart":361.3999996185303,"domainLookupEnd":361.3999996185303,"domainLookupStart":361.3999996185303,"fetchStart":361.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":361.3999996185303,"responseEnd":581.5,"responseStart":581.5,"secureConnectionStart":361.3999996185303},{"duration":224,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":361.5,"connectEnd":361.5,"connectStart":361.5,"domainLookupEnd":361.5,"domainLookupStart":361.5,"fetchStart":361.5,"redirectEnd":0,"redirectStart":0,"requestStart":361.5,"responseEnd":585.5,"responseStart":585.3999996185303,"secureConnectionStart":361.5},{"duration":224.2000002861023,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":361.7999997138977,"connectEnd":361.7999997138977,"connectStart":361.7999997138977,"domainLookupEnd":361.7999997138977,"domainLookupStart":361.7999997138977,"fetchStart":361.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":361.7999997138977,"responseEnd":586,"responseStart":586,"secureConnectionStart":361.7999997138977},{"duration":224.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":361.8999996185303,"connectEnd":361.8999996185303,"connectStart":361.8999996185303,"domainLookupEnd":361.8999996185303,"domainLookupStart":361.8999996185303,"fetchStart":361.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":361.8999996185303,"responseEnd":586.3999996185303,"responseStart":586.3999996185303,"secureConnectionStart":361.8999996185303},{"duration":246.59999990463257,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":362.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":362.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":608.6999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":224.5,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":362.2999997138977,"connectEnd":362.2999997138977,"connectStart":362.2999997138977,"domainLookupEnd":362.2999997138977,"domainLookupStart":362.2999997138977,"fetchStart":362.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":362.2999997138977,"responseEnd":586.7999997138977,"responseStart":586.7999997138977,"secureConnectionStart":362.2999997138977},{"duration":246.2999997138977,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/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":362.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":362.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":608.7999997138977,"responseStart":0,"secureConnectionStart":0},{"duration":224.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/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":363.2999997138977,"connectEnd":363.2999997138977,"connectStart":363.2999997138977,"domainLookupEnd":363.2999997138977,"domainLookupStart":363.2999997138977,"fetchStart":363.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":363.2999997138977,"responseEnd":587.3999996185303,"responseStart":587.3999996185303,"secureConnectionStart":363.2999997138977},{"duration":665.5999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":364.5,"connectEnd":364.5,"connectStart":364.5,"domainLookupEnd":364.5,"domainLookupStart":364.5,"fetchStart":364.5,"redirectEnd":0,"redirectStart":0,"requestStart":364.5,"responseEnd":1030.0999999046326,"responseStart":1030.0999999046326,"secureConnectionStart":364.5},{"duration":661.2999997138977,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":370,"connectEnd":370,"connectStart":370,"domainLookupEnd":370,"domainLookupStart":370,"fetchStart":370,"redirectEnd":0,"redirectStart":0,"requestStart":370,"responseEnd":1031.2999997138977,"responseStart":1031.2999997138977,"secureConnectionStart":370},{"duration":316.09999990463257,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":622,"connectEnd":622,"connectStart":622,"domainLookupEnd":622,"domainLookupStart":622,"fetchStart":622,"redirectEnd":0,"redirectStart":0,"requestStart":622,"responseEnd":938.0999999046326,"responseStart":938.0999999046326,"secureConnectionStart":622},{"duration":329.5,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":937.2999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":937.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1266.7999997138977,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":178,"responseStart":354,"responseEnd":360,"domLoading":358,"domInteractive":1208,"domContentLoadedEventStart":1208,"domContentLoadedEventEnd":1266,"domComplete":1653,"loadEventStart":1653,"loadEventEnd":1654,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1179.5999999046326},{"name":"bigPipe.sidebar-id.end","time":1180.5},{"name":"bigPipe.activity-panel-pipe-id.start","time":1180.5},{"name":"bigPipe.activity-panel-pipe-id.end","time":1183.7999997138977},{"name":"activityTabFullyLoaded","time":1285.1999998092651}],"measures":[],"correlationId":"839583d31247d0","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":106,"dbReadsTimeInMs":10,"dbConnsTimeInMs":18,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
-- source include/have_innodb.inc
-- source include/have_query_cache.inc
-- source include/not_embedded.inc
set GLOBAL query_cache_type=ON;
set LOCAL query_cache_type=ON;
connect (conn1,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
connect (conn2,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
connect (conn3,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
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;
connection conn1;
insert into table3 () values ();
connection conn2;
insert into table1 () values ();
select count(*) from table3;
connection conn3;
set autocommit=0;
select count(*) from table3;
select count(*) from table3;
select sql_no_cache count(*) from table3;
rollback;
connection conn2;
rollback;
connection conn1;
drop table table1;
drop table table2;
drop table table3;
set GLOBAL query_cache_type=default;