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

Online ALTER reports the number of affected rows incorrectly

Details

    Description

      --source include/have_debug_sync.inc
       
      create table t (a int);
      insert into t values (1),(2);
      --send set debug_sync= 'now wait_for go_dml'
       
      --connect (con1,localhost,root,,)
      set debug_sync='alter_table_online_progress signal go_dml wait_for go_alter';
      --send alter table t add b int, algorithm=copy, lock=none
       
      --connection default
      --reap
      insert into t values (3);
      set debug_sync= 'now signal go_alter';
       
      --connection con1
      --enable_info
      --reap
      --disable_info
      select * from t;
       
      # Cleanup
      drop table t;
      

      bb-11.2-oalter b0484157ecd33e153e181d9ca4c055b82046ffea

      connect  con1,localhost,root,,;
      set debug_sync='alter_table_online_progress signal go_dml wait_for go_alter';
      alter table t add b int, algorithm=copy, lock=none;
      connection default;
      insert into t values (3);
      set debug_sync= 'now signal go_alter';
      connection con1;
      affected rows: 2
      info: Records: 2  Duplicates: 0  Warnings: 0
      select * from t;
      a	b
      1	NULL
      2	NULL
      3	NULL
      

      So, ALTER reports 2 affected rows (the number before DML), while it obviously affects 3.

      Attachments

        Issue Links

          Activity

            looks ok. although I recommend to rename online_alter_update_row_countupdate_row_count, there's nothing in the logic of this method that's specific to the online alter

            serg Sergei Golubchik added a comment - looks ok. although I recommend to rename online_alter_update_row_count → update_row_count , there's nothing in the logic of this method that's specific to the online alter

            I disagree, serg. Normally, for example, Delete_log_event, would increase the number of rows affected (in the statement). Here we actually want to know the number of resulting rows in the new table. So then delete decreases, and update doesn't change.

            nikitamalyavin Nikita Malyavin added a comment - I disagree, serg . Normally, for example, Delete_log_event, would increase the number of rows affected (in the statement). Here we actually want to know the number of resulting rows in the new table . So then delete decreases, and update doesn't change.

            sure, that's what I meant too. your "update_row_count" method updates the number of rows in the table. Delete_row_event always decreases this number of rows, not only in online alter.

            serg Sergei Golubchik added a comment - sure, that's what I meant too. your "update_row_count" method updates the number of rows in the table. Delete_row_event always decreases this number of rows, not only in online alter.

            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.