Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-41010

err == DB_SUCCESS || err == DB_LOCK_WAIT || err == DB_DEADLOCK || err == DB_LOCK_WAIT_TIMEOUT in row_upd_sec_index_entry on interrupted UPDATE of an FK column w/ wsrep

    XMLWordPrintable

Details

    Description

      On a Galera node, an UPDATE that changes a foreign key column runs a foreign key check while it delete-marks the old secondary index entry. When the query is interrupted while that check waits for a lock on the parent row, the check returns "Operation interrupted". That value is logged and left unchanged, and the assertion below the call does not allow it, so a debug build aborts. An optimised build logs the same line at ERROR level and continues.

      Both parts are needed. With the foreign key removed the same UPDATE completes. With the interrupt removed the lock wait ends in a timeout, which the assertion allows. It was first seen under concurrent foreign key writes on a three node cluster. The testcase below uses max_statement_time to interrupt the query at the same point. That makes the issue less sporadic, and it avoids the need for debug_sync. The testcase remains lightly sporadic.

      MTR Testcase:

      --source include/galera_cluster.inc
      --connection node_1
      CREATE TABLE p (id INT PRIMARY KEY, v INT) ENGINE=InnoDB;
      CREATE TABLE c (id INT PRIMARY KEY, pid INT NOT NULL, KEY k (pid), FOREIGN KEY (pid) REFERENCES p (id)) ENGINE=InnoDB;
      INSERT INTO p VALUES (1, 0), (2, 0);
      INSERT INTO c VALUES (1, 1);
      --connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
      --connection node_1a
      BEGIN;
      UPDATE p SET v = v + 1 WHERE id = 1;
      --connect node_1b, 127.0.0.1, root, , test, $NODE_MYPORT_1
      --connection node_1b
      SET SESSION max_statement_time = 1;
      --error 0,ER_STATEMENT_TIMEOUT,ER_LOCK_DEADLOCK,ER_LOCK_WAIT_TIMEOUT,ER_QUERY_INTERRUPTED
      UPDATE c SET pid = 2 WHERE id = 1;
      --connection node_1a
      ROLLBACK;
      --connection node_1
      DROP TABLE c;
      DROP TABLE p;
      

      Leads to:

      ES 10.6.28-24 fcecb2620f25965723d640decede7c018bcb1dcc (Debug, Clang 22.1.8-20260622) Build 18/08/2026

      mariadbd: /test/10.6-es_dbg/storage/innobase/row/row0upd.cc:1989: dberr_t row_upd_sec_index_entry(upd_node_t *, que_thr_t *): Assertion `err == DB_SUCCESS || err == DB_LOCK_WAIT || err == DB_DEADLOCK || err == DB_LOCK_WAIT_TIMEOUT' failed.
      

      ES 10.6.28-24 fcecb2620f25965723d640decede7c018bcb1dcc (Debug, Clang 22.1.8-20260622) Build 18/08/2026

      Core was generated by `/test/EMD180826-mariadb-10.6.28-24-linux-x86_64-dbg/bin/mariadbd --defaults-gro'.
      Program terminated with signal SIGABRT, Aborted.
      #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
       
      [Current thread is 1 (LWP 2407606)]
      (gdb) bt
      #0  __pthread_kill_implementation (no_tid=0, signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:44
      #1  __pthread_kill_internal (signo=6, threadid=<optimized out>)at ./nptl/pthread_kill.c:78
      #2  __GI___pthread_kill (threadid=<optimized out>, signo=signo@entry=6)at ./nptl/pthread_kill.c:89
      #3  0x00007ae67ba4527e in __GI_raise (sig=sig@entry=6)at ../sysdeps/posix/raise.c:26
      #4  0x00007ae67ba288ff in __GI_abort () at ./stdlib/abort.c:79
      #5  0x00007ae67ba2881b in __assert_fail_base (fmt=0x7ae67bbd01e8 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=assertion@entry=0x56d4d0a79f77 "err == DB_SUCCESS || err == DB_LOCK_WAIT || err == DB_DEADLOCK || err == DB_LOCK_WAIT_TIMEOUT", file=file@entry=0x56d4d0a78984 "/test/10.6-es_dbg/storage/innobase/row/row0upd.cc", line=line@entry=1989, function=function@entry=0x56d4d0a79ed7 "dberr_t row_upd_sec_index_entry(upd_node_t *, que_thr_t *)") at ./assert/assert.c:96
      #6  0x00007ae67ba3b517 in __assert_fail (assertion=0x56d4d0a79f77 "err == DB_SUCCESS || err == DB_LOCK_WAIT || err == DB_DEADLOCK || err == DB_LOCK_WAIT_TIMEOUT", file=0x56d4d0a78984 "/test/10.6-es_dbg/storage/innobase/row/row0upd.cc", line=1989, function=0x56d4d0a79ed7 "dberr_t row_upd_sec_index_entry(upd_node_t *, que_thr_t *)") at ./assert/assert.c:105
      #7  0x000056d4d05c5b5b in row_upd_sec_index_entry (node=0x72e4e405ee08, thr=0x72e4c4021aa0)at /test/10.6-es_dbg/storage/innobase/row/row0upd.cc:1988
      #8  0x000056d4d05c0457 in row_upd_sec_step (node=0x72e4e405ee08, thr=0x72e4c4021aa0)at /test/10.6-es_dbg/storage/innobase/row/row0upd.cc:2054
      #9  0x000056d4d05be64d in row_upd (node=0x72e4e405ee08, thr=0x72e4c4021aa0)at /test/10.6-es_dbg/storage/innobase/row/row0upd.cc:2801
      #10 0x000056d4d05be2d0 in row_upd_step (thr=0x72e4c4021aa0)at /test/10.6-es_dbg/storage/innobase/row/row0upd.cc:2916
      #11 0x000056d4d0565706 in row_update_for_mysql (prebuilt=0x72e4e405e410)at /test/10.6-es_dbg/storage/innobase/row/row0mysql.cc:1667
      #12 0x000056d4d0397722 in ha_innobase::update_row (this=0x72e4e405c388, old_row=0x72e4e405cb98 "\377\001", new_row=0x72e4e405cb88 "\377\001")at /test/10.6-es_dbg/storage/innobase/handler/ha_innodb.cc:8565
      #13 0x000056d4cfffc0e4 in handler::ha_update_row (this=0x72e4e405c388, old_data=0x72e4e405cb98 "\377\001", new_data=0x72e4e405cb88 "\377\001")at /test/10.6-es_dbg/sql/handler.cc:7864
      #14 0x000056d4cfd959f8 in mysql_update (thd=0x72e4c4001ea8, table_list=0x72e4c40146c0, fields=@0x72e4c4006ba0: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x72e4c4014f80, last = 0x72e4c4014f80, elements = 1}, <No data fields>}, values=@0x72e4c4007000: {<base_list> = {<Sql_alloc> = {<No data fields>}, first = 0x72e4c4014f90, last = 0x72e4c4014f90, elements = 1}, <No data fields>}, conds=0x72e4c4015140, order_num=0, order=0x0, limit=18446744073709551615, ignore=false, found_return=0x7ae6783d8f88, updated_return=0x7ae6783d8f80)at /test/10.6-es_dbg/sql/sql_update.cc:1116
      #15 0x000056d4cfc5ee9c in mysql_execute_command (thd=0x72e4c4001ea8, is_called_from_prepared_stmt=false)at /test/10.6-es_dbg/sql/sql_parse.cc:4493
      #16 0x000056d4cfc55a38 in mysql_parse (thd=0x72e4c4001ea8, rawbuf=0x72e4c40145d0 "UPDATE c SET pid = 2 WHERE id = 1", length=33, parser_state=0x7ae6783d9a28) at /test/10.6-es_dbg/sql/sql_parse.cc:8228
      #17 0x000056d4cfc57aed in wsrep_mysql_parse (thd=0x72e4c4001ea8, rawbuf=0x72e4c40145d0 "UPDATE c SET pid = 2 WHERE id = 1", length=33, parser_state=0x7ae6783d9a28) at /test/10.6-es_dbg/sql/sql_parse.cc:8039
      #18 0x000056d4cfc530ee in dispatch_command (command=COM_QUERY, thd=0x72e4c4001ea8, packet=0x72e4c400c029 "UPDATE c SET pid = 2 WHERE id = 1", packet_length=33, blocking=true) at /test/10.6-es_dbg/sql/sql_parse.cc:1905
      #19 0x000056d4cfc564df in do_command (thd=0x72e4c4001ea8, blocking=true)at /test/10.6-es_dbg/sql/sql_parse.cc:1428
      #20 0x000056d4cfe047ae in do_handle_one_connection (connect=0x56d4e364d1d8, put_in_cache=true) at /test/10.6-es_dbg/sql/sql_connect.cc:1393
      #21 0x000056d4cfe04595 in handle_one_connection (arg=0x56d4e364d1d8)at /test/10.6-es_dbg/sql/sql_connect.cc:1305
      #22 0x00007ae67ba9cb84 in start_thread (arg=<optimized out>)at ./nptl/pthread_create.c:447
      #23 0x00007ae67bb29d6c in clone3 ()at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
      

      Bug Detection Matrix

          Rel    o/d  Build   Commit                                    Affected
      CS  10.11  dbg  180826  8f00e6caca633c783140db86d3a48a96de67cf38  err == DB_SUCCESS || err == DB_LOCK_WAIT || err == DB_DEADLOCK || err == DB_LOCK_WAIT_TIMEOUT|SIGABRT|row_upd_sec_index_entry|row_upd_sec_step|row_upd|row_upd_step
      CS  10.11  opt  180826  8f00e6caca633c783140db86d3a48a96de67cf38  TBD
      CS  11.4   dbg  180826  1a052f27e374fc9b4cb5b1fd098cf10f0e1381cc  err == DB_SUCCESS || err == DB_LOCK_WAIT || err == DB_DEADLOCK || err == DB_LOCK_WAIT_TIMEOUT|SIGABRT|row_upd_sec_index_entry|row_upd_sec_step|row_upd|row_upd_step
      CS  11.4   opt  180826  1a052f27e374fc9b4cb5b1fd098cf10f0e1381cc  TBD
      CS  11.8   dbg  180826  d26f9ab217a7fcf9d4eccc62c01020ff275ff42e  err == DB_SUCCESS || err == DB_LOCK_WAIT || err == DB_DEADLOCK || err == DB_LOCK_WAIT_TIMEOUT|SIGABRT|row_upd_sec_index_entry|row_upd_sec_step|row_upd|row_upd_step
      CS  11.8   opt  180826  d26f9ab217a7fcf9d4eccc62c01020ff275ff42e  TBD 
      CS  12.3   dbg  180826  add63991988734383c5e942de2a19c6c45f511f7  err == DB_SUCCESS || err == DB_LOCK_WAIT || err == DB_DEADLOCK || err == DB_LOCK_WAIT_TIMEOUT|SIGABRT|row_upd_sec_index_entry|row_upd_sec_step|row_upd|row_upd_step
      CS  12.3   opt  180826  add63991988734383c5e942de2a19c6c45f511f7  TBD
      CS  13.0   dbg  180826  a848493c6fe031f23606144420c1ca1e467cbd81  err == DB_SUCCESS || err == DB_LOCK_WAIT || err == DB_DEADLOCK || err == DB_LOCK_WAIT_TIMEOUT|SIGABRT|row_upd_sec_index_entry|row_upd_sec_step|row_upd|row_upd_step
      CS  13.0   opt  180826  a848493c6fe031f23606144420c1ca1e467cbd81  TBD
      CS  13.1   dbg  180826  da18481158c81ca94689702073c3e04aad85a6a3  err == DB_SUCCESS || err == DB_LOCK_WAIT || err == DB_DEADLOCK || err == DB_LOCK_WAIT_TIMEOUT|SIGABRT|row_upd_sec_index_entry|row_upd_sec_step|row_upd|row_upd_step
      CS  13.1   opt  180826  da18481158c81ca94689702073c3e04aad85a6a3  TBD
      ES  10.6   dbg  180826  fcecb2620f25965723d640decede7c018bcb1dcc  err == DB_SUCCESS || err == DB_LOCK_WAIT || err == DB_DEADLOCK || err == DB_LOCK_WAIT_TIMEOUT|SIGABRT|row_upd_sec_index_entry|row_upd_sec_step|row_upd|row_upd_step
      ES  10.6   opt  180826  fcecb2620f25965723d640decede7c018bcb1dcc  TBD
      ES  11.4   dbg  180826  3b34189bfe675c18c4ced3ef531d016ea74c76f4  err == DB_SUCCESS || err == DB_LOCK_WAIT || err == DB_DEADLOCK || err == DB_LOCK_WAIT_TIMEOUT|SIGABRT|row_upd_sec_index_entry|row_upd_sec_step|row_upd|row_upd_step
      ES  11.4   opt  180826  3b34189bfe675c18c4ced3ef531d016ea74c76f4  TBD
      ES  11.8   dbg  180826  4694e931d10fecf733c34f83ea2146d31b708eb3  err == DB_SUCCESS || err == DB_LOCK_WAIT || err == DB_DEADLOCK || err == DB_LOCK_WAIT_TIMEOUT|SIGABRT|row_upd_sec_index_entry|row_upd_sec_step|row_upd|row_upd_step
      ES  11.8   opt  180826  4694e931d10fecf733c34f83ea2146d31b708eb3  Yes
      ES  12.3   dbg  180826  f513f503feacabfb219d4a6f965b5f72b86d4db0  err == DB_SUCCESS || err == DB_LOCK_WAIT || err == DB_DEADLOCK || err == DB_LOCK_WAIT_TIMEOUT|SIGABRT|row_upd_sec_index_entry|row_upd_sec_step|row_upd|row_upd_step
      ES  12.3   opt  180826  f513f503feacabfb219d4a6f965b5f72b86d4db0  TBD
      

      Attachments

        Issue Links

          Activity

            People

              seppo Seppo Jaakola
              Roel Roel Van de Paar
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - Not Specified
                  Not Specified
                  Logged:
                  Time Spent - 0.5d
                  0.5d

                  Git Integration

                    Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.