-
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.
[#14202] YSQL: Avoid rpc from YSQL to local tserver when switching su…
…b-txns Summary: Currently, YSQL sends the PgSetActiveSubTransactionRequestPB rpc to the local tserver process' Pg client (pg_client_session.cc) when it wants to switch the active sub transaction id. YSQL will switch the active sub transaction id for any of following - user savepoint operations, an internal savepoint created for exception handling or an internal savepoint created before execution of a statement in READ COMMITTED isolation level as explained in 9f2cc7f. The PgSetActiveSubTransactionRequestPB rpc was added in c5f5125 as part of larger PgClient changes. After the change, YSQL sends all rpcs for DMLs to the PgClientSession on the local tserver process. Distributed transaction creations and management is handled in the PgClientSession and is not visible to the YSQL backends. Before this change, YSQL backends managed the lifecycle of distributed transactions and sub-txn operations were local i.e., any rpcs. However, a separate rpc is not required for setting the active sub transaction id. The active sub transaction id can be piggybacked in each PgPerformRequestPB through the PgPerformOptionsPB sub-field and the Pg client session on the tserver can change the active sub transaction id before handling the PgPerformRequestPB. Removal of this rpc is required as a precursor to solving #12494. As part of #12494, we can see that postgres allows changing the transaction isolation level after a "BEGIN" statement. In YSQL, if the "BEGIN" statement starts in READ COMMITTED isolation, every future statement will acquire an internal savepoint before executing the statement (refer 9f2cc7f). Without this diff, the internal savepoint creation results in a PgSetActiveSubTransactionRequestPB rpc which inturn starts a distributed transaction. This leads to the setting the isolation level in stone, and not allowing any future modification of the transaction isolation (via the "SET TRANSACTION ISOLATION LEVEL" statement) even if no other queries have been executed. It results in the "Attempt to change isolation level of running transaction..." error message in pg_client_session.cc NOTE: The RollbackToSubTransaction rpc for rolling back to a sub transaction id stays and will remain synchronous. Test Plan: ./yb_build.sh --java-test org.yb.pgsql.TestPgIsolationRegress#isolationRegres Reviewers: mtakahara, rsami Reviewed By: mtakahara, rsami Subscribers: zyu, yql, bogdan Differential Revision: https://phabricator.dev.yugabyte.com/D19902
- Loading branch information
Showing
7 changed files
with
102 additions
and
42 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