Skip to content
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

kv: support two-phase commit transactions #129388

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Commits on Aug 20, 2024

  1. sql: add max_prepared_transactions variable

    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
    nvanbenschoten committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    e892b8e View commit details
    Browse the repository at this point in the history
  2. sql: create system.prepared_transactions table

    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
    nvanbenschoten committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    262ab50 View commit details
    Browse the repository at this point in the history
  3. sql: add parser support for XA transactions

    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
    nvanbenschoten committed Aug 20, 2024
    Configuration menu
    Copy the full SHA
    0b32909 View commit details
    Browse the repository at this point in the history

Commits on Aug 21, 2024

  1. kv: support two-phase commit transactions

    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
    nvanbenschoten committed Aug 21, 2024
    Configuration menu
    Copy the full SHA
    86ea407 View commit details
    Browse the repository at this point in the history