The test case mentioned in MDEV-16063 occasionally causes a crash in AddressSanitizer-enabled builds. I have tested and repeated this in 10.0, 10.2, and 10.3 so far.
10.0 7b9486d2eb3876d55edc05173235e6ccad2e6ae3
|
AddressSanitizer: heap-use-after-free
|
…
|
#8 0x00000000006730a8 in __asan_report_load8 ()
|
#9 0x00007fded9d437bc in lock_release (trx=<optimized out>) at /mariadb/10.0/storage/innobase/lock/lock0lock.cc:4803
|
#10 0x00007fded9d432d1 in lock_trx_release_locks (trx=0x61b00003fef8) at /mariadb/10.0/storage/innobase/lock/lock0lock.cc:7047
|
#11 0x00007fded9ebe384 in trx_commit_in_memory (trx=0x61b00003fef8, lsn=1639442) at /mariadb/10.0/storage/innobase/trx/trx0trx.cc:1182
|
#12 0x00007fded9ebf173 in trx_commit (trx=0x61b00003fef8) at /mariadb/10.0/storage/innobase/trx/trx0trx.cc:1410
|
#13 0x00007fded9eb1915 in trx_rollback_finish (trx=0x61b00003fef8) at /mariadb/10.0/storage/innobase/trx/trx0roll.cc:1339
|
This rollback is executed when a client disconnects. The index name is uidx, and that object has been freed. lock->index->table->indexes contains only one index, the clustered index. The freed index object was an uncommitted index, created by ADD UNIQUE INDEX.
Next, I will try to create a DEBUG_SYNC test case for this.
{"report":{"fcp":923.3999999761581,"ttfb":204.5,"pageVisibility":"visible","entityId":67336,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":16,"apdex":0.5,"journeyId":"8daddd77-308f-47c4-8fb7-84cf2915766b","navigationType":0,"readyForUser":1021.0999999940395,"redirectCount":0,"resourceLoadedEnd":1082.5,"resourceLoadedStart":210.59999999403954,"resourceTiming":[{"duration":52.79999998211861,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":210.59999999403954,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":210.59999999403954,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":263.39999997615814,"responseStart":0,"secureConnectionStart":0},{"duration":52.5,"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":210.89999997615814,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":210.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":263.39999997615814,"responseStart":0,"secureConnectionStart":0},{"duration":105.7999999821186,"initiatorType":"script","name":"https://jira.mariadb.org/s/fbf975c0cce4b1abf04784eeae9ba1f4-CDN/lu2bu7/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":211.09999999403954,"connectEnd":211.09999999403954,"connectStart":211.09999999403954,"domainLookupEnd":211.09999999403954,"domainLookupStart":211.09999999403954,"fetchStart":211.09999999403954,"redirectEnd":0,"redirectStart":0,"requestStart":211.09999999403954,"responseEnd":316.89999997615814,"responseStart":316.89999997615814,"secureConnectionStart":211.09999999403954},{"duration":265,"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":211.19999998807907,"connectEnd":211.19999998807907,"connectStart":211.19999998807907,"domainLookupEnd":211.19999998807907,"domainLookupStart":211.19999998807907,"fetchStart":211.19999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":211.19999998807907,"responseEnd":476.19999998807907,"responseStart":476.19999998807907,"secureConnectionStart":211.19999998807907},{"duration":268.5,"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":211.39999997615814,"connectEnd":211.39999997615814,"connectStart":211.39999997615814,"domainLookupEnd":211.39999997615814,"domainLookupStart":211.39999997615814,"fetchStart":211.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":211.39999997615814,"responseEnd":479.89999997615814,"responseStart":479.89999997615814,"secureConnectionStart":211.39999997615814},{"duration":269,"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":211.5,"connectEnd":211.5,"connectStart":211.5,"domainLookupEnd":211.5,"domainLookupStart":211.5,"fetchStart":211.5,"redirectEnd":0,"redirectStart":0,"requestStart":211.5,"responseEnd":480.5,"responseStart":480.5,"secureConnectionStart":211.5},{"duration":269.89999997615814,"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":211.5,"connectEnd":211.5,"connectStart":211.5,"domainLookupEnd":211.5,"domainLookupStart":211.5,"fetchStart":211.5,"redirectEnd":0,"redirectStart":0,"requestStart":211.5,"responseEnd":481.39999997615814,"responseStart":481.39999997615814,"secureConnectionStart":211.5},{"duration":271.40000000596046,"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":211.59999999403954,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":211.59999999403954,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":483,"responseStart":0,"secureConnectionStart":0},{"duration":272.59999999403954,"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":211.69999998807907,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":211.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":484.2999999821186,"responseStart":0,"secureConnectionStart":0},{"duration":270.69999998807907,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":211.69999998807907,"connectEnd":211.69999998807907,"connectStart":211.69999998807907,"domainLookupEnd":211.69999998807907,"domainLookupStart":211.69999998807907,"fetchStart":211.69999998807907,"redirectEnd":0,"redirectStart":0,"requestStart":211.69999998807907,"responseEnd":482.39999997615814,"responseStart":482.39999997615814,"secureConnectionStart":211.69999998807907},{"duration":271.90000000596046,"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":211.89999997615814,"connectEnd":211.89999997615814,"connectStart":211.89999997615814,"domainLookupEnd":211.89999997615814,"domainLookupStart":211.89999997615814,"fetchStart":211.89999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":211.89999997615814,"responseEnd":483.7999999821186,"responseStart":483.69999998807907,"secureConnectionStart":211.89999997615814},{"duration":573.6000000238419,"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":212.39999997615814,"connectEnd":212.39999997615814,"connectStart":212.39999997615814,"domainLookupEnd":212.39999997615814,"domainLookupStart":212.39999997615814,"fetchStart":212.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":212.39999997615814,"responseEnd":786,"responseStart":786,"secureConnectionStart":212.39999997615814},{"duration":699,"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":229.39999997615814,"connectEnd":229.39999997615814,"connectStart":229.39999997615814,"domainLookupEnd":229.39999997615814,"domainLookupStart":229.39999997615814,"fetchStart":229.39999997615814,"redirectEnd":0,"redirectStart":0,"requestStart":229.39999997615814,"responseEnd":928.3999999761581,"responseStart":928.3999999761581,"secureConnectionStart":229.39999997615814},{"duration":271.09999999403954,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":517.6999999880791,"connectEnd":517.6999999880791,"connectStart":517.6999999880791,"domainLookupEnd":517.6999999880791,"domainLookupStart":517.6999999880791,"fetchStart":517.6999999880791,"redirectEnd":0,"redirectStart":0,"requestStart":517.6999999880791,"responseEnd":788.7999999821186,"responseStart":788.7999999821186,"secureConnectionStart":517.6999999880791},{"duration":278.90000000596046,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2bu7/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","startTime":803.5999999940395,"connectEnd":803.5999999940395,"connectStart":803.5999999940395,"domainLookupEnd":803.5999999940395,"domainLookupStart":803.5999999940395,"fetchStart":803.5999999940395,"redirectEnd":0,"redirectStart":0,"requestStart":803.5999999940395,"responseEnd":1082.5,"responseStart":1082.5,"secureConnectionStart":803.5999999940395},{"duration":169.30000001192093,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":915.3999999761581,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":915.3999999761581,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1084.699999988079,"responseStart":0,"secureConnectionStart":0}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":48,"responseStart":204,"responseEnd":226,"domLoading":208,"domInteractive":1121,"domContentLoadedEventStart":1121,"domContentLoadedEventEnd":1192,"domComplete":1514,"loadEventStart":1514,"loadEventEnd":1515,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1074.5},{"name":"bigPipe.sidebar-id.end","time":1075.199999988079},{"name":"bigPipe.activity-panel-pipe-id.start","time":1075.2999999821186},{"name":"bigPipe.activity-panel-pipe-id.end","time":1078.699999988079},{"name":"activityTabFullyLoaded","time":1209.8999999761581}],"measures":[],"correlationId":"d9137c5858a744","effectiveType":"4g","downlink":9.1,"rtt":0,"serverDuration":76,"dbReadsTimeInMs":13,"dbConnsTimeInMs":20,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
I added some debug instrumentation to find out when a lock is being created for an uncommitted index:
10.0 7b9486d2eb3876d55edc05173235e6ccad2e6ae3
#6 0x0000562f33c4133c in lock_rec_create (type_mode=type_mode@entry=1059, block=block@entry=0x7f5a9e91e5d0, heap_no=heap_no@entry=2, index=index@entry=0x6190000e1ff8, trx=trx@entry=0x61c0000400f8, caller_owns_trx_mutex=caller_owns_trx_mutex@entry=0) at /mariadb/10.0/storage/xtradb/lock/lock0lock.cc:1869
#7 0x0000562f33c41b46 in lock_rec_add_to_queue (type_mode=type_mode@entry=1059, block=block@entry=0x7f5a9e91e5d0, heap_no=heap_no@entry=2, index=index@entry=0x6190000e1ff8, trx=trx@entry=0x61c0000400f8, caller_owns_trx_mutex=caller_owns_trx_mutex@entry=0) at /mariadb/10.0/storage/xtradb/lock/lock0lock.cc:2182
#8 0x0000562f33c46c8b in lock_rec_convert_impl_to_expl (block=block@entry=0x7f5a9e91e5d0, rec=rec@entry=0x7f5a9ee9c07e "\200", index=index@entry=0x6190000e1ff8, offsets=offsets@entry=0x6190000d16f8) at /mariadb/10.0/storage/xtradb/lock/lock0lock.cc:6349
#9 0x0000562f33c50838 in lock_sec_rec_read_check_and_lock (flags=flags@entry=0, block=block@entry=0x7f5a9e91e5d0, rec=rec@entry=0x7f5a9ee9c07e "\200", index=index@entry=0x6190000e1ff8, offsets=offsets@entry=0x6190000d16f8, mode=mode@entry=LOCK_S, gap_mode=0, thr=0x620000031828) at /mariadb/10.0/storage/xtradb/lock/lock0lock.cc:6573
#10 0x0000562f33d755f5 in row_ins_set_shared_rec_lock (type=type@entry=0, block=block@entry=0x7f5a9e91e5d0, rec=rec@entry=0x7f5a9ee9c07e "\200", index=index@entry=0x6190000e1ff8, offsets=offsets@entry=0x6190000d16f8, thr=thr@entry=0x620000031828) at /mariadb/10.0/storage/xtradb/row/row0ins.cc:1373
#11 0x0000562f33d7a0ad in row_ins_scan_sec_index_for_duplicate (offsets_heap=<optimized out>, mtr=0x7f5a9478acf0, s_latch=<optimized out>, thr=0x620000031828, entry=0x6160000706a8, index=0x6190000e1ff8, flags=0) at /mariadb/10.0/storage/xtradb/row/row0ins.cc:2004
#12 row_ins_sec_index_entry_low (flags=flags@entry=0, mode=mode@entry=2, index=index@entry=0x6190000e1ff8, offsets_heap=<optimized out>, offsets_heap@entry=0x6190000d1680, heap=heap@entry=0x6190000d1b80, entry=entry@entry=0x6160000706a8, trx_id=<optimized out>, thr=<optimized out>) at /mariadb/10.0/storage/xtradb/row/row0ins.cc:2759
#13 0x0000562f33d8a64e in row_ins_sec_index_entry (index=index@entry=0x6190000e1ff8, entry=entry@entry=0x6160000706a8, thr=thr@entry=0x620000031828) at /mariadb/10.0/storage/xtradb/row/row0ins.cc:3015
#14 0x0000562f33d8ccdd in row_ins_index_entry (thr=0x620000031828, entry=0x6160000706a8, index=0x6190000e1ff8) at /mariadb/10.0/storage/xtradb/row/row0ins.cc:3060
#15 row_ins_index_entry_step (thr=0x620000031828, node=0x6200000315e8) at /mariadb/10.0/storage/xtradb/row/row0ins.cc:3135
#16 row_ins (thr=<optimized out>, node=<optimized out>) at /mariadb/10.0/storage/xtradb/row/row0ins.cc:3275
#17 row_ins_step (thr=thr@entry=0x620000031828) at /mariadb/10.0/storage/xtradb/row/row0ins.cc:3400
#18 0x0000562f33dbd3c9 in row_insert_for_mysql (mysql_rec=mysql_rec@entry=0x6190000d07a0 "\371\002", prebuilt=<optimized out>) at /mariadb/10.0/storage/xtradb/row/row0mysql.cc:1379
#19 0x0000562f33bb5c1d in ha_innobase::write_row (this=0x61c0000410a0, record=<optimized out>) at /mariadb/10.0/storage/xtradb/handler/ha_innodb.cc:7979
#20 0x0000562f33389129 in handler::ha_write_row (this=0x61c0000410a0, buf=<optimized out>) at /mariadb/10.0/sql/handler.cc:6033
#21 0x0000562f32deff83 in write_record (thd=thd@entry=0x62a000072208, table=0x61e000070888, info=info@entry=0x7f5a9478c1a0) at /mariadb/10.0/sql/sql_insert.cc:1848
#22 0x0000562f32e05bdf in mysql_insert (thd=thd@entry=0x62a000072208, table_list=0x6250000eda10, fields=..., values_list=..., update_fields=..., update_values=..., duplic=<optimized out>, ignore=<optimized out>) at /mariadb/10.0/sql/sql_insert.cc:964
#23 0x0000562f32e57387 in mysql_execute_command (thd=thd@entry=0x62a000072208) at /mariadb/10.0/sql/sql_parse.cc:3447
#24 0x0000562f32e672c1 in mysql_parse (thd=thd@entry=0x62a000072208, rawbuf=<optimized out>, length=<optimized out>, parser_state=parser_state@entry=0x7f5a9478f870) at /mariadb/10.0/sql/sql_parse.cc:6573
#25 0x0000562f32e6b633 in dispatch_command (command=command@entry=COM_QUERY, thd=thd@entry=0x62a000072208, packet=packet@entry=0x6290000f5209 "INSERT INTO t1 VALUES (2,2),(2,2)", packet_length=packet_length@entry=33) at /mariadb/10.0/sql/sql_parse.cc:1296
I think that it is risky to remove such locking. It is better to modify the code that is responsible for freeing the index stub. Either the stub will have to remain in memory until no locks are referring to it, or the locks will have to be removed. I think that it is safer to keep the stub in memory.