[MDEV-31776] Online ALTER reports the number of affected rows incorrectly Created: 2023-07-25  Updated: 2023-08-16  Resolved: 2023-08-16

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Alter Table
Affects Version/s: N/A
Fix Version/s: 11.2.1

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Nikita Malyavin
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-16329 Engine-independent online ALTER TABLE Closed

 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.



 Comments   
Comment by Sergei Golubchik [ 2023-08-04 ]

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

Comment by Nikita Malyavin [ 2023-08-07 ]

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.

Comment by Sergei Golubchik [ 2023-08-07 ]

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.

Generated at Thu Feb 08 10:26:23 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.