-
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.
[#16696] DocDB: Expose endpoint in pg_client_session to cancel a tran…
…saction Summary: This diff introduces support for cancelling a transaction given its transaction id. Providing a status tablet id is left as optional. When a status tablet id provided, we just check that tablet alone. When left empty, we check all the global txn status tablets and the local txn status tablets and try to cancel the txn. If we are unable to cancel the transaction for some reason, the `error` field in the `CancelTransactionResponsePB` is populated, which is returned back to pg as a status using the `status` field in `PgCancelTransactionResponsePB`. Note: When a transaction undergoes promotion, there is a minor period in which both the old and the new status tablet assume they are responsible for the transaction. In such cases, where multiple tablets report cancelation statuses, any reported error(s) take precedence. So it might also happen that we actually abort the txn, but report an error to the client. Subsequent cancel calls should report a `NOT_FOUND` in that case. We do this to be on the safer side as reporting `ABORTED` while the txn may still be active is not at all acceptable. Jira: DB-6068 Test Plan: ./yb_build.sh --cxx-test pgwrapper_pg_cancel_transaction-test ./yb_build.sh --cxx-test pgwrapper_pg_get_lock_status-test Old plan, but still can test using the following git cherry-pick commit basavaraj29@a864741 and basavaraj29@5ab76b0 create a cluster using the following ``` ./bin/yb-ctl create --rf=3 --placement_info "cloud0.rack1.zone,cloud0.rack2.zone,cloud0.rack3.zone" --data_dir ~/yugabyte-data --tserver_flags 'ysql_num_shards_per_tserver=1,ysql_pg_conf_csv="statement_timeout=0",enable_wait_queues=true,enable_deadlock_detection=true,enable_intentsdb_page=true' --master_flags 'auto_create_local_transaction_tables=true,auto_promote_nonlocal_transactions_to_global=true,enable_ysql_tablespaces_for_placement=true,ysql_tablespace_info_refresh_secs=1,client_read_write_timeout_ms=60000' ``` ``` CREATE TABLESPACE tablespace1 WITH (replica_placement='{"num_replicas": 1,"placement_blocks":[{"cloud": "cloud0","region": "rack1","zone": "zone","min_num_replicas": 1}]}'); CREATE TABLE test(k int PRIMARY KEY, v int); INSERT INTO test(k, v) VALUES (0,0),(1,1); CREATE TABLE foo(k int, v int) TABLESPACE tablespace1; INSERT INTO foo(k, v) VALUES (0,0),(1,1); ``` operating on foo produces a local txn, and operating on test produces a global txn ``` build/latest/bin/yb-ts-cli cancel_transaction <txn_id> [<status_tablet_id>] ``` Reviewers: esheng, tvesely, rsami Reviewed By: rsami Subscribers: ybase, bogdan Differential Revision: https://phorge.dev.yugabyte.com/D24476
- Loading branch information
1 parent
399340e
commit 3097369
Showing
16 changed files
with
983 additions
and
34 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
Oops, something went wrong.