The test case is non-deterministic, run with --repeat=N. It usually fails for me within ~10 attempts on a plain debug build, but it can vary on different machines and builds. The test case is rr-able, although it may require some patience, hundreds of attempts may be needed (again, depending on the machine and build).
I could only reproduce it on 11.7 and main.
--source include/have_innodb.inc
CREATETABLE t1 (a INT) ENGINE=InnoDB;
--source include/restart_mysqld.inc
SET SESSION TRANSACTIONISOLATIONLEVELREADCOMMITTED;
--connect (con1,localhost,root,,)
CREATETABLE t2 (b BLOB) ENGINE=InnoDB;
INSERTINTO t2 VALUES (1),('2025-01-21 00:00:00');
--send
CREATETABLE t3 ENGINE=InnoDB ASSELECT * FROM t1;
--connection default
--error ER_TRUNCATED_WRONG_VALUE
CREATETABLE t4 (b BLOB CHECK (b)) ENGINE=InnoDB ASSELECT b FROM t2;
at /data/MDEV-35647/11.7/storage/innobase/dict/dict0dict.cc:871
#7 0x0000564a3b1cd7e5 in row_undo_mod_parse_undo_rec (dict_locked=false, node=0x153cb803fb40) at /data/MDEV-35647/11.7/storage/innobase/row/row0umod.cc:1210
#8 row_undo_mod (node=node@entry=0x153cb803fb40, thr=thr@entry=0x153cb8038cb0) at /data/MDEV-35647/11.7/storage/innobase/row/row0umod.cc:1327
#9 0x0000564a3b1cf47f in row_undo (thr=0x153cb8038cb0, node=0x153cb803fb40) at /data/MDEV-35647/11.7/storage/innobase/include/trx0undo.inl:82
#10 row_undo_step (thr=thr@entry=0x153cb8038cb0) at /data/MDEV-35647/11.7/storage/innobase/row/row0undo.cc:442
#11 0x0000564a3b171b90 in que_thr_step (thr=0x153cb8038cb0) at /data/MDEV-35647/11.7/storage/innobase/que/que0que.cc:552
#12 que_run_threads_low (thr=0x153cb8038cb0) at /data/MDEV-35647/11.7/storage/innobase/que/que0que.cc:610
#13 que_run_threads (thr=0x153cb8038cb0) at /data/MDEV-35647/11.7/storage/innobase/que/que0que.cc:630
#14 0x0000564a3b1f3ff0 in trx_t::rollback_low (this=this@entry=0x153cd5739680, savept=savept@entry=0x0)
at /data/MDEV-35647/11.7/storage/innobase/trx/trx0roll.cc:129
#15 0x0000564a3b1f256c in trx_t::rollback (this=this@entry=0x153cd5739680, savept=savept@entry=0x0)
at /data/MDEV-35647/11.7/storage/innobase/trx/trx0roll.cc:183
#16 0x0000564a3b0cc9f4 in ha_innobase::delete_table (this=<optimized out>, name=<optimized out>)
at /data/MDEV-35647/11.7/storage/innobase/handler/ha_innodb.cc:13644
#17 0x0000564a3ae4725c in hton_drop_table (hton=0x564a3dcda578, path=<optimized out>) at /data/MDEV-35647/11.7/sql/handler.cc:578
#18 0x0000564a3ae4de15 in ha_delete_table (thd=thd@entry=0x153cb8012418, hton=hton@entry=0x564a3dcda578, path=path@entry=0x153ccd2a5650 "./test/t4",
db=db@entry=0x153cb8024d08, alias=alias@entry=0x153cb8024d18, generate_warning=generate_warning@entry=false) at /data/MDEV-35647/11.7/sql/handler.cc:3303
#19 0x0000564a3ac64576 in quick_rm_table (thd=0x153cb8012418, base=0x564a3dcda578, db=0x153cb8024d08, table_name=0x153cb8024d18, flags=flags@entry=20,
table_path=table_path@entry=0x0) at /data/MDEV-35647/11.7/sql/sql_table.cc:2152
#21 0x0000564a3ab68eee in select_create::abort_result_set (this=0x153cb8026f80) at /data/MDEV-35647/11.7/sql/sql_insert.cc:5411
#22 select_create::abort_result_set (this=0x153cb8026f80) at /data/MDEV-35647/11.7/sql/sql_insert.cc:5346
#23 0x0000564a3ac2f812 in handle_select (thd=thd@entry=0x153cb8012418, lex=lex@entry=0x153cb8016660, result=result@entry=0x153cb8026f80,
setup_tables_done_option=setup_tables_done_option@entry=0) at /data/MDEV-35647/11.7/sql/sql_select.cc:651
#24 0x0000564a3ac71e8f in Sql_cmd_create_table_like::execute (this=<optimized out>, thd=0x153cb8012418) at /data/MDEV-35647/11.7/sql/sql_table.cc:13377
#25 0x0000564a3abaff4f in mysql_execute_command (thd=0x153cb8012418, is_called_from_prepared_stmt=<optimized out>)
The patch looks functionally correct. I have one improvement suggestion. I think the root cause of the issue is setting dict_operation_lock_mode much earlier to releasing the dict sys lock.
1. Move trx->dict_operation_lock_mode= false; down while unlocking the dictionary.
2. Improve [1] by calling row_mysql_unlock_data_dictionary instead of dict_sys.unlock(); to unset dict_operation_lock_mode together.
Debarun Banerjee
added a comment - The patch looks functionally correct. I have one improvement suggestion. I think the root cause of the issue is setting dict_operation_lock_mode much earlier to releasing the dict sys lock.
1. Move trx->dict_operation_lock_mode= false; down while unlocking the dictionary.
2. Improve [1] by calling row_mysql_unlock_data_dictionary instead of dict_sys.unlock(); to unset dict_operation_lock_mode together.
In the fix of MDEV-25919, an assignment had been moved across a call to trx->rollback(), causing an incorrect value of dict_locked=false to be passed during the rollback. Restoring the order fixes this:
@@ -13798,8 +13798,8 @@ int ha_innobase::delete_table(const char *name)
if (err != DB_SUCCESS)
{
err_exit:
- trx->dict_operation_lock_mode= false;
trx->rollback();
+ trx->dict_operation_lock_mode= false;
switch (err) {
case DB_CANNOT_DROP_CONSTRAINT:
case DB_LOCK_WAIT_TIMEOUT:
Marko Mäkelä
added a comment - In the fix of MDEV-25919 , an assignment had been moved across a call to trx->rollback() , causing an incorrect value of dict_locked=false to be passed during the rollback. Restoring the order fixes this:
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 447d1533b6c..fe0c0ea177c 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -13798,8 +13798,8 @@ int ha_innobase::delete_table(const char *name)
if (err != DB_SUCCESS)
{
err_exit:
- trx->dict_operation_lock_mode= false;
trx->rollback();
+ trx->dict_operation_lock_mode= false;
switch (err) {
case DB_CANNOT_DROP_CONSTRAINT:
case DB_LOCK_WAIT_TIMEOUT:
I can reproduce this on 10.6 when using innodb_snapshot_isolation=ON.
The problem seems to be that the CREATE TABLE t4…SELECT needs to be rolled back because of a fatal error (in this case, ER_CHECKREAD, but I think that also a lock wait timeout would be applicable).
The bug is in the error handling. The transaction rollback assumes that the caller is not holding dict_sys.latch in any mode.
We must ensure that no DDL operation in 10.6 may hold dict_sys.latch while executing transaction rollback. CREATE…SELECT is quite different from everything else, and the logic was rewritten in 10.6 in order to achieve Atomic DDL.
Marko Mäkelä
added a comment - I can reproduce this on 10.6 when using innodb_snapshot_isolation=ON .
The problem seems to be that the CREATE TABLE t4…SELECT needs to be rolled back because of a fatal error (in this case, ER_CHECKREAD , but I think that also a lock wait timeout would be applicable).
The bug is in the error handling. The transaction rollback assumes that the caller is not holding dict_sys.latch in any mode.
We must ensure that no DDL operation in 10.6 may hold dict_sys.latch while executing transaction rollback. CREATE…SELECT is quite different from everything else, and the logic was rewritten in 10.6 in order to achieve Atomic DDL.
People
Marko Mäkelä
Elena Stepanova
Votes:
0Vote for this issue
Watchers:
3Start watching this issue
Dates
Created:
Updated:
Resolved:
Git Integration
Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.
{"report":{"fcp":1303.1999998092651,"ttfb":299.3999996185303,"pageVisibility":"visible","entityId":132060,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"12c0cf26-aede-475c-a1bb-5f2c15fdfc40","navigationType":0,"readyForUser":1465.3999996185303,"redirectCount":0,"resourceLoadedEnd":1364.3999996185303,"resourceLoadedStart":304.3999996185303,"resourceTiming":[{"duration":311.6000003814697,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":304.3999996185303,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":304.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":616,"responseStart":0,"secureConnectionStart":0},{"duration":311.59999990463257,"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":304.69999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":304.69999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":616.2999997138977,"responseStart":0,"secureConnectionStart":0},{"duration":319.80000019073486,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":304.8999996185303,"connectEnd":304.8999996185303,"connectStart":304.8999996185303,"domainLookupEnd":304.8999996185303,"domainLookupStart":304.8999996185303,"fetchStart":304.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":304.8999996185303,"responseEnd":624.6999998092651,"responseStart":624.6999998092651,"secureConnectionStart":304.8999996185303},{"duration":597.4000000953674,"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":305.09999990463257,"connectEnd":305.09999990463257,"connectStart":305.09999990463257,"domainLookupEnd":305.09999990463257,"domainLookupStart":305.09999990463257,"fetchStart":305.09999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":305.09999990463257,"responseEnd":902.5,"responseStart":902.3999996185303,"secureConnectionStart":305.09999990463257},{"duration":601.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":305.2999997138977,"connectEnd":305.2999997138977,"connectStart":305.2999997138977,"domainLookupEnd":305.2999997138977,"domainLookupStart":305.2999997138977,"fetchStart":305.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":305.2999997138977,"responseEnd":906.7999997138977,"responseStart":906.7999997138977,"secureConnectionStart":305.2999997138977},{"duration":602.2000002861023,"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":305.3999996185303,"connectEnd":305.3999996185303,"connectStart":305.3999996185303,"domainLookupEnd":305.3999996185303,"domainLookupStart":305.3999996185303,"fetchStart":305.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":305.3999996185303,"responseEnd":907.5999999046326,"responseStart":907.5999999046326,"secureConnectionStart":305.3999996185303},{"duration":602.4000000953674,"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":305.59999990463257,"connectEnd":305.59999990463257,"connectStart":305.59999990463257,"domainLookupEnd":305.59999990463257,"domainLookupStart":305.59999990463257,"fetchStart":305.59999990463257,"redirectEnd":0,"redirectStart":0,"requestStart":305.59999990463257,"responseEnd":908,"responseStart":908,"secureConnectionStart":305.59999990463257},{"duration":602.9000000953674,"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":305.7999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":305.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":908.6999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":602.6000003814697,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":305.8999996185303,"connectEnd":305.8999996185303,"connectStart":305.8999996185303,"domainLookupEnd":305.8999996185303,"domainLookupStart":305.8999996185303,"fetchStart":305.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":305.8999996185303,"responseEnd":908.5,"responseStart":908.5,"secureConnectionStart":305.8999996185303},{"duration":603.5,"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":306.19999980926514,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":306.19999980926514,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":909.6999998092651,"responseStart":0,"secureConnectionStart":0},{"duration":602.8000001907349,"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":306.3999996185303,"connectEnd":306.3999996185303,"connectStart":306.3999996185303,"domainLookupEnd":306.3999996185303,"domainLookupStart":306.3999996185303,"fetchStart":306.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":306.3999996185303,"responseEnd":909.1999998092651,"responseStart":909.1999998092651,"secureConnectionStart":306.3999996185303},{"duration":986.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":312.3999996185303,"connectEnd":312.3999996185303,"connectStart":312.3999996185303,"domainLookupEnd":312.3999996185303,"domainLookupStart":312.3999996185303,"fetchStart":312.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":312.3999996185303,"responseEnd":1299.1999998092651,"responseStart":1299.1999998092651,"secureConnectionStart":312.3999996185303},{"duration":1051.5999999046326,"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":312.7999997138977,"connectEnd":312.7999997138977,"connectStart":312.7999997138977,"domainLookupEnd":312.7999997138977,"domainLookupStart":312.7999997138977,"fetchStart":312.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":312.7999997138977,"responseEnd":1364.3999996185303,"responseStart":1364.3999996185303,"secureConnectionStart":312.7999997138977},{"duration":482.69999980926514,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":798.0999999046326,"connectEnd":798.0999999046326,"connectStart":798.0999999046326,"domainLookupEnd":798.0999999046326,"domainLookupStart":798.0999999046326,"fetchStart":798.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":798.0999999046326,"responseEnd":1280.7999997138977,"responseStart":1280.7999997138977,"secureConnectionStart":798.0999999046326},{"duration":457.7999997138977,"initiatorType":"script","name":"https://www.google-analytics.com/analytics.js","startTime":1260.5,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":1260.5,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1718.2999997138977,"responseStart":0,"secureConnectionStart":0}],"fetchStart":1,"domainLookupStart":1,"domainLookupEnd":1,"connectStart":1,"connectEnd":1,"requestStart":114,"responseStart":300,"responseEnd":313,"domLoading":303,"domInteractive":1784,"domContentLoadedEventStart":1784,"domContentLoadedEventEnd":1840,"domComplete":2450,"loadEventStart":2450,"loadEventEnd":2450,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":1758.0999999046326},{"name":"bigPipe.sidebar-id.end","time":1759.0999999046326},{"name":"bigPipe.activity-panel-pipe-id.start","time":1759.2999997138977},{"name":"bigPipe.activity-panel-pipe-id.end","time":1761.5},{"name":"activityTabFullyLoaded","time":1856.5}],"measures":[],"correlationId":"1883b44ee7ac14","effectiveType":"4g","downlink":9.4,"rtt":0,"serverDuration":117,"dbReadsTimeInMs":12,"dbConnsTimeInMs":21,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}
The patch looks functionally correct. I have one improvement suggestion. I think the root cause of the issue is setting dict_operation_lock_mode much earlier to releasing the dict sys lock.
1. Move trx->dict_operation_lock_mode= false; down while unlocking the dictionary.
2. Improve [1] by calling row_mysql_unlock_data_dictionary instead of dict_sys.unlock(); to unset dict_operation_lock_mode together.