Skip to content

Conversation

@aakashanandg
Copy link
Collaborator

@aakashanandg aakashanandg commented Jun 20, 2025

Description:
This change introduces an opt-in, automatic retry mechanism for DML statement that fails due to Spanner's transaction mutation limit.

When a DML statement fails with a TransactionMutationLimitExceededError, this logic will automatically retry the statement within a new Partitioned DML (PDML) transaction.

Key Features:

  • The fallback is transparent and enabled by passing a fallback_to_pdml isolation option to a standard transaction block.
  • If the fallback is disabled or unsafe, a specific TransactionMutationLimitExceededError is raised.

Usage:

Singer.transaction(isolation: fallback_to_pdml) do
  # If this fails with a mutation limit error, it will be retried with PDML.
  Singer.where("last_name LIKE ?", "A%").update_all(status: "Archived")
end

@aakashanandg aakashanandg requested review from a team and olavloite as code owners June 20, 2025 18:53
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/ruby-spanner-activerecord API. label Jun 20, 2025
@aakashanandg aakashanandg changed the title feat: Adding PDML fallback support for DML operations feat: Add automatic PDML fallback for mutation limit errors Jun 20, 2025
@aakashanandg aakashanandg force-pushed the pdml-fallback branch 3 times, most recently from 85b8421 to 67ac01b Compare June 23, 2025 18:22
olavloite
olavloite previously approved these changes Jun 25, 2025
Copy link
Collaborator

@olavloite olavloite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, with some minor nits/suggestions on the tests and sample.

@olavloite olavloite merged commit 1a3ad26 into googleapis:main Jun 25, 2025
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the googleapis/ruby-spanner-activerecord API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants