[MDEV-23446] UPDATE does not insert history row if the row is not changed Created: 2020-08-11 Updated: 2023-09-08 Resolved: 2021-01-12 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Data Manipulation - Update, Versioned Tables |
| Affects Version/s: | 10.3.18, 10.3 |
| Fix Version/s: | 10.3.28, 10.4.18, 10.5.9 |
| Type: | Bug | Priority: | Blocker |
| Reporter: | Remy Fox | Assignee: | Aleksey Midenkov |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
UPDATE queries that do not change any values in the rows they match on versioned tables do not insert historical rows. Example:
Disclaimer: I don't know whether this is a bug or was purposefully designed like this. In the latter case, I want to make a case to reconsider it:
|
| Comments |
| Comment by Sergei Golubchik [ 2020-09-02 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Looks like a bug to me | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Michael Erickson (Inactive) [ 2020-09-10 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
We had a similar bug in Clustrix caused by a similar optimization, though it manifest as a MVCC problem rather than a system versioning problem. (Bug 31880 for those with access to the Clustrix bug database.) If it helps, here was the scenario from that bug:
Perhaps this can serve as inspiration for additional testcases. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Nikita Malyavin [ 2020-10-25 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Changes are required: IGNORE behavior should be handled for `vers_insert_history_row`; gotos to the label in the middle of the function body should be removed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Nikita Malyavin [ 2020-10-26 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
After the discussion we decided not to argue too much on IGNORE behavior, and leave it out of this ticket's scope. So this will be left as is | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Aleksey Midenkov [ 2020-12-12 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
versioning.foreign fails still. Might be different bug of execution foreign ON constraint. Fixed by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2021-01-06 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Common people, first goto backward, then using "error" variable from other scope by place of goto. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2021-01-06 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I will make urgent fix with the variable, plase fix it properly. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-01-07 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
midenok, I think that we must absolutely cover this code path in multi_update::send_data() with a test case:
This is causing an uninitialized variable to be used in another scope:
If I understood it correctly, the fix that sanja is considering would only silence the GCC -Wmaybe-uninitialized in optimized builds, but we would use error=0 (no error) in that error handling code path, which feels wrong to me. Hence, we should make sure that this code path is covered by a test, and an appropriate error will be reported. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Oleksandr Byelkin [ 2021-01-07 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
188b328335d5c2a61d21f528fad19a685f9511ef | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Aleksey Midenkov [ 2021-01-12 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
marko Agree and already started that in MDEV-24451. Some errors are hard to trigger without DBUG_EXECUTE_IF() (like failure of insert history row). Do you have an idea how to fail row insert in release build? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2021-01-13 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
midenok, an insert should be able to fail on lock wait timeout. Maybe you could issue a locking read (SELECT…LOCK IN SHARE MODE) from another connection? |