[MDEV-30046] wrong row targeted with "insert ... on duplicate" and "replace", leading to data corruption Created: 2022-11-21 Updated: 2024-01-03 |
|
| Status: | Stalled |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Insert |
| Affects Version/s: | 10.5.15, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10 |
| Fix Version/s: | 10.4, 10.5, 10.6 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Frank Heckenbach | Assignee: | Nikita Malyavin |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Environment: |
Linux 5.10.0-14-amd64, Debian 11.5 |
||
| Issue Links: |
|
||||||||||||||||||||||||||||
| Description |
|
(Also reported here: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1015293) Using the MySQL interface, these statements:
produce this output: s n So the latter "INSERT" updates the wrong row. This happens whether the first column is "BLOB" or "TEXT", but only Likewise, these statements:
give the error: ERROR 1062 (23000) at line 4: Duplicate entry 'Hrecvx_0004mm-00' for key 's' In my understanding, this error should actually be impossible with It might be the same issue, i.e. it tries to delete the wrong row |
| Comments |
| Comment by Alice Sherepa [ 2022-11-21 ] | |||||||||||||||||||||
|
Thanks for the report! I repeated as described on 10.4-10.11, InnoDB. Probably caused by
| |||||||||||||||||||||
| Comment by Alexander Barkov [ 2022-12-16 ] | |||||||||||||||||||||
|
Works fine with MyISAM:
| |||||||||||||||||||||
| Comment by Nikita Malyavin [ 2023-01-09 ] | |||||||||||||||||||||
|
Thanks bar for the pointers, the bug with IDEMPOTENT replication was found with long uniques, which uses the same logic as REPLACE, and even contains the copy-paste from there. I guess it was made so to allocate and reuse the key buffer memory on the stack, saving from extra malloc. I think our priority now is to minimize stack usage vs extra mallocs, so it's not the point anymore. I made some refactoring and extracted common code. Also moved handler's RND search initialization to Write_rows_log_event::do_before_row_operations. This fixed many long unique bugs in relplication and optimized the use a little bit. https://github.com/MariaDB/server/commit/703e73e221a42638f2f05379124b35c57482da93 One more refactoring should be done to generalize handler initialization (and de-initialization) across REPLACE, LOAD DATA, IDEMPOTENT replication, and improve memory usage. | |||||||||||||||||||||
| Comment by Otto Kekäläinen [ 2023-12-01 ] | |||||||||||||||||||||
|
The commit https://github.com/MariaDB/server/commit/703e73e221a42638f2f05379124b35c57482da93 was never in a pull request nor included on any branch, and `git log -S MDEV-30046` does not yield any results from 10.5 branch, so I assume this issue is still open (and thus will also continue to keep https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1015293 open). |