Repository navigation
Fixed - check synced slaves in RTransaction commit #6292 - #7392
ronitgupta138 wants to merge 2 commits into
Conversation
Signed-off-by: Ronit Gupta <ronitgupta138@gmail.com>
ef79c6c to
0feeec5
Compare
mrniko
left a comment
There was a problem hiding this comment.
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 fromprivateto package-private, but no code uses it. Make itprivateagain.- The check occurs two times, in
commitand incommitAsync. One small private method can contain the check for both.
…hard min replica sync (redisson#6292) Signed-off-by: Ronit Gupta <ronitgupta138@gmail.com>

Fixes #6292
When
TransactionOptions.syncSlavesis configured,RedissonTransactionconfigures the slave synchronization parameters onBatchOptionsand sendsWAITvia the transaction batch executor. However,commit()andcommitAsync()previously ignored the returnedBatchResult, silently succeeding even when the number of synced replicas reported by RedisWAITwas fewer than requested.This change verifies
result.getSyncedSlaves()in bothcommit()andcommitAsync()whenbatchOptions.getSyncSlaves() > 0, throwing aTransactionExceptionif the required amount of slaves was not synced within the timeout.Added
RedissonTransactionSyncSlavesTestto verify options handling and execution constraints.