MLOG_INDEX_LOAD redo log is written during online alter table. But MLOG_INDEX_LOAD
is written for the root page even though the page is empty and for spatial index too. By fixing this, we can save some I/O for mariabackup
and even during redo log recovery. (MDEV-12699). It also saves a few bytes in the redo log.
{"report":{"fcp":1110.4000000953674,"ttfb":291.40000009536743,"pageVisibility":"visible","entityId":73522,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"e76686ea-69be-4825-bc19-f33294096e6a","navigationType":0,"readyForUser":1182.8000001907349,"redirectCount":0,"resourceLoadedEnd":1145.2000002861023,"resourceLoadedStart":297,"resourceTiming":[{"duration":248.40000009536743,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":297,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":297,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":545.4000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":248.80000019073486,"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":297.30000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":297.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":546.1000003814697,"responseStart":0,"secureConnectionStart":0},{"duration":311,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":297.5,"connectEnd":297.5,"connectStart":297.5,"domainLookupEnd":297.5,"domainLookupStart":297.5,"fetchStart":297.5,"redirectEnd":0,"redirectStart":0,"requestStart":297.5,"responseEnd":608.5,"responseStart":608.5,"secureConnectionStart":297.5},{"duration":374.69999980926514,"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":297.80000019073486,"connectEnd":297.80000019073486,"connectStart":297.80000019073486,"domainLookupEnd":297.80000019073486,"domainLookupStart":297.80000019073486,"fetchStart":297.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":297.80000019073486,"responseEnd":672.5,"responseStart":672.5,"secureConnectionStart":297.80000019073486},{"duration":378.5,"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":297.90000009536743,"connectEnd":297.90000009536743,"connectStart":297.90000009536743,"domainLookupEnd":297.90000009536743,"domainLookupStart":297.90000009536743,"fetchStart":297.90000009536743,"redirectEnd":0,"redirectStart":0,"requestStart":297.90000009536743,"responseEnd":676.4000000953674,"responseStart":676.4000000953674,"secureConnectionStart":297.90000009536743},{"duration":378.59999990463257,"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":298.2000002861023,"connectEnd":298.2000002861023,"connectStart":298.2000002861023,"domainLookupEnd":298.2000002861023,"domainLookupStart":298.2000002861023,"fetchStart":298.2000002861023,"redirectEnd":0,"redirectStart":0,"requestStart":298.2000002861023,"responseEnd":676.8000001907349,"responseStart":676.8000001907349,"secureConnectionStart":298.2000002861023},{"duration":378.90000009536743,"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":298.30000019073486,"connectEnd":298.30000019073486,"connectStart":298.30000019073486,"domainLookupEnd":298.30000019073486,"domainLookupStart":298.30000019073486,"fetchStart":298.30000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":298.30000019073486,"responseEnd":677.2000002861023,"responseStart":677.2000002861023,"secureConnectionStart":298.30000019073486},{"duration":453.2000002861023,"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":298.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":298.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":751.7000002861023,"responseStart":0,"secureConnectionStart":0},{"duration":379.09999990463257,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":298.6000003814697,"connectEnd":298.6000003814697,"connectStart":298.6000003814697,"domainLookupEnd":298.6000003814697,"domainLookupStart":298.6000003814697,"fetchStart":298.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":298.6000003814697,"responseEnd":677.7000002861023,"responseStart":677.7000002861023,"secureConnectionStart":298.6000003814697},{"duration":453.09999990463257,"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":298.80000019073486,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":298.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":751.9000000953674,"responseStart":0,"secureConnectionStart":0},{"duration":379.30000019073486,"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":299,"connectEnd":299,"connectStart":299,"domainLookupEnd":299,"domainLookupStart":299,"fetchStart":299,"redirectEnd":0,"redirectStart":0,"requestStart":299,"responseEnd":678.3000001907349,"responseStart":678.3000001907349,"secureConnectionStart":299},{"duration":461.09999990463257,"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":299.80000019073486,"connectEnd":299.80000019073486,"connectStart":299.80000019073486,"domainLookupEnd":299.80000019073486,"domainLookupStart":299.80000019073486,"fetchStart":299.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":299.80000019073486,"responseEnd":760.9000000953674,"responseStart":760.9000000953674,"secureConnectionStart":299.80000019073486},{"duration":581.4000000953674,"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":299.80000019073486,"connectEnd":299.80000019073486,"connectStart":299.80000019073486,"domainLookupEnd":299.80000019073486,"domainLookupStart":299.80000019073486,"fetchStart":299.80000019073486,"redirectEnd":0,"redirectStart":0,"requestStart":299.80000019073486,"responseEnd":881.2000002861023,"responseStart":881.2000002861023,"secureConnectionStart":299.80000019073486},{"duration":102,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":779.6000003814697,"connectEnd":779.6000003814697,"connectStart":779.6000003814697,"domainLookupEnd":779.6000003814697,"domainLookupStart":779.6000003814697,"fetchStart":779.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":779.6000003814697,"responseEnd":881.6000003814697,"responseStart":881.6000003814697,"secureConnectionStart":779.6000003814697},{"duration":117.40000009536743,"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":1027.8000001907349,"connectEnd":1027.8000001907349,"connectStart":1027.8000001907349,"domainLookupEnd":1027.8000001907349,"domainLookupStart":1027.8000001907349,"fetchStart":1027.8000001907349,"redirectEnd":0,"redirectStart":0,"requestStart":1027.8000001907349,"responseEnd":1145.2000002861023,"responseStart":1145.2000002861023,"secureConnectionStart":1027.8000001907349},{"duration":109.09999990463257,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1103.6000003814697,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1103.6000003814697,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1212.7000002861023,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":145,"responseStart":292,"responseEnd":295,"domLoading":295,"domInteractive":1246,"domContentLoadedEventStart":1246,"domContentLoadedEventEnd":1292,"domComplete":1531,"loadEventStart":1531,"loadEventEnd":1532,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1215},{"name":"bigPipe.sidebar-id.end","time":1215.7000002861023},{"name":"bigPipe.activity-panel-pipe-id.start","time":1216},{"name":"bigPipe.activity-panel-pipe-id.end","time":1218.5},{"name":"activityTabFullyLoaded","time":1308.6000003814697}],"measures":[],"correlationId":"c8d79932529519","effectiveType":"4g","downlink":10,"rtt":0,"serverDuration":93,"dbReadsTimeInMs":12,"dbConnsTimeInMs":20,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
Below patch can fix the issue for un-necessary writing of MLOG_INDEX_LOAD redo log record.
diff --git a/storage/innobase/row/row0merge.cc b/storage/innobase/row/row0merge.cc
index 4f05899..3c5e715 100644
--- a/storage/innobase/row/row0merge.cc
+++ b/storage/innobase/row/row0merge.cc
@@ -4559,6 +4559,7 @@ row_merge_build_indexes(
ulint total_index_blocks = 0;
double pct_cost=0;
double pct_progress=0;
+ bool is_empty_table = false;
DBUG_ENTER("row_merge_build_indexes");
@@ -4637,6 +4638,7 @@ row_merge_build_indexes(
for (i = 0; i < n_indexes; i++) {
merge_files[i].fd = -1;
merge_files[i].offset = 0;
+ merge_files[i].n_rec = 0;
}
total_static_cost = COST_BUILD_INDEX_STATIC * n_indexes + COST_READ_CLUSTERED_INDEX;
@@ -4723,6 +4725,8 @@ row_merge_build_indexes(
total_index_blocks += merge_files[i].offset;
}
+ is_empty_table = (merge_files[0].n_rec == 0);
+
if (error != DB_SUCCESS) {
goto func_exit;
}
@@ -4915,7 +4919,7 @@ row_merge_build_indexes(
ut_ad(sort_idx->online_status
== ONLINE_INDEX_COMPLETE);
} else {
- if (flush_observer) {
+ if (flush_observer && !is_empty_table) {
flush_observer->flush();
row_merge_write_redo(indexes[i]);
}
@@ -5033,7 +5037,8 @@ row_merge_build_indexes(
error = DB_INTERRUPTED;
}
- if (error == DB_SUCCESS && old_table != new_table) {
+ if (error == DB_SUCCESS && old_table != new_table
+ && !is_empty_table) {
for (const dict_index_t* index
= dict_table_get_first_index(new_table);
index != NULL;
I tested the patch manually by adding ib_log as restart parameter in mtr test case.
Tested for both PK(rebuild table) and index build.