Fixed - check synced slaves in RTransaction commit #6292 by ronitgupta138 · Pull Request #7392 · redisson/redisson · GitHub
Skip to content

Fixed - check synced slaves in RTransaction commit #6292 - #7392

Open
ronitgupta138 wants to merge 2 commits into
redisson:masterfrom
ronitgupta138:fix/transaction-sync-slaves-check
Open

ronitgupta138 wants to merge 2 commits into
redisson:masterfrom
ronitgupta138:fix/transaction-sync-slaves-check

Conversation

@ronitgupta138

Copy link
Copy Markdown
Contributor

Fixes #6292

When TransactionOptions.syncSlaves is configured, RedissonTransaction configures the slave synchronization parameters on BatchOptions and sends WAIT via the transaction batch executor. However, commit() and commitAsync() previously ignored the returned BatchResult, silently succeeding even when the number of synced replicas reported by Redis WAIT was fewer than requested.

This change verifies result.getSyncedSlaves() in both commit() and commitAsync() when batchOptions.getSyncSlaves() > 0, throwing a TransactionException if the required amount of slaves was not synced within the timeout.

Added RedissonTransactionSyncSlavesTest to verify options handling and execution constraints.

Copilot AI balanced review requested due to automatic review settings October 16, 2026 10:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Signed-off-by: Ronit Gupta <ronitgupta138@gmail.com>
@ronitgupta138
ronitgupta138 force-pushed the fix/transaction-sync-slaves-check branch from ef79c6c to 0feeec5 Compare October 17, 2026 06:21

@mrniko mrniko left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the suggested changes. Below are the comments:

1. Cluster: a transaction on 2 or more shards can pass when 1 shard has no replica acknowledgement

BatchResult.getSyncedSlaves() returns the sum of the WAIT replies from all masters in the batch. Refer to CommandBatchService, near L339 and L775.

2. Default options now cause commits to fail if a replica is slow

The default value of syncSlaves is 0, which means "all available slaves". Because of this value, createOptions() already sends WAIT <availableSlaves> for default transactions. The new check tests batchOptions.getSyncSlaves() > 0. As a result, the check applies to all default commits. It also applies to users who did not request replica sync.

3. The exception shows a failed transaction, but the master contains the data

WAIT does not cancel the write. After each exception in my tests, the master contained the value. At that point, executed is already true, so a rollback() call is not possible.

The exception type is also the same as for "Unable to execute transaction". In that case, Redisson wrote no data. RedissonTransactionManager.doCommit changes the exception to TransactionSystemException. If the application retries a failed transaction, it applies the writes two times.

Can you use a subclass for this exception? For example, TransactionSyncException extends TransactionException. With a subclass, the current catch blocks continue to work. The message must tell what occurred, for example: Transaction committed, but only 2 of 3 replicas acknowledged within 2000 ms. Also, update the syncSlaves Javadoc and docs/transactions.md with the new behaviour.

4. The test does not test the change

RedissonTransactionSyncSlavesTest only examines the getters, equals and hashCode of TransactionOptions. Thus, the test passes if you remove the fix.

Minor items

  • createOptions() changed from private to package-private, but no code uses it. Make it private again.
  • The check occurs two times, in commit and in commitAsync. One small private method can contain the check for both.

…hard min replica sync (redisson#6292)

Signed-off-by: Ronit Gupta <ronitgupta138@gmail.com>
@ronitgupta138

Copy link
Copy Markdown
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

syncSlaves in RTransaction not working as expected

3 participants