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

Potential corruption on Foreign key update on a table with vcol index

Details

    Description

      I have added an assertion to ensure that the correct table is chosen in innodb_find_table_for_vc:

      --- a/storage/innobase/handler/ha_innodb.cc
      +++ b/storage/innobase/handler/ha_innodb.cc
      @@ -20007,6 +20007,9 @@
       	} else {
       		if (table->vc_templ->mysql_table_query_id
       		    == thd_get_query_id(thd)) {
      +			DEBUG_SYNC(thd, "find_table_for_vc_table_valid");
      +                        DBUG_ASSERT(table->vc_templ->mysql_table_query_id
      +                                    == thd_get_query_id(thd));
       			return table->vc_templ->mysql_table;
       		}
       	}
      

      This is important, since the table is thread-local data.

      The above assertion fails with the following test:

      --source include/have_debug_sync.inc
      --source include/have_innodb.inc
      --source include/have_sequence.inc
      --connect (con2, localhost, root,,)
      --connection default
      set default_storage_engine= innodb;
       
       
      create table t1 (a int primary key);
      insert into t1(a) select * from seq_1_to_65536;
      create table t2 (a int,  b int as (a), key(b), foreign key (a) references t1 (a)
        on delete cascade on update cascade);
      insert into t2(a) select * from seq_1_to_65536;
      set debug_sync= "find_table_for_vc_table_valid SIGNAL found WAIT_FOR go";
      --send
      UPDATE t1 set a = a + 1000000 where a <= 2;
      --connection con2
      set debug_sync= "now WAIT_FOR found TIMEOUT 3";
      UPDATE t1 set a= 330000 where a = 33333;
      set debug_sync= "now SIGNAL go";
       
      --connection default
      --reap
       
      # Cleanup
      drop table t2, t1;
      set debug_sync= reset;
      --connection default
      

      I believe we need enough rows to have more that one leaf page in the tree, to avoid a row lock timeout.

      The best way to fix it is to put mysql_table to a threadlocal data as well. A good place can be row_prebuilt_t (and table is already there): to access child prebuilt, parent prebuilt should contain references to it, we can fill it on open under certain conditions, or on demand

      Attachments

        Issue Links

          Activity

            Transition Time In Source Status Execution Times
            Nikita Malyavin made transition -
            Open In Progress
            8d 2h 12m 1
            Nikita Malyavin made transition -
            In Progress In Review
            18d 8m 1
            Nikita Malyavin made transition -
            Stalled In Progress
            66d 13h 7m 4
            Nikita Malyavin made transition -
            In Progress Stalled
            34d 17h 14m 4
            Nikita Malyavin made transition -
            Stalled In Review
            33d 6h 28m 3
            Nikita Malyavin made transition -
            In Review Stalled
            446d 7h 11m 4

            People

              nikitamalyavin Nikita Malyavin
              nikitamalyavin Nikita Malyavin
              Votes:
              1 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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