-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#18192] YSQL: Make pggate use a best-effort approach for Abort Trans…
…action Summary: **Background** Postgres has a small stack (of size 5) to hold error records in re-entrant error scenarios. When any error occurs during the execution of a transaction, the error is pushed into this stack, and postgres attempts to perform transaction error recovery. As part of this recovery, any active transaction and sub-transaction is aborted. If an error occurs during these abort operations, they are further pushed onto the stack, and recovery from this error recovery is attempted, leading to a recursive loop. In YugabyteDB, aborting a transaction requires an RPC to the local tserver which introduces additional modes of failure. Failure to communicate with the tserver during transaction error recovery can cause this recursive loop of errors to overflow the error stack and result in a PANIC. This PANIC is innocuous, because DocDB automatically aborts the transaction after a period of inactivity. **Fix** This revision makes the AbortTransaction flow a best-effort approach so that errors from this flow are handled and not propagated further. The flow is as follows: - If a DML transaction is sought to be aborted (enclosing DDL transaction will also be aborted) via `YBCAbortTransaction`: - Two FinishTransaction RPCs with commit = false are sent to the tserver, first for the DDL, second for the DML. - Irrespective of the success/failure of the RPCs, the transaction state in pggate is cleared. - The status of the RPC is propagated to the pg layer. - In case of any errors, pg closes the backend connection connection. The above flow is also used as part of PG error recovery to abort any ongoing transaction (DDL or DML or both) and clear any transaction state via `YBCAbortTransaction`: - If a DDL transaction is sought to be aborted via `YBResetDdlState` (ie. enclosing DML transaction does not need to be aborted) - A FinishTransaction RPC with commit = false is sent to the local tserver to abort the DDL transaction. - Irrespective of the success/failure of the above RPC, the local DDL transaction state in pggate is cleared. - The status of the RPC is propagated to the pg layer. - In case of any errors, the PG error recovery flow is invoked to abort any enclosing DML transaction. Jira: DB-7215 Test Plan: This revision does not introduce new functionality; it only simplifies existing flows. Testing against a Jenkins run should be sufficient. Reviewers: pjain Reviewed By: pjain Subscribers: smishra, yql Tags: #jenkins-ready Differential Revision: https://phorge.dev.yugabyte.com/D34725
- Loading branch information
1 parent
166ef51
commit fcbdb09
Showing
8 changed files
with
70 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters