From 8f771b28a152b95abc0b1c5ab22fa62b09f7781b Mon Sep 17 00:00:00 2001 From: Monty Date: Thu, 4 Sep 2025 17:05:52 +0300 Subject: [PATCH] MDEV-34914 maria.bulk_insert_crash fails on s390x (10.6+, Debug) This was caused by a wrong handling of bitmaps in copy_not_changed_fields() that did not work on big endian machines. This bug caused recovery of Aria files to fail on big endian machines like s390x or Sparc. This issue was noticed by the bulk_insert_crash.test on the s390x builder. --- mysql-test/suite/maria/bulk_insert_crash.result | 3 +++ mysql-test/suite/maria/bulk_insert_crash.test | 2 ++ storage/maria/aria_read_log.c | 1 + storage/maria/ma_blockrec.c | 12 +++--------- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mysql-test/suite/maria/bulk_insert_crash.result b/mysql-test/suite/maria/bulk_insert_crash.result index 0cf5a474939..c827a579cfb 100644 --- a/mysql-test/suite/maria/bulk_insert_crash.result +++ b/mysql-test/suite/maria/bulk_insert_crash.result @@ -1,6 +1,9 @@ create table t1 (a int primary key, b int, c int, unique key(b), key(c)) engine=aria transactional=1; insert into t1 values (1000,1000,1000); insert into t1 select seq,seq+100, seq+200 from seq_1_to_10; +select sum(a),sum(b),sum(c) from t1; +sum(a) sum(b) sum(c) +1055 2055 3055 SET GLOBAL debug_dbug="+d,crash_end_bulk_insert"; REPLACE into t1 select seq+20,seq+95, seq + 300 from seq_1_to_10; ERROR HY000: Lost connection to server during query diff --git a/mysql-test/suite/maria/bulk_insert_crash.test b/mysql-test/suite/maria/bulk_insert_crash.test index 04f3a148ad4..30fbd802fed 100644 --- a/mysql-test/suite/maria/bulk_insert_crash.test +++ b/mysql-test/suite/maria/bulk_insert_crash.test @@ -18,6 +18,8 @@ create table t1 (a int primary key, b int, c int, unique key(b), key(c)) engine= insert into t1 values (1000,1000,1000); insert into t1 select seq,seq+100, seq+200 from seq_1_to_10; +select sum(a),sum(b),sum(c) from t1; + # Insert into t1 with batch insert where we get a rows replaced after # a few sucessful inserts diff --git a/storage/maria/aria_read_log.c b/storage/maria/aria_read_log.c index cfb592561c3..eec2cc10483 100644 --- a/storage/maria/aria_read_log.c +++ b/storage/maria/aria_read_log.c @@ -199,6 +199,7 @@ err: /* don't touch anything more, in case we hit a bug */ fprintf(stderr, "%s: FAILED\n", my_progname_short); free_tmpdir(&maria_chk_tmpdir); + my_hash_free(&tables_to_redo); free_defaults(default_argv); exit(1); } diff --git a/storage/maria/ma_blockrec.c b/storage/maria/ma_blockrec.c index 561cc324ed1..d8cfca1bcfc 100644 --- a/storage/maria/ma_blockrec.c +++ b/storage/maria/ma_blockrec.c @@ -953,14 +953,13 @@ void copy_not_changed_fields(MARIA_HA *info, MY_BITMAP *changed_fields, uchar *to, uchar *from) { MARIA_COLUMNDEF *column, *end_column; - uchar *bitmap= (uchar*) changed_fields->bitmap; MARIA_SHARE *share= info->s; - uint bit= 1; + uint bit= 0; for (column= share->columndef, end_column= column+ share->base.fields; - column < end_column; column++) + column < end_column; column++, bit++) { - if (!(*bitmap & bit)) + if (!bitmap_is_set(changed_fields, bit)) { uint field_length= column->length; if (column->type == FIELD_VARCHAR) @@ -972,11 +971,6 @@ void copy_not_changed_fields(MARIA_HA *info, MY_BITMAP *changed_fields, } memcpy(to + column->offset, from + column->offset, field_length); } - if ((bit= (bit << 1)) == 256) - { - bitmap++; - bit= 1; - } } }