Repository navigation
Fixed - check synced slaves in RTransaction commit #6292 - #7392
ronitgupta138 wants to merge 5 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>
|
Thanks for the review and detailed feedback @mrniko! Addressed all items in commit
|
mrniko
left a comment
There was a problem hiding this comment.
Thank you for update. Three small items:
-
The new tests use a single server node. Because of this, the minimum and the sum are always equal, and a default commit never sends
WAIT. If you changegetMinSyncedSlaves()back togetSyncedSlaves(), all the tests still pass. You can add a test withtestInCluster, which has 1 replica for each master. -
The
@throws TransactionSyncExceptiontag is onTransactionOptions.syncSlaves(), but that method does not throw. Please move it toRTransaction.commit()andcommitAsync(). -
The example in
docs/transactions.mdnow uses.syncSlaves(2, 5, TimeUnit.SECONDS). If a user copies it to a setup with fewer than 2 replicas, each commit throws an exception. You can use0, which agrees with the "Default slaves value is 0" line above it.
…edisson#6292) - Add cluster integration tests in RedissonTransactionSyncSlavesTest using testInCluster verifying per-shard min replica sync - Move @throws TransactionSyncException javadoc to RTransaction commit/commitAsync - Update docs/transactions.md example to use syncSlaves(0, ...) Signed-off-by: Ronit Gupta <ronitgupta138@gmail.com>
|
Thanks @mrniko! Addressed all three items in commit
|
mrniko
left a comment
There was a problem hiding this comment.
testDefaultOptionsPassInCluster(), testSyncSlavesInCluster() fail
|
Thanks @mrniko! Fixed both items in commit
|
|
Thanks @mrniko! The failures shown in the test runner were caused by:
|
9223040 to
da23b77
Compare
…check (redisson#6292) Signed-off-by: Ronit Gupta <ronitgupta138@gmail.com>
da23b77 to
d4703e2
Compare
|
|
||
| private BatchOptions createOptions() { | ||
| MasterSlaveEntry entry = commandExecutor.getConnectionManager().getEntrySet().iterator().next(); | ||
| int syncSlaves = entry.getAvailableSlaves(); |
There was a problem hiding this comment.
default transactions no longer wait for replicas. createOptions() now sends no WAIT when syncSlaves is 0, the default.
There was a problem hiding this comment.
Good catch @mrniko! Restored entry.getAvailableSlaves() in createOptions() in commit cd12477.
Default transactions (options.getSyncSlaves() == 0) now continue to send WAIT for all available replicas as before, while checkSyncSlaves() ensures only explicitly configured quorums (options.getSyncSlaves() > 0) enforce strict verification and throw TransactionSyncException on timeout.
There was a problem hiding this comment.
Please help me to my account no transfer to me 01425604868500 awash bank of Ethiopia maliya aliyi ame
There was a problem hiding this comment.
01425604868500 awash bank of Ethiopia bishoftu oromia lamlem branch maliya aliyi ame
…Options (redisson#6292) Restore MasterSlaveEntry availableSlaves lookup in createOptions so default transactions (syncSlaves == 0) continue to wait for available replicas, while strict verification in checkSyncSlaves only applies when syncSlaves > 0. 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.