Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#23843] YSQL: Do not retry schema mismatch errors that occur as part…
… of a batched execution. Summary: ### Motivation Commit fa8a138 fixes an issue with internal retries of transaction conflicts in batched execution scenarios. Retries for schema mismatch errors take a different code path. Do not retry schema mismatch errors when in batched mode of execution. Say, we retry 5th statement of the batch on a schema version mismatch error. ``` .addBatch("UPDATE t SET v = 2 WHERE k = 1") .addBatch("UPDATE t SET v = 2 WHERE k = 2") .addBatch("UPDATE t SET v = 2 WHERE k = 3") .addBatch("UPDATE t SET v = 2 WHERE k = 4") .addBatch("UPDATE t SET v = 2 WHERE k = 5") <-- retry here ... .addBatch("UPDATE t SET v = 2 WHERE k = 10") .executeBatch() ``` Only statements starting from the retried statement take effect. That is, internally, ``` START TXN UPDATE ... k = 1 UPDATE ... k = 2 UPDATE ... k = 3 UPDATE ... k = 4 UPDATE ... k = 5 <--- schema mismatch error <--- abort txn and retry ROLLBACK TXN START TXN UPDATE ... k = 5 <--- retries starting from 5th statement because the previous statements are lost ... UPDATE ... k = 10 COMMIT TXN ``` This is a transaction atomicity issue. ### Fix Schema mismatch errors are not retried when the statement exists within an explicit transaction block. Similarly, avoid retrying transactions in batched execution mode. Jira: DB-12746 Test Plan: Jenkins ``` ./yb_build.sh --java-test TestPgBatch#testTransparentRestartSchemaMismatch ``` **Context:** TestPgBatch.java executes a conflicting statement `UPDATE t SET v=1 WHERE k=...` to test retries due to transaction conflicts in batched execution mode. Execute `ALTER TABLE t ALTER COLUMN v SET NOT NULL` to introduce a schema mismatch error instead of a transaction conflict. This triggers the retry path meant for schema mismatch errors. We verify that an exception is raised in batched execution mode. Backport-through: 2.20 Reviewers: tfoucher, dmitry, smishra Reviewed By: tfoucher, dmitry Subscribers: yql Differential Revision: https://phorge.dev.yugabyte.com/D37913
- Loading branch information