quarkusio/quarkus · error · IllegalStateException
Unable to add command to the current transaction
Error message
Unable to add command to the current transaction
What it means
In transactional Redis commands, each queued command must receive a 'QUEUED' reply. queuedOrDiscard() checks the response; if it is not QUEUED, the whole transaction is discarded and an IllegalStateException is thrown because the command could not be added to the transaction and continuing would leave the MULTI block inconsistent.
Source
Thrown at extensions/redis-client/runtime/src/main/java/io/quarkus/redis/runtime/datasource/AbstractTransactionalCommands.java:20
import io.quarkus.redis.datasource.ReactiveTransactionalRedisCommands;
import io.quarkus.redis.datasource.transactions.ReactiveTransactionalRedisDataSource;
import io.vertx.redis.client.Response;
public class AbstractTransactionalCommands implements ReactiveTransactionalRedisCommands {
protected final TransactionHolder tx;
private final ReactiveTransactionalRedisDataSource ds;
public AbstractTransactionalCommands(ReactiveTransactionalRedisDataSource ds, TransactionHolder tx) {
this.ds = ds;
this.tx = tx;
}
protected void queuedOrDiscard(Response response) {
if (!"QUEUED".equals(response.toString())) {
this.tx.discard();
throw new IllegalStateException("Unable to add command to the current transaction");
}
}
@Override
public ReactiveTransactionalRedisDataSource getDataSource() {
return ds;
}
}
View on GitHub (pinned to e1c734241f)
Solutions
- Inspect the discarded transaction's commands for type/key mismatches (WRONGTYPE replies) and fix the offending command.
- Verify all commands used in the transaction are supported by your Redis server version.
- Retry the transaction after the failure, since the client discarded it automatically.
Example fix
// before
TxRedisStringCommands<String> strings = tx.string();
strings.set(key, value); // fails if key holds a list -> WRONGTYPE
// after
if (tx.type(key).await().indefinitely().equals("string")) {
tx.string().set(key, value);
} Defensive patterns
Strategy: try-catch
Validate before calling
// Validate key types before entering the transaction String type = redis.key().type(key).await().indefinitely();
Try / catch
try (TransactionResult ignored = txResult) {
tx.string().set(key, value);
} catch (IllegalStateException e) {
if (e.getMessage().contains("Unable to add command to the current transaction")) {
// transaction was discarded; inspect command args/types and retry
}
} Prevention
- Ensure command data types match the actual key types inside transactions.
- Only use commands supported by your Redis server version in MULTI blocks.
- Log discarded transactions with their commands for diagnosis.
When it happens
Trigger: Inside a Redis transaction (MULTI/EXEC flow via TransactionalRedisDataSource), a command is queued and the server responds with something other than QUEUED — e.g. a WRONGTYPE or syntax error reply during queueing.
Common situations: Calling a command with arguments of the wrong Redis type inside a transaction (e.g. LIST operation on a STRING key); using commands unsupported by the server version; connection issues mid-transaction.
Related errors
- Could not access JTA Transaction to register synchronization
- Error getting the status of the current transaction
- Error getting the current transaction
- Changing timeout via @TransactionConfiguration can only be d
- The Reactive Redis Client must be injected
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/015fd02922d12303.
Report an issue: GitHub.