[MDEV-29674] History modification inserts records into a wrong partition without warning Created: 2022-09-30 Updated: 2022-10-21 |
|
| Status: | Stalled |
| Project: | MariaDB Server |
| Component/s: | Partitioning, Versioned Tables |
| Affects Version/s: | 10.11.1 |
| Fix Version/s: | 10.11 |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Sergei Golubchik |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||
| Description |
|
If a record is inserted into a versioned partitioned table with row end outside existing history partitions, no warning is produced, and the record is inserted into the last history partition. If the table is auto-partitioned, no partition is created. When the same operation is performed via timestamp modification, a warning is thrown, or auto-partitions are created.
With timestamp modification instead of insert_history:
For "doesn't produce/produces a warning" part, the test cases can be adjusted by removing AUTO clause from the table description. |
| Comments |
| Comment by Sergei Golubchik [ 2022-10-03 ] | ||||||||||||||||
|
Unfortunately, this is where the logic "exactly the same as setting the timestamp" breaks. We cannot create new partitions (DDL) in the middle of an INSERT (DML). Note that a multi-row insert might need to create new partitions for every row, The row must go into the correct partition, if it exists, that's clear. The main use case — mysqldump — creates tables with the correct number of partitions, so it won't be affected by that. | ||||||||||||||||
| Comment by Elena Stepanova [ 2022-10-09 ] | ||||||||||||||||
|
FWIW, mysqldump isn't great at it either. Yes, it will create the correct number of partitions, but for partitioning by LIMIT (and if mysqldump runs with default extended insert), it will distribute the records between the partitions with rather little regard to the actual LIMIT condition. It will put into each partition at least as many records as a single INSERT contains (based on net-buffer-length), which can be a lot more than LIMIT, depending on circumstances; or, if LIMIT is greater than INSERT number, up to <LIMIT + INSERT> records. And since historical records in the dump aren't sorted by ROW END, it will put them into partitions pretty much randomly comparing to the order they were originally added. But this is of course to be expected. | ||||||||||||||||
| Comment by Elena Stepanova [ 2022-10-16 ] | ||||||||||||||||
|
Another consequence:
| ||||||||||||||||
| Comment by Elena Stepanova [ 2022-10-20 ] | ||||||||||||||||
I was too optimistic in this part. In fact, all inserted historical records are put into the first LIMIT partition, regardless its size and the amount/size of inserts. For mysqldump it means that even if it's run with --skip-extended-insert, it still puts all records into the first partition. Even if partition to insert into is specified explicitly, it still refuses to use any other than the first partition:
|