mirror of
https://github.com/MariaDB/server.git
synced 2025-08-06 18:41:37 +02:00

Timestamp-versioned row deletion was exposed to a collisional problem: if current timestamp wasn't changed, then a sequence of row delete+insert could get a duplication error. A row delete would find another conflicting history row and return an error. This is true both for REPLACE and DELETE statements, however in REPLACE, the "optimized" path is usually taken, especially in the tests. There, delete+insert is substituted for a single versioned row update. In the end, both paths end up as ha_update_row + ha_write_row. The solution is to handle a history collision somehow. From the design perspective, the user shouldn't experience history rows loss, unless there's a technical limitation. To the contrary, trxid-based changes should never generate history for the same transaction, see MDEV-15427. If two operations on the same row happened too quickly, so that they happen at the same timestamp, the history row shouldn't be lost. We can still write a history row, though it'll have row_start == row_end. We cannot store more than one such historical row, as this will violate the unique constraint on row_end. So we will have to phisically delete the row if the history row is already available. In this commit: 1. Improve TABLE::delete_row to handle the history collision: if an update results with a duplicate error, delete a row for real. 2. use TABLE::delete_row in a non-optimistic path of REPLACE, where the system-versioned case now belongs entirely.
26 lines
838 B
Text
26 lines
838 B
Text
--- replace.result
|
|
+++ replace.reject
|
|
@@ -75,7 +75,6 @@
|
|
replace into t1 (pk,i) values (1,10),(1,100),(1,1000);
|
|
select pk, i, check_row(row_start, row_end) from t1 for system_time all;
|
|
pk i check_row(row_start, row_end)
|
|
-1 10 ERROR: row_end == row_start
|
|
1 1000 CURRENT ROW
|
|
drop table t1;
|
|
create or replace table t1 (
|
|
@@ -94,7 +93,6 @@
|
|
commit;
|
|
select pk, i, check_row(row_start, row_end) from t1 for system_time all;
|
|
pk i check_row(row_start, row_end)
|
|
-1 3 ERROR: row_end == row_start
|
|
1 300 CURRENT ROW
|
|
drop table t1;
|
|
# In this case there'll be no unique constraint on a historical row.
|
|
@@ -114,8 +112,6 @@
|
|
commit;
|
|
select pk, i, check_row(row_start, row_end) from t1 for system_time all;
|
|
pk i check_row(row_start, row_end)
|
|
-1 3 ERROR: row_end == row_start
|
|
-1 30 ERROR: row_end == row_start
|
|
1 300 CURRENT ROW
|
|
drop table t1;
|