[YSQL] INSERT ON CONFLICT read batching stale map can give wrong results #26241
Labels
2024.2 Backport Required
area/ysql
Yugabyte SQL (YSQL)
kind/bug
This issue is a bug
priority/medium
Medium priority issue
Jira Link: DB-15586
Description
When INSERT ON CONFLICT read batching is used in conjunction with other DMLs within the same statement, the results can be distorted.
Compare the output of the alternate expectfiles of yb.orig.insert_on_conflict_with.out:
yugabyte-db/src/postgres/src/test/regress/expected/yb.orig.insert_on_conflict_with_1.out
Lines 70 to 92 in 95e3c5f
yugabyte-db/src/postgres/src/test/regress/expected/yb.orig.insert_on_conflict_with_2.out
Lines 70 to 73 in 95e3c5f
and
yugabyte-db/src/postgres/src/test/regress/expected/yb.orig.insert_on_conflict_with_1.out
Lines 95 to 116 in 95e3c5f
yugabyte-db/src/postgres/src/test/regress/expected/yb.orig.insert_on_conflict_with_2.out
Lines 78 to 99 in 95e3c5f
At it's core, it's a caching issue. Any statements that don't use INSERT ON CONFLICT read batching will not update the INSERT ON CONFLICT maps, both the global intents map (keys that are believed to have been added this executor node) and the batch-read map (keys/slots found existing in the index from this batch's batch read). The above test has simple cases of that using a WITH clause that manipulates the table but does not involve INSERT ON CONFLICT. All DMLs that manipulate the table should also update these maps. Alternatively, the maps should be discarded on such external manipulation, and batching should be restarted with fresh reads.
Commit message a120c25 discusses this issue and a potential solution:
Issue Type
kind/bug
Warning: Please confirm that this issue does not contain any sensitive information
The text was updated successfully, but these errors were encountered: