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

mysqlimport -l doesn't issue UNLOCK TABLES

Details

    • 10.2.4-4, 10.2.4-1

    Description

      It wasn't a problem before MDEV-7660. With MDEV-7660 LOCK TABLES now starts transaction and this feature is generally broken, because transaction is rolled back on disconnect.

      Attachments

        Issue Links

          Activity

            For backward compatibility we will implement a special handling for transactions implicitly opened by LOCK TABLES. These transactions will be committed on disconnect, not rolled back,

            serg Sergei Golubchik added a comment - For backward compatibility we will implement a special handling for transactions implicitly opened by LOCK TABLES. These transactions will be committed on disconnect, not rolled back,

            Problem #1 (solvable, but confusing):

            We have to consider autocommit setting that was before LOCK TABLES when deciding whether to commit or rollback transaction.

            Disconnect must commit transaction:

            SET @@autocommit=1;
            LOCK TABLE t1 WRITE;
            

            Disconnect must rollback transaction:

            SET @@autocommit=0;
            LOCK TABLE t1 WRITE;
            

            The latter example is from http://dev.mysql.com/doc/refman/5.7/en/lock-tables-and-transactions.html

            svoj Sergey Vojtovich added a comment - Problem #1 (solvable, but confusing): We have to consider autocommit setting that was before LOCK TABLES when deciding whether to commit or rollback transaction. Disconnect must commit transaction: SET @@autocommit=1; LOCK TABLE t1 WRITE; Disconnect must rollback transaction: SET @@autocommit=0; LOCK TABLE t1 WRITE; The latter example is from http://dev.mysql.com/doc/refman/5.7/en/lock-tables-and-transactions.html
            svoj Sergey Vojtovich added a comment - - edited

            Problem #2 (not completely related):

            COMMIT now breaks lock:

            CREATE TABLE t1(a INT) ENGINE=InnoDB;
            SET @@autocommit=0;
            LOCK TABLE t1 READ;
            connect(con1, localhost, root);
            send INSERT INTO t1 VALUES(1);
            connection default;
            COMMIT;
            --sleep 1
            SELECT * FROM t1;
            UNLOCK TABLES;
            connection con1;
            reap;
            disconnect con1;
            connection default;
            DROP TABLE t1;
            

            Before MDEV-7660 SELECT didn't see "1", now it sees.
            BUT if t1 is write locked, COMMIT doesn't break lock and thus "1" is not visible.

            svoj Sergey Vojtovich added a comment - - edited Problem #2 (not completely related): COMMIT now breaks lock: CREATE TABLE t1(a INT ) ENGINE=InnoDB; SET @@autocommit=0; LOCK TABLE t1 READ ; connect (con1, localhost, root); send INSERT INTO t1 VALUES (1); connection default ; COMMIT ; --sleep 1 SELECT * FROM t1; UNLOCK TABLES; connection con1; reap; disconnect con1; connection default ; DROP TABLE t1; Before MDEV-7660 SELECT didn't see "1", now it sees. BUT if t1 is write locked, COMMIT doesn't break lock and thus "1" is not visible.
            elenst Elena Stepanova added a comment - - edited

            Problem #2 extension (it might be unrelated to the disconnect issue, but it's definitely related to the root cause)

            • ROLLBACK now breaks lock;
            • statements which cause implicit commit can now break lock, e.g. ANALYZE TABLE !

            Problem #3

            This does not work anymore:

            --source include/have_log_bin.inc
             
            SET SESSION BINLOG_FORMAT=ROW;
            CREATE TABLE t11 (song VARCHAR(255));
            LOCK TABLES t11 WRITE;
            INSERT INTO t11 VALUES('Several Species');
            SET SESSION BINLOG_FORMAT=STATEMENT;
            INSERT INTO t11 VALUES('Careful');
            UNLOCK TABLES;
            

            At line 7: query 'SET SESSION BINLOG_FORMAT=STATEMENT' failed: 1679: Cannot modify @@session.binlog_format inside a transaction
            

            I'm sure there are many more surprises.

            serg, again, given all the above, I beg to reconsider. Yes, I suppose every single issue can be solved by some cumbersome workaround, or declared as non-essential, but the sheer amount of incompatibilities that we introduce just does not make sense. Even if it were the only way to implement the desired optimization, it would still be very questionable, but to my understanding, svoj had an alternative solution which wasn't supposed to cause all of this, but it was discarded. Maybe it could be revived?

            elenst Elena Stepanova added a comment - - edited Problem #2 extension (it might be unrelated to the disconnect issue, but it's definitely related to the root cause) ROLLBACK now breaks lock; statements which cause implicit commit can now break lock, e.g. ANALYZE TABLE ! Problem #3 This does not work anymore: --source include/have_log_bin.inc   SET SESSION BINLOG_FORMAT=ROW; CREATE TABLE t11 (song VARCHAR (255)); LOCK TABLES t11 WRITE; INSERT INTO t11 VALUES ( 'Several Species' ); SET SESSION BINLOG_FORMAT=STATEMENT; INSERT INTO t11 VALUES ( 'Careful' ); UNLOCK TABLES; At line 7: query 'SET SESSION BINLOG_FORMAT=STATEMENT' failed: 1679: Cannot modify @@session.binlog_format inside a transaction I'm sure there are many more surprises. serg , again, given all the above, I beg to reconsider. Yes, I suppose every single issue can be solved by some cumbersome workaround, or declared as non-essential, but the sheer amount of incompatibilities that we introduce just does not make sense. Even if it were the only way to implement the desired optimization, it would still be very questionable, but to my understanding, svoj had an alternative solution which wasn't supposed to cause all of this, but it was discarded. Maybe it could be revived?

            serg, please review fix for this bug.

            svoj Sergey Vojtovich added a comment - serg , please review fix for this bug.

            People

              svoj Sergey Vojtovich
              svoj Sergey Vojtovich
              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.