When we rotate the binlog, we first close the old log file, which marks the
file as "not crashed". We then create the new log file, and last add it to the
binlog index file.
Suppose we crash after closing the old file but before the new file is added
to the index. And suppose further than at least one transaction had time to
enter the "prepared inside InnoDB" status before we crashed.
Then on next server restart, the binlog code will not realise that we crashed,
as the last file in the binlog index is closed properly. And ha_recover in
handler.cc will fail the startup due to finding a prepared innodb transaction
in a no-crash scenario:
120615 14:41:02 [ERROR] Found 1 prepared transactions! It means that mysqld was not shut down properly last time and critical recovery information (last binlog or tc.log file) was manually deleted after a crash. You have to start mysqld with --tc-heuristic-recover switch to commit or rollback pending transactions.
To reproduce, apply following patch (to get needed debug_sync points) and run
attached test case.
=== modified file 'sql/handler.cc'
|
--- sql/handler.cc 2012-05-21 18:54:41 +0000
|
+++ sql/handler.cc 2012-06-15 12:37:51 +0000
|
@@ -1276,6 +1276,7 @@ int ha_commit_trans(THD *thd, bool all)
|
need_prepare_ordered|= (ht->prepare_ordered != NULL);
|
need_commit_ordered|= (ht->commit_ordered != NULL);
|
}
|
+ DEBUG_SYNC(thd, "ha_commit_trans_after_prepare");
|
DBUG_EXECUTE_IF("crash_commit_after_prepare", DBUG_SUICIDE(););
|
|
if (!is_real_trans)
|
|
=== modified file 'sql/log.cc'
|
--- sql/log.cc 2012-05-21 18:54:41 +0000
|
+++ sql/log.cc 2012-06-15 12:39:45 +0000
|
@@ -3189,6 +3189,10 @@ bool MYSQL_BIN_LOG::open(const char *log
|
if (write_file_name_to_index_file)
|
{
|
#ifdef HAVE_REPLICATION
|
+#ifdef ENABLED_DEBUG_SYNC
|
+ if (current_thd)
|
+ DEBUG_SYNC(current_thd, "binlog_open_before_update_index");
|
+#endif
|
DBUG_EXECUTE_IF("crash_create_critical_before_update_index", DBUG_SUICIDE(););
|
#endif
|
{"report":{"fcp":1232.8000001907349,"ttfb":367,"pageVisibility":"visible","entityId":12115,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"928fe12f-2b7a-4318-a928-fc03a651d164","navigationType":0,"readyForUser":1309.6999998092651,"redirectCount":0,"resourceLoadedEnd":1602.6999998092651,"resourceLoadedStart":374.19999980926514,"resourceTiming":[{"duration":331.3999996185303,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":374.19999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":374.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":705.5999994277954,"responseStart":0,"secureConnectionStart":0},{"duration":331.69999980926514,"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":374.3999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":374.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":706.0999994277954,"responseStart":0,"secureConnectionStart":0},{"duration":391.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":374.69999980926514,"connectEnd":374.69999980926514,"connectStart":374.69999980926514,"domainLookupEnd":374.69999980926514,"domainLookupStart":374.69999980926514,"fetchStart":374.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":374.69999980926514,"responseEnd":766.5,"responseStart":766.5,"secureConnectionStart":374.69999980926514},{"duration":452.9000005722046,"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":374.8999996185303,"connectEnd":374.8999996185303,"connectStart":374.8999996185303,"domainLookupEnd":374.8999996185303,"domainLookupStart":374.8999996185303,"fetchStart":374.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":374.8999996185303,"responseEnd":827.8000001907349,"responseStart":827.8000001907349,"secureConnectionStart":374.8999996185303},{"duration":457.20000076293945,"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":375.0999994277954,"connectEnd":375.0999994277954,"connectStart":375.0999994277954,"domainLookupEnd":375.0999994277954,"domainLookupStart":375.0999994277954,"fetchStart":375.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":375.0999994277954,"responseEnd":832.3000001907349,"responseStart":832.3000001907349,"secureConnectionStart":375.0999994277954},{"duration":458.19999980926514,"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":375.30000019073486,"connectEnd":375.30000019073486,"connectStart":375.30000019073486,"domainLookupEnd":375.30000019073486,"domainLookupStart":375.30000019073486,"fetchStart":375.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":375.30000019073486,"responseEnd":833.5,"responseStart":833.5,"secureConnectionStart":375.30000019073486},{"duration":459.0999994277954,"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":375.5,"connectEnd":375.5,"connectStart":375.5,"domainLookupEnd":375.5,"domainLookupStart":375.5,"fetchStart":375.5,"redirectEnd":0,"redirectStart":0,"requestStart":375.5,"responseEnd":834.5999994277954,"responseStart":834.5999994277954,"secureConnectionStart":375.5},{"duration":535.5,"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":375.80000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":375.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":911.3000001907349,"responseStart":0,"secureConnectionStart":0},{"duration":459.69999980926514,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":376,"connectEnd":376,"connectStart":376,"domainLookupEnd":376,"domainLookupStart":376,"fetchStart":376,"redirectEnd":0,"redirectStart":0,"requestStart":376,"responseEnd":835.6999998092651,"responseStart":835.6999998092651,"secureConnectionStart":376},{"duration":535.3000001907349,"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":376.0999994277954,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":376.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":911.3999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":460.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":376.30000019073486,"connectEnd":376.30000019073486,"connectStart":376.30000019073486,"domainLookupEnd":376.30000019073486,"domainLookupStart":376.30000019073486,"fetchStart":376.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":376.30000019073486,"responseEnd":837.1999998092651,"responseStart":837.1999998092651,"secureConnectionStart":376.30000019073486},{"duration":781,"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":377.19999980926514,"connectEnd":377.19999980926514,"connectStart":377.19999980926514,"domainLookupEnd":377.19999980926514,"domainLookupStart":377.19999980926514,"fetchStart":377.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":377.19999980926514,"responseEnd":1158.1999998092651,"responseStart":1158.1999998092651,"secureConnectionStart":377.19999980926514},{"duration":1213.0999994277954,"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":377.30000019073486,"connectEnd":377.30000019073486,"connectStart":377.30000019073486,"domainLookupEnd":377.30000019073486,"domainLookupStart":377.30000019073486,"fetchStart":377.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":377.30000019073486,"responseEnd":1590.3999996185303,"responseStart":1590.3999996185303,"secureConnectionStart":377.30000019073486},{"duration":250.89999961853027,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":923.3000001907349,"connectEnd":923.3000001907349,"connectStart":923.3000001907349,"domainLookupEnd":923.3000001907349,"domainLookupStart":923.3000001907349,"fetchStart":923.3000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":923.3000001907349,"responseEnd":1174.1999998092651,"responseStart":1174.1999998092651,"secureConnectionStart":923.3000001907349},{"duration":409.79999923706055,"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&whisper-enabled=true","startTime":1182.8000001907349,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1182.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1592.5999994277954,"responseStart":0,"secureConnectionStart":0},{"duration":408.8999996185303,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/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&whisper-enabled=true","startTime":1183.6999998092651,"connectEnd":1183.6999998092651,"connectStart":1183.6999998092651,"domainLookupEnd":1183.6999998092651,"domainLookupStart":1183.6999998092651,"fetchStart":1183.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":1183.6999998092651,"responseEnd":1592.5999994277954,"responseStart":1592.5999994277954,"secureConnectionStart":1183.6999998092651},{"duration":418.6000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/s/097ae97cb8fbec7d6ea4bbb1f26955b9-CDN/lu2cib/820016/12ta74/be4b45e9cec53099498fa61c8b7acba4/_/download/contextbatch/js/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.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":1184.0999994277954,"connectEnd":1184.0999994277954,"connectStart":1184.0999994277954,"domainLookupEnd":1184.0999994277954,"domainLookupStart":1184.0999994277954,"fetchStart":1184.0999994277954,"redirectEnd":0,"redirectStart":0,"requestStart":1184.0999994277954,"responseEnd":1602.6999998092651,"responseStart":1602.6999998092651,"secureConnectionStart":1184.0999994277954},{"duration":389.69999980926514,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1222.1999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1222.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1611.8999996185303,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":208,"responseStart":367,"responseEnd":371,"domLoading":371,"domInteractive":1656,"domContentLoadedEventStart":1656,"domContentLoadedEventEnd":1700,"domComplete":2005,"loadEventStart":2006,"loadEventEnd":2006,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1598.0999994277954},{"name":"bigPipe.sidebar-id.end","time":1599},{"name":"bigPipe.activity-panel-pipe-id.start","time":1599.1999998092651},{"name":"bigPipe.activity-panel-pipe-id.end","time":1600.5},{"name":"activityTabFullyLoaded","time":1723}],"measures":[],"correlationId":"e33d55d54c6bef","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":98,"dbReadsTimeInMs":12,"dbConnsTimeInMs":21,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Fix committed - re-assigning for review