Type:
Bug
Priority:
Major
Resolution:
Fixed
Affects Version/s:
N/A
The test case is non-deterministic and for reproducing purposes only, not suitable for the regression suite.
--source include/master-slave.inc
CREATE TABLE t1 (a INT );
CREATE TABLE t2 (b INT );
--let $run= 100
--disable_abort_on_error
while ($run)
{
--send
CREATE TRIGGER tr AFTER INSERT ON t1 FOR EACH ROW SET @b = 1;
--connection master1
CREATE TRIGGER tr AFTER INSERT ON t2 FOR EACH ROW SET @b = 1;
--connection master
--reap
DROP TRIGGER IF EXISTS tr;
--dec $run
}
--sync_slave_with_master
# Cleanup
--connection master
DROP TABLE t1, t2;
--source include/rpl_end.inc
It very quickly ends up with something like this in the binary log:
bb-10.6-monty 387d673ed
master-bin.000001 653 Query 1 836 use `test`; CREATE DEFINER=`root`@`localhost` TRIGGER tr AFTER INSERT ON t1 FOR EACH ROW SET @b = 1
master-bin.000001 836 Gtid 1 878 GTID 0-1-4
master-bin.000001 878 Query 1 979 use `test`; DROP TRIGGER IF EXISTS tr
master-bin.000001 979 Gtid 1 1021 GTID 0-1-5
master-bin.000001 1021 Query 1 1204 use `test`; CREATE DEFINER=`root`@`localhost` TRIGGER tr AFTER INSERT ON t2 FOR EACH ROW SET @b = 1
master-bin.000001 1204 Gtid 1 1246 GTID 0-1-6
master-bin.000001 1246 Query 1 1429 use `test`; CREATE DEFINER=`root`@`localhost` TRIGGER tr AFTER INSERT ON t1 FOR EACH ROW SET @b = 1
master-bin.000001 1429 Gtid 1 1471 GTID 0-1-7
master-bin.000001 1471 Query 1 1572 use `test`; DROP TRIGGER IF EXISTS tr
which naturally makes the replication fail with
2021-05-06 0:44:33 8 [ERROR] Slave SQL: Error 'Trigger 'test.tr' already exists' on query. Default database: 'test'. Query: 'CREATE DEFINER=`root`@`localhost` TRIGGER tr AFTER INSERT ON t1 FOR EACH ROW SET @b = 1', Gtid 0-1-6, Internal MariaDB error code: 1359
2021-05-06 0:44:33 8 [Warning] Slave: Trigger 'test.tr' already exists Error_code: 1359
There was some problem with this on 10.2, but nothing bad happens on 10.3-10.6. However, on bb-10.6-monty starting from the patch below it fails very reliably.
commit d9fe53cfe71443c645862f62b389b4e7b56a5953
Author: Monty
Date: Mon Mar 22 16:05:08 2021 +0200
Check if we can rename triggers before doing an ALTER TABLE ... RENAME
Elena Stepanova
made changes -
2021-05-05 21:50
Field
Original Value
New Value
Link
This issue relates to TODO-2694
[ TODO-2694
]
Michael Widenius
made changes -
2021-05-10 15:36
Summary
Atomic DDL: Concurrent CREATE TRIGGER statements mix up in binlog and break replication
Concurrent CREATE TRIGGER statements mix up in binlog and break replication
Michael Widenius
made changes -
2021-05-10 16:19
Fix Version/s
10.5
[ 23123
]
Fix Version/s
10.6
[ 24028
]
Michael Widenius
made changes -
2021-05-10 21:19
issue.field.resolutiondate
2021-05-10 21:19:18.0
2021-05-10 21:19:18.159
Michael Widenius
made changes -
2021-05-10 21:19
Fix Version/s
10.5.11
[ 25734
]
Fix Version/s
10.5
[ 23123
]
Resolution
Fixed
[ 1
]
Status
Open
[ 1
]
Closed
[ 6
]
Sergei Golubchik
made changes -
2021-12-06 21:53
Workflow
MariaDB v3
[ 121641
]
MariaDB v4
[ 159244
]
{"report":{"fcp":815.1999999284744,"ttfb":275.1999999284744,"pageVisibility":"visible","entityId":99437,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":1,"journeyId":"77901ddb-1aaf-45cc-b2fd-734fd61627ea","navigationType":0,"readyForUser":900.5,"redirectCount":0,"resourceLoadedEnd":963.2999999523163,"resourceLoadedStart":281.2999999523163,"resourceTiming":[{"duration":7.700000047683716,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":281.2999999523163,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":281.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":289,"responseStart":0,"secureConnectionStart":0},{"duration":10,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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":281.59999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":281.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":291.59999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":75.10000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":281.7999999523163,"connectEnd":281.7999999523163,"connectStart":281.7999999523163,"domainLookupEnd":281.7999999523163,"domainLookupStart":281.7999999523163,"fetchStart":281.7999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":281.7999999523163,"responseEnd":356.89999997615814,"responseStart":356.89999997615814,"secureConnectionStart":281.7999999523163},{"duration":145.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/s/099b33461394b8015fc36c0a4b96e19f-CDN/lu2bu7/820016/12ta74/8679b4946efa1a0bb029a3a22206fb5d/_/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":282,"connectEnd":282,"connectStart":282,"domainLookupEnd":282,"domainLookupStart":282,"fetchStart":282,"redirectEnd":0,"redirectStart":0,"requestStart":282,"responseEnd":427.09999990463257,"responseStart":427.09999990463257,"secureConnectionStart":282},{"duration":148.60000002384186,"initiatorType":"script","name":"https://jira.mariadb.org/s/94c15bff32baef80f4096a08aceae8bc-CDN/lu2bu7/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":282.1999999284744,"connectEnd":282.1999999284744,"connectStart":282.1999999284744,"domainLookupEnd":282.1999999284744,"domainLookupStart":282.1999999284744,"fetchStart":282.1999999284744,"redirectEnd":0,"redirectStart":0,"requestStart":282.1999999284744,"responseEnd":430.7999999523163,"responseStart":430.7999999523163,"secureConnectionStart":282.1999999284744},{"duration":149,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":282.2999999523163,"connectEnd":282.2999999523163,"connectStart":282.2999999523163,"domainLookupEnd":282.2999999523163,"domainLookupStart":282.2999999523163,"fetchStart":282.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":282.2999999523163,"responseEnd":431.2999999523163,"responseStart":431.2999999523163,"secureConnectionStart":282.2999999523163},{"duration":149.19999992847443,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":282.5,"connectEnd":282.5,"connectStart":282.5,"domainLookupEnd":282.5,"domainLookupStart":282.5,"fetchStart":282.5,"redirectEnd":0,"redirectStart":0,"requestStart":282.5,"responseEnd":431.6999999284744,"responseStart":431.6999999284744,"secureConnectionStart":282.5},{"duration":219.39999997615814,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2bu7/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":282.6999999284744,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":282.6999999284744,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":502.09999990463257,"responseStart":0,"secureConnectionStart":0},{"duration":149.19999992847443,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":282.89999997615814,"connectEnd":282.89999997615814,"connectStart":282.89999997615814,"domainLookupEnd":282.89999997615814,"domainLookupStart":282.89999997615814,"fetchStart":282.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":282.89999997615814,"responseEnd":432.09999990463257,"responseStart":432.09999990463257,"secureConnectionStart":282.89999997615814},{"duration":219.10000002384186,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2bu7/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":283.09999990463257,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":283.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":502.1999999284744,"responseStart":0,"secureConnectionStart":0},{"duration":149.70000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/s/3339d87fa2538a859872f2df449bf8d0-CDN/lu2bu7/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":283.09999990463257,"connectEnd":283.09999990463257,"connectStart":283.09999990463257,"domainLookupEnd":283.09999990463257,"domainLookupStart":283.09999990463257,"fetchStart":283.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":283.09999990463257,"responseEnd":432.7999999523163,"responseStart":432.7999999523163,"secureConnectionStart":283.09999990463257},{"duration":232.20000004768372,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":284.1999999284744,"connectEnd":284.1999999284744,"connectStart":284.1999999284744,"domainLookupEnd":284.1999999284744,"domainLookupStart":284.1999999284744,"fetchStart":284.1999999284744,"redirectEnd":0,"redirectStart":0,"requestStart":284.1999999284744,"responseEnd":516.3999999761581,"responseStart":516.3999999761581,"secureConnectionStart":284.1999999284744},{"duration":266.2999999523163,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":284.2999999523163,"connectEnd":284.2999999523163,"connectStart":284.2999999523163,"domainLookupEnd":284.2999999523163,"domainLookupStart":284.2999999523163,"fetchStart":284.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":284.2999999523163,"responseEnd":550.5999999046326,"responseStart":550.5999999046326,"secureConnectionStart":284.2999999523163},{"duration":21,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":530.1999999284744,"connectEnd":530.1999999284744,"connectStart":530.1999999284744,"domainLookupEnd":530.1999999284744,"domainLookupStart":530.1999999284744,"fetchStart":530.1999999284744,"redirectEnd":0,"redirectStart":0,"requestStart":530.1999999284744,"responseEnd":551.1999999284744,"responseStart":551.1999999284744,"secureConnectionStart":530.1999999284744},{"duration":409,"initiatorType":"link","name":"https://jira.mariadb.org/s/d5715adaadd168a9002b108b2b039b50-CDN/lu2bu7/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":554.2999999523163,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":554.2999999523163,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":963.2999999523163,"responseStart":0,"secureConnectionStart":0}],"fetchStart":1,"domainLookupStart":1,"domainLookupEnd":1,"connectStart":1,"connectEnd":1,"requestStart":66,"responseStart":276,"responseEnd":278,"domLoading":279,"domInteractive":975,"domContentLoadedEventStart":975,"domContentLoadedEventEnd":1034,"domComplete":1138,"loadEventStart":1138,"loadEventEnd":1138,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":943.1999999284744},{"name":"bigPipe.sidebar-id.end","time":943.8999999761581},{"name":"bigPipe.activity-panel-pipe-id.start","time":944.0999999046326},{"name":"bigPipe.activity-panel-pipe-id.end","time":947.2999999523163},{"name":"activityTabFullyLoaded","time":1052.1999999284744}],"measures":[],"correlationId":"a885e8aa577cec","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":142,"dbReadsTimeInMs":25,"dbConnsTimeInMs":35,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
The reason for this is that we don't have a a lock on the trigger name, so it is possible for
two threads to try to create the same trigger at the same time and both thinks that they
have succeed.
There is also a possibility for a problem with DROP TRIGGER:
Another thread does in the mean time drop of the .TRN file and creates a new trigger for another table with the same name