-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sql: implement XA transaction SQL statements #129448
Draft
nvanbenschoten
wants to merge
7
commits into
cockroachdb:master
Choose a base branch
from
nvanbenschoten:nvanbenschoten/2pcSQL
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
sql: implement XA transaction SQL statements #129448
nvanbenschoten
wants to merge
7
commits into
cockroachdb:master
from
nvanbenschoten:nvanbenschoten/2pcSQL
+3,237
−504
Conversation
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
Informs cockroachdb#22329. This commit adds the max_prepared_transactions session variable, returning a value of math.MaxInt32 to indicate that there is no limit on the number of prepared transactions that can be created. This change has the effect of unblocking the pgjdbc XADataSourceTest test suite, which was previously failing during initialization. Is also includes a small patch to work around cockroachdb#31632 (unsupported deferrable qualifier) so that each test in the XA test suite actually runs (and fails). Release note: None
Informs cockroachdb#22329. This commit adds a new `system.prepared_transactions` table, which will be used to track prepared transactions. The table includes all of the information needed to implement XA two-phase commit transactions, along with additional metadata needed to implement `pg_catalog.pg_prepared_xacts`. Release note: None
Informs cockroachdb#22329. This commit adds new syntax for `PREPARE TRANSACTION <gid>`, `COMMIT PREPARED <gid>`, and `ROLLBACK PREPARED <gid>`, for parity with Postgres support. Handling of the syntax is currently unimplemented. Release note: None
Informs cockroachdb#22329. This commit adds support for Txn.Prepare, DB.CommitPrepared, and DB.RollbackPrepared APIs to KV. These methods allow clients to prepare a transaction for commit, commit a prepared transaction, and rollback a prepared transaction, respectively. When a transaction is prepared, we send an EndTxnRequest as usual, but a new flag indicates the transaction should be moved to status PREPARED instead of COMMITTED. In state PREPARED, a transaction record is updated to include all of its intents, and awaits a subsequent EndTxnRequest which will move the transaction either to COMMITTED or ABORTED. Transaction in state PREPARED cannot be pushed, regardless of isolation level, ensuring that a subsequent commit or rollback is guaranteed to succeed. Release note: None
Informs cockroachdb#22329. This commit implements the statement handling for `PREPARE TRANSACTION <gid>`, `COMMIT PREPARED <gid>`, and `ROLLBACK PREPARED <gid>`, for parity with Postgres support. The implementation is based on the Postgres documentation and the Postgres source code. Release note (sql change): XA transaction support allows CockroachDB to participate in distributed transaction with other resources (e.g. databases, message queues, etc) using a two phase commit protocol.
Informs cockroachdb#22329. `pg_catalog.pg_prepared_xacts` reads from `system.prepared_transactions`. Release note: None
Informs cockroachdb#22329. This commit fixes the pgjdbc blocklist to reflect the current state of support for XA transactions in CockroachDB. With the newly added support for two-phase commit transactions, all tests in the XADataSourceTest test suite now pass except for `mappingOfConstraintViolations`, which is blocked by cockroachdb#31632 (DEFERRABLE foreign keys). Release note: None
Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Informs #22329.
First commit from #129295.
Second commit from #129297.
Third commit from #129298.
Fourth commit from #129388.
This PR implements the statement handling for
PREPARE TRANSACTION <gid>
,COMMIT PREPARED <gid>
, andROLLBACK PREPARED <gid>
, for parity with Postgres support. The implementation is based on the Postgres documentation and the Postgres source code.The PR then implements the
pg_catalog.pg_prepared_xacts
system catalog table, which reads fromsystem.prepared_transactions
. This adds the remaining PG compatibility, so that XA in CockroachDB looks near-identical to XA in PostgreSQL.Finally, the PR fixes the
pgjdbc
blocklist to reflect the current state of support for XA transactions in CockroachDB. With the newly added support for two-phase commit transactions, all tests in theXADataSourceTest
test suite now pass except formappingOfConstraintViolations
, which is blocked by #31632 (DEFERRABLE foreign keys).Release note (sql change): XA transaction support allows CockroachDB to participate in distributed transaction with other resources (e.g. databases, message queues, etc) using a two phase commit protocol.