Open jabolina opened 1 week ago
I think WATCH is the only command that the MULTI will drop. The solution will require something specific to WATCH.
Not only, unfortunately. MULTI inside MULTI is not allowed too (and does not fail the transaction) :
127.0.0.1:6484> MULTI
OK
127.0.0.1:6484(TX)> SET a b
QUEUED
127.0.0.1:6484(TX)> MULTI
(error) ERR MULTI calls can not be nested
127.0.0.1:6484(TX)> SET b b
QUEUED
127.0.0.1:6484(TX)> EXEC
1) OK
2) OK
The test should complete successfully with all 3 set operations returning an OK response.
I agree that the last result should not be omitted from the TransactionResult
, but I disagree that the error should be silently ignored. After all the transaction was supposed to contain 4 commands and, respectively, I would assume it would have 4 results (for each of the commands). Otherwise it might not be immediately visible to the user where the result from the WATCH
command is, or why it failed for that matter.
Bug Report
Redis returns an error if a WATCH command is submitted inside a MULTI. However, this command is silently discarded. The WATCH command does not count in the final result list during the EXEC phase. For example:
Observe that the WATCH command is not included in the result list.
Current Behavior
Lettuce includes the failed WATCH command in the output list. Additionally, since the command is dropped, the response list has fewer responses than the command list in
MultiOutput
and some commands might never be completed.Input Code
For example, adding the following test to the
TransactionCommandIntegrationTests
class:Input Code
```java @Test void watchWithinMulti() { redis.multi(); redis.set("one-a", "a"); redis.set("one-b", "b"); redis.watch("something"); redis.set("one-c", "c"); TransactionResult result = redis.exec(); for (Object o : result) { System.out.println(o); } assertThat(result) .hasSize(3) .allMatch("OK"::equals); } ```Produces:
Expected behavior/code
The test should complete successfully with all 3 set operations returning an
OK
response.Environment
Additional context
I think WATCH is the only command that the MULTI will drop. The solution will require something specific to WATCH.