2024-05-03 17:37:48 5 [Note] 'CHANGE MASTER TO executed'. Previous state master_host='', master_port='3306', master_log_file='', master_log_pos='4'. New state master_host='a', master_port='1', master_log_file='', master_log_pos='4'.
2024-05-03 17:37:48 5 [Note] Previous Using_Gtid=Slave_Pos. New Using_Gtid=Slave_Pos
CHANGE MASTER TO master_host='a',master_port=1,master_user='a',master_demote_to_slave=1;
SELECT SLEEP(5);
Roel Van de Paar
added a comment - MTR Testcase:
--source include/have_binlog_format_mixed.inc
INSTALL PLUGIN Spider SONAME 'ha_spider.so' ;
CREATE TABLE t (c TEXT) ENGINE=Spider;
XA BEGIN 'a' ;
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
UPDATE t SET c=+1;
CHANGE MASTER TO master_host= 'a' ,master_port=1,master_user= 'a' ,master_demote_to_slave=1;
SELECT SLEEP(5);
Same kind of issue as MDEV-28105 and MDEV-27186, but instead of info(), it is rpl_slave_state::truncate_state_table() ignores error from ha_commit_trans().
Here's a demo of what I mean. Does it point towards a sensible fix bnestere?
MDEV-34064 [demo] return error from ha_commit_trans() in rpl_slave_state::truncate_state_table(THD *thd)
just a demo - a similar fix to MDEV-28105 and MDEV-27186.
Whether the 12607 error makes sense is perhaps a different matter:
mysqltest: At line 7: query 'CHANGE MASTER TO master_host='a',master_port=1,master_user='a',master_demote_to_slave=1' failed: <Unknown> (12607): This xid is not exist
new file storage/spider/mysql-test/spider/bugfix/t/mdev_34064.test
@@ -0,0 +1,8 @@
+--source include/have_binlog_format_mixed.inc
+INSTALL SONAME 'ha_spider.so';
+CREATE TABLE t (c TEXT) ENGINE=Spider;
+XA BEGIN 'a';
+--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
+UPDATE t SET c=+1;
+--error 12607
+CHANGE MASTER TO master_host='a',master_port=1,master_user='a',master_demote_to_slave=1;
Yuchen Pei
added a comment - - edited Same kind of issue as MDEV-28105 and MDEV-27186 , but instead of info(), it is rpl_slave_state::truncate_state_table() ignores error from ha_commit_trans().
Here's a demo of what I mean. Does it point towards a sensible fix bnestere ?
bb-10.11-mdev-34064-ycp-demo dfcb8b380a186cd47efec1d31b1db7c8e4fe2943
MDEV-34064 [demo] return error from ha_commit_trans() in rpl_slave_state::truncate_state_table(THD *thd)
just a demo - a similar fix to MDEV-28105 and MDEV-27186.
Whether the 12607 error makes sense is perhaps a different matter:
mysqltest: At line 7: query 'CHANGE MASTER TO master_host='a',master_port=1,master_user='a',master_demote_to_slave=1' failed: <Unknown> (12607): This xid is not exist
2 files changed, 13 insertions(+), 1 deletion(-)
sql/rpl_gtid.cc | 6 +++++-
storage/spider/mysql-test/spider/bugfix/t/mdev_34064.test | 8 ++++++++
modified sql/rpl_gtid.cc
@@ -461,7 +461,11 @@ rpl_slave_state::truncate_state_table(THD *thd)
{
ha_commit_trans(thd, FALSE);
close_thread_tables(thd);
- ha_commit_trans(thd, TRUE);
+ if ((err= ha_commit_trans(thd, TRUE)))
+ {
+ thd->release_transactional_locks();
+ return err;
+ }
}
thd->release_transactional_locks();
}
new file storage/spider/mysql-test/spider/bugfix/t/mdev_34064.test
@@ -0,0 +1,8 @@
+--source include/have_binlog_format_mixed.inc
+INSTALL SONAME 'ha_spider.so';
+CREATE TABLE t (c TEXT) ENGINE=Spider;
+XA BEGIN 'a';
+--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE
+UPDATE t SET c=+1;
+--error 12607
+CHANGE MASTER TO master_host='a',master_port=1,master_user='a',master_demote_to_slave=1;
I think the bug runs deeper than that (and not specific to spider), it seems CHANGE MASTER (CM) with master_demote_to_slave=1 will commit any ongoing transaction on the current thread.. If you make the DML within the XA transaction valid, you can see it commit in the binary log as soon as CM executes as a normal transaction. Then if you remove the master_demote_to_slave=1 option, it won't commit. I'll reassign to myself, because it isn't spider.
Though the general idea of your fix seems quite good to have, though I don't think you need the if statement, you can just assign the commit (and rollback) to err as the function will then naturally release its trans locks and return.
Brandon Nesterenko
added a comment - Hi ycp ,
I think the bug runs deeper than that (and not specific to spider), it seems CHANGE MASTER (CM) with master_demote_to_slave=1 will commit any ongoing transaction on the current thread.. If you make the DML within the XA transaction valid, you can see it commit in the binary log as soon as CM executes as a normal transaction. Then if you remove the master_demote_to_slave=1 option, it won't commit. I'll reassign to myself, because it isn't spider.
Though the general idea of your fix seems quite good to have, though I don't think you need the if statement, you can just assign the commit (and rollback) to err as the function will then naturally release its trans locks and return.
People
Brandon Nesterenko
Roel Van de Paar
Votes:
0Vote for this issue
Watchers:
5Start watching this issue
Dates
Created:
Updated:
Git Integration
Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.
{"report":{"fcp":2182,"ttfb":300.5,"pageVisibility":"visible","entityId":129006,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":32,"apdex":0.5,"journeyId":"986bd3e1-b755-4b45-ad43-d3a80bedc5ed","navigationType":0,"readyForUser":2285.7999997138977,"redirectCount":0,"resourceLoadedEnd":2387.5,"resourceLoadedStart":310.09999990463257,"resourceTiming":[{"duration":718.5999999046326,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":310.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":310.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1028.6999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":718.5999999046326,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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":310.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":310.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1029.0999999046326,"responseStart":0,"secureConnectionStart":0},{"duration":727.2999997138977,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":311,"connectEnd":311,"connectStart":311,"domainLookupEnd":311,"domainLookupStart":311,"fetchStart":311,"redirectEnd":0,"redirectStart":0,"requestStart":311,"responseEnd":1038.2999997138977,"responseStart":1038.2999997138977,"secureConnectionStart":311},{"duration":1171.7999997138977,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/2bf333562ca6724060a9d5f1535471f6/_/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":311.59999990463257,"connectEnd":311.59999990463257,"connectStart":311.59999990463257,"domainLookupEnd":311.59999990463257,"domainLookupStart":311.59999990463257,"fetchStart":311.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":311.59999990463257,"responseEnd":1483.3999996185303,"responseStart":1483.3999996185303,"secureConnectionStart":311.59999990463257},{"duration":1175.5999999046326,"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":311.7999997138977,"connectEnd":311.7999997138977,"connectStart":311.7999997138977,"domainLookupEnd":311.7999997138977,"domainLookupStart":311.7999997138977,"fetchStart":311.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":311.7999997138977,"responseEnd":1487.3999996185303,"responseStart":1487.3999996185303,"secureConnectionStart":311.7999997138977},{"duration":1176.2999997138977,"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":312,"connectEnd":312,"connectStart":312,"domainLookupEnd":312,"domainLookupStart":312,"fetchStart":312,"redirectEnd":0,"redirectStart":0,"requestStart":312,"responseEnd":1488.2999997138977,"responseStart":1488.2999997138977,"secureConnectionStart":312},{"duration":1177,"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":312.2999997138977,"connectEnd":312.2999997138977,"connectStart":312.2999997138977,"domainLookupEnd":312.2999997138977,"domainLookupStart":312.2999997138977,"fetchStart":312.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":312.2999997138977,"responseEnd":1489.2999997138977,"responseStart":1489.2999997138977,"secureConnectionStart":312.2999997138977},{"duration":1178.3000001907349,"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":312.3999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":312.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1490.6999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":1178,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":312.59999990463257,"connectEnd":312.59999990463257,"connectStart":312.59999990463257,"domainLookupEnd":312.59999990463257,"domainLookupStart":312.59999990463257,"fetchStart":312.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":312.59999990463257,"responseEnd":1490.5999999046326,"responseStart":1490.5999999046326,"secureConnectionStart":312.59999990463257},{"duration":1179.2000002861023,"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":313.2999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":313.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1492.5,"responseStart":0,"secureConnectionStart":0},{"duration":1179.8999996185303,"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":313.5,"connectEnd":313.5,"connectStart":313.5,"domainLookupEnd":313.5,"domainLookupStart":313.5,"fetchStart":313.5,"redirectEnd":0,"redirectStart":0,"requestStart":313.5,"responseEnd":1493.3999996185303,"responseStart":1493.3999996185303,"secureConnectionStart":313.5},{"duration":1952.8000001907349,"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":320.7999997138977,"connectEnd":320.7999997138977,"connectStart":320.7999997138977,"domainLookupEnd":320.7999997138977,"domainLookupStart":320.7999997138977,"fetchStart":320.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":320.7999997138977,"responseEnd":2273.5999999046326,"responseStart":2273.5999999046326,"secureConnectionStart":320.7999997138977},{"duration":1950,"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":324.3999996185303,"connectEnd":324.3999996185303,"connectStart":324.3999996185303,"domainLookupEnd":324.3999996185303,"domainLookupStart":324.3999996185303,"fetchStart":324.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":324.3999996185303,"responseEnd":2274.3999996185303,"responseStart":2274.3999996185303,"secureConnectionStart":324.3999996185303},{"duration":459.5,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":1203.0999999046326,"connectEnd":1203.0999999046326,"connectStart":1203.0999999046326,"domainLookupEnd":1203.0999999046326,"domainLookupStart":1203.0999999046326,"fetchStart":1203.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":1203.0999999046326,"responseEnd":1662.5999999046326,"responseStart":1662.5999999046326,"secureConnectionStart":1203.0999999046326},{"duration":549.8000001907349,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/css/jira.project.sidebar,-_super,-project.issue.navigator,-jira.general,-jira.browse.project,-jira.view.issue,-jira.global,-atl.general,-com.atlassian.jira.projects.sidebar.init/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true","startTime":1837.6999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1837.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":2387.5,"responseStart":0,"secureConnectionStart":0}],"fetchStart":1,"domainLookupStart":1,"domainLookupEnd":1,"connectStart":1,"connectEnd":1,"requestStart":88,"responseStart":301,"responseEnd":325,"domLoading":305,"domInteractive":2471,"domContentLoadedEventStart":2471,"domContentLoadedEventEnd":2655,"domComplete":3528,"loadEventStart":3528,"loadEventEnd":3528,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":2402.199999809265},{"name":"bigPipe.sidebar-id.end","time":2403},{"name":"bigPipe.activity-panel-pipe-id.start","time":2403.199999809265},{"name":"bigPipe.activity-panel-pipe-id.end","time":2405.8999996185303},{"name":"activityTabFullyLoaded","time":2683.0999999046326}],"measures":[],"correlationId":"4845f9f4e6991a","effectiveType":"4g","downlink":9.1,"rtt":0,"serverDuration":120,"dbReadsTimeInMs":20,"dbConnsTimeInMs":29,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
MTR Testcase:
--source include/have_binlog_format_mixed.inc
--error ER_CONNECT_TO_FOREIGN_DATA_SOURCE