Repository navigation
Description
Redis version
Valkey 7.2.6
Redisson version
4.7.0
Redisson configuration
Config config = new Config();
config.useSingleServer()
.setAddress("redis://127.0.0.1:6379")
.setTimeout(20000)
.setPingConnectionInterval(10000);
RedissonClient client = Redisson.create(config);
BatchOptions options = BatchOptions.defaults()
.executionMode(BatchOptions.ExecutionMode.IN_MEMORY)
.skipResult();
RBatch batch = client.createBatch(options);
// Add batch writes.
batch.getBucket("example").setAsync("value");
batch.executeAsync();
// The workload mixes skip-result batches with ordinary commands/batches.
// Reproduction depends on reply coalescing and command timing;
// a single small batch does not reliably trigger it.
What is the Expected behavior?
A skipResult() batch should consume only its own replies: the CLIENT REPLY ON acknowledgement and any additional transaction or replication-sync replies.
Replies to subsequent commands must remain associated with those commands, regardless of TCP packet boundaries or whether multiple replies arrive in the same network read.
For example, PING should receive "PONG" and SCARD should receive its integer result.
What is the Actual behavior?
When a skipped batch's +OK acknowledgement and a following PING's +PONG arrive in the same read, the batch decoder can consume both as batch replies.
This shifts subsequent reply associations:
- The skipped batch consumes PONG.
- The pending PING consumes the next command's integer reply.
- A subsequent integer command can receive an OK string, producing a String-to-Long ClassCastException.
Depending on the following traffic, commands can also remain pending and eventually fail with RedisResponseTimeoutException.
Additional information
The decoder behavior reproduces in Redisson 3.52.0, 4.7.0, and master at 64d5fbf.
The relevant batch-decoding behavior predates 4.7. Earlier heartbeat suppression avoided sending PINGs while a connection was borrowed, reducing exposure. The later
heartbeat change makes this sequence easier to encounter.
Related PR #7380 suppresses PINGs while an unfinished batch is queued, but reply decoding must preserve command boundaries independently of heartbeat timing.
A deterministic EmbeddedChannel reproduction queues:
- A skip-result SET batch
- A PING
- A normal batch containing SCARD and SET
Deliver the batch acknowledgement and PONG together:
+OK\r\n+PONG\r\n
Then deliver the following command replies:
:5\r\n+OK\r\n
The skipped batch consumes PONG, leaving PING to consume the integer response. Delivering OK and PONG in separate reads avoids this failure.
No malformed Redis responses are required; coalescing replies is normal TCP behavior.
Proposed fix and regression tests:
#7445
Activity
rahulrane50 commentedon Nov 19, 2026
@mrniko this is quite serious and we had to downgrade redisson version because of this. Can you take a look once?
Exar-lab commentedon Nov 26, 2026
I read through
CommandDecoderand the behaviour described here matches the code. I'd like to work on a fix.What I see
skipBatchCommandalready knows askipResult()batch expects a single reply (theCLIENT REPLY ONacknowledgement).decodeCommandBatchloopswhile (in.writerIndex() > in.readerIndex())and only stops wheni == commandBatch.getCommands().size(). The one early exit isi == 0 && skipResult && syncSlaves.+OKof a skipped batch and the+PONGof the next command arrive in the same read, the loop keeps going and decodes+PONGas a batch reply. Every later reply is then matched with the wrong command.Possible fix: leave the loop right after
i++when the batch isskipResult. That also covers thesyncSlavescase, where the second call decodes a single command.Plan: write a unit test that feeds the
CommandDecoderanEmbeddedChannelwith+OK\r\n+PONG\r\nin one buffer and check it fails before the change. I haven't confirmed yet that the decoder can be set up that way without a Redis server.@mrniko does this match how you read it, or is there a reason the loop doesn't stop after the expected reply count? I'll wait for your answer before opening a PR.