Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#20549] YSQL: Perform portal restart after instead of before transac…
…tion restart Summary: This diff is the preparation for the further diff with actual fix for #20549. The fix will store YB related info `read_time_serial_no` in the postgres' native structure `SnapshotData`. In case of building `SnapshotData` it is required to store actual (i.e. non obsolete) value of `read_time_serial_no`. And this `read_time_serial_no` value should be valid after restarting YB's transaction. In case of query failure YB may perform transparent retry. In this case portal is restarted and YB transaction may be restarted as well. Portal restart creates fresh snapshot (`SnapshotData` structure) and transaction restart performs `read_time_serial_no` update. To meet the requirement that new snapshot should have actual `read_time_serial_no` value it is necessary to restart YB's transaction before creation of the snapshot by portal restart. This diff splits portal restart in 2 separate functions: `yb_clear_portal_before_restart` and `yb_attempt_to_retry_on_error`. Between these 2 function calls transaction is restarted (by the `yb_prepare_transaction_for_retry` function): ``` yb_clear_portal_before_restart yb_prepare_transaction_for_retry yb_attempt_to_retry_on_error ``` **Note:** it is necessary to clear the portal before transaction restart because current transaction owns portal and it will be freed by current transaction abort. The `yb_clear_portal_before_restart` function unattach the portal from current transaction to keep it alive even in case of transaction restart. **Note:** To simplify the code and increase readability some additional cleanup changes was implemented (including `restart` with `retry` substitution in names of some functions and structures) Jira: DB-9557 Test Plan: Jenkins Reviewers: pjain Reviewed By: pjain Subscribers: yql Tags: #jenkins-ready Differential Revision: https://phorge.dev.yugabyte.com/D34797
- Loading branch information