[MDEV-25236] Online log apply fails for redundant row format tables Created: 2021-03-24  Updated: 2023-03-14  Resolved: 2021-07-02

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.4, 10.5, 10.6
Fix Version/s: 10.4.21, 10.5.12, 10.6.3

Type: Bug Priority: Major
Reporter: Thirunarayanan Balathandayuthapani Assignee: Thirunarayanan Balathandayuthapani
Resolution: Fixed Votes: 0
Labels: rr-profile-analyzed

Issue Links:
Problem/Incident
causes MDEV-26198 Assertion `0' failed in row_log_table... Closed
is caused by MDEV-15563 Instant failure-free data type conver... Closed

 Description   

In rec_get_converted_size_comp_prefix_low(), InnoDB calculates extra bytes
for null bytes using index->n_core_null_bytes field. But in
rec_convert_dtuple_to_rec_comp(), InnoDB traverse to null bytes
using index->n_nullable field. In the given scenario, index->n_core_null_bytes
is 1 and index->n_nullable is 9 and it doesn't fit in single byte.
Moreover, n_core_null_bytes indicates the number of null bits in non-redundant
format when table is not instant. Problem exist from 10.3+. But
the given test case repeats from 10.4+

 
--source include/have_innodb.inc
CREATE TABLE IF NOT EXISTS t4 ( col1 INT, col2 INT, col_int INTEGER, col_string INTEGER, col_varchar VARCHAR(500), col_text TEXT ) ENGINE = InnoDB ROW_FORMAT = REDUNDANT;
ALTER TABLE t4 ADD PRIMARY KEY ( col_text(9), col_int );
ALTER TABLE t4 ADD COLUMN col_int_copy INTEGER;
ALTER TABLE t4 DROP PRIMARY KEY;
ALTER TABLE t4 ADD COLUMN col_text_copy TEXT;
ALTER TABLE t4 ADD PRIMARY KEY ( col_text(9), col_int );
ALTER TABLE t4 ADD COLUMN col_inTcol_int INTEGER;
ALTER TABLE t4 DROP PRIMARY KEY;
ALTER TABLE t4 ADD COLUMN col_texTcol_text TEXT;
ALTER TABLE t4 ADD PRIMARY KEY ( col_text(9), col_int );
ALTER TABLE t4 DROP PRIMARY KEY;
ALTER TABLE t4 MODIFY COLUMN col_text TEXT;
 
set DEBUG_SYNC="innodb_inplace_alter_table_enter SIGNAL alter_phase WAIT_FOR alter_finish";
--send ALTER TABLE t4 ADD PRIMARY KEY ( col_text(9), col_int )
connect(con1,localhost,root,,);
set DEBUG_SYNC="now WAIT_FOR alter_phase";
begin;
INSERT INTO t4 (col1,col2, col_int, col_string, col_text) VALUES ( 1, 1, 0, REPEAT(SUBSTR(CAST( 1 AS CHAR),1,1), 10), REPEAT(SUBSTR(CAST( 1 AS CHAR),1,1), 10000) );
rollback;
set DEBUG_SYNC="now SIGNAL alter_finish";
 
connection default;
reap;
disconnect con1;
select * from t4;
drop table t4;
set debug_sync=reset;

Run the above test case with --innodb_page_size=64K --innodb_buffer_pool_size=24M



 Comments   
Comment by Thirunarayanan Balathandayuthapani [ 2021-04-26 ]

Patch is in bb-10.4-thiru

Comment by Marko Mäkelä [ 2021-04-27 ]

I think that we must a second template parameter bool redundant_temp to rec_init_offsets_comp_ordinary(), like we already have it in rec_get_converted_size_comp_prefix_low().

If redundant_temp==true, we must do something special for !index->table->not_redundant() (the online_log record is in a different format). Else, we must assert that index->table->not_redundant() holds.

The test innodb.instant_alter_crash is supposed to test crash recovery. For this test, innodb.instant_alter_debug would be a better match. Please remove ROW_FORMAT=REDUNDANT from the test case, because that test runs with two combinations of innodb_default_row_format.

Comment by Thirunarayanan Balathandayuthapani [ 2021-05-17 ]

Problem happens only in 10.4. Modify column does instant operation only in 10.4+. This issue is caused by MDEV-15563.
so moving the affected version to 10.4

Comment by Marko Mäkelä [ 2021-07-02 ]

I spent some time creating a simpler test case. We need 9 columns, and 8 of them can be INT. Only 2 ALTER TABLE statements are necessary.

The code fix itself is fine, and 10.3 is not affected because it is missing MDEV-15563.

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