[MDEV-25054] Innodb inbuilt cache behaving strangely for indexed virtual columns Created: 2021-03-04  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.4, 10.5
Fix Version/s: 10.4, 10.5

Type: Bug Priority: Major
Reporter: Sachin Setiya (Inactive) Assignee: Nikita Malyavin
Resolution: Unresolved Votes: 0
Labels: None
Environment:

Ubuntu 20.04



 Description   

When Innodb rows are read from prebuilt cache, sometimes wrong result is returned for table->record[0] (null bits).

Test Case (for 10.4, 10.5 (with 10.5 debug build it fails more frequently))

--source include/have_innodb.inc
CREATE TABLE t1 (id INT, f TEXT UNIQUE, d DATE, PRIMARY KEY (id)) ENGINE=InnoDB;
INSERT INTO t1 VALUES
    (1,NULL,'2001-11-16'),(2,NULL,'2007-07-01'),(3,NULL,'2020-02-03'),
    (4,NULL,'1971-05-24'),(5,NULL,'1971-05-24'),(6,NULL,'1985-02-07');
ANALYZE TABLE t1 PERSISTENT FOR ALL;
# Cleanup
DROP TABLE t1;

In above test case not all table fields are read. Analyze table does not read blob columns
(Please note we will have 4 fields 4th will be hidden DB_ROW_HASH1 (storing hash for column f))

Table read_set
(rr) p/t *args[0]->field->table->read_set->bitmap
$2 = 1101

Good table record

(rr) x/26tb args[0]->field->table->record[0]
0x7f28182205b8: 11111101        00000101        00000000        00000000        00000000        00000000        00000000
 00000000
0x7f28182205c0: 00000000        00000000        00000000        00000000        00000000        00000000        00000000
 10111000
0x7f28182205c8: 01100110        00001111        00000000        00000000        00000000        00000000        00000000
 00000000
0x7f28182205d0: 00000000        00000000

While reading the last column sometime we are given bad result from record[0] null_bits

(rr) x/26tb args[0]->field->table->record[0]
0x7f28182205b8: 00101000        00000110        00000000        00000000        00000000        10001111        10001111
 10001111
0x7f28182205c0: 10001111        10001111        10001111        10001111        10001111        10001111        10001111
 01000111
0x7f28182205c8: 10000010        00001111        00000000        00000000        00000000        00000000        00000000
 00000000
0x7f28182205d0: 00000000        00000000

Notice the first byte 00101000 , it is wrong


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