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

ER_KEY_NOT_FOUND upon concurrent CHANGE column to autoinc and DML

Details

    Description

      Notes:

      • A fix for MDEV-31043 is already in the branch. Besides, this time the failure affects transactional engines as well, reproducible with at least InnoDB, MyISAM, Aria, HEAP.
      • The test case is non-deterministic, run with --repeat=N. It fails for me on almost every attempt, but it can vary on different machines and builds.
      • The second table (t2) seems to be important somehow, at least I couldn't replace its operation with just a sleep.

      --source include/have_sequence.inc
       
      CREATE TABLE t1 (b int);
      INSERT INTO t1 VALUES (0),(0);
       
      CREATE TABLE t2 (a int);
      INSERT INTO t2 (a) select seq from seq_1_to_128;
       
      --connect (con1,localhost,root,,)
      --send
        ALTER TABLE t1 MODIFY b SERIAL;
       
      --connection default
      DELETE FROM t2 ORDER BY a LIMIT 1;
      DELETE FROM t1 ORDER BY b LIMIT 2;
       
      --connection con1
      --reap
       
      # Cleanup
      DROP TABLE t1, t2;
      

      bb-11.0-oalter 6f5427417eff

      mysqltest: At line 18: query 'reap' failed: ER_KEY_NOT_FOUND (1032): Can't find record in 't1'
      

      Attachments

        Issue Links

          Activity

            serg Sergei Golubchik added a comment - - edited

            consider this example

            create table t1 (a int, b int);
            insert t1 values (1,NULL),(2,NULL),(3,NULL),(4,NULL);
            update t1 set b=10 where a=2;
            alter table t1 modify b int auto_increment, add key(b);
            select * from t1 order by a,b;
            drop table t1;
            

            it prints

            a       b
            1       1
            2       10
            3       11
            4       12
            

            I don't understand how it could be even possible to do the above online.
            If I recall correctly, conceptually online alter should produce the same result as if all concurrent updates were done before the alter.

            serg Sergei Golubchik added a comment - - edited consider this example create table t1 (a int , b int ); insert t1 values (1, NULL ),(2, NULL ),(3, NULL ),(4, NULL ); update t1 set b=10 where a=2; alter table t1 modify b int auto_increment, add key (b); select * from t1 order by a,b; drop table t1; it prints a b 1 1 2 10 3 11 4 12 I don't understand how it could be even possible to do the above online. If I recall correctly, conceptually online alter should produce the same result as if all concurrent updates were done before the alter.

            Right, if we stick to taking effect after the changes applied, then this method won't work

            nikitamalyavin Nikita Malyavin added a comment - Right, if we stick to taking effect after the changes applied, then this method won't work

            But of course. A user does SELECT — sees the old table structure. Performs UPDATE, commits, runs SELECT again — sees the old table structure, with the updated content. There's no other way to interpret it, the UPDATE was applied to the old table structure, before the ALTER.

            serg Sergei Golubchik added a comment - But of course. A user does SELECT — sees the old table structure. Performs UPDATE , commits, runs SELECT again — sees the old table structure, with the updated content. There's no other way to interpret it, the UPDATE was applied to the old table structure, before the ALTER .

            db2d411bc is obsolete, it seems, because d23555b19206 (MDEV-30984) rewrites it.

            I've already commented on d23555b19206, so there's no need to review db2d411bc anymore.

            serg Sergei Golubchik added a comment - db2d411bc is obsolete, it seems, because d23555b19206 ( MDEV-30984 ) rewrites it. I've already commented on d23555b19206, so there's no need to review db2d411bc anymore.

            Well, yes, it can be done so, almost. Thanks. the commit could be useful to understand the intentions at first place, but I can squash it

            nikitamalyavin Nikita Malyavin added a comment - Well, yes, it can be done so, almost. Thanks. the commit could be useful to understand the intentions at first place, but I can squash it

            People

              nikitamalyavin Nikita Malyavin
              elenst Elena Stepanova
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start 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.