{"record":{"id":"8a1dae31e909b826","repo":"redis/jedis","slug":"multi-command-failed-received-response","errorCode":null,"errorMessage":"MULTI command failed. Received response: ","messagePattern":"MULTI command failed\\. Received response: ","errorType":"exception","errorClass":"JedisException","httpStatus":null,"severity":"error","filePath":"src/main/java/redis/clients/jedis/ReliableTransaction.java","lineNumber":96,"sourceCode":"   * @param closeConnection should the 'connection' be closed when 'close()' is called?\n   */\n  ReliableTransaction(Connection connection, boolean doMulti, boolean closeConnection, CommandObjects commandObjects) {\n    super(commandObjects);\n    this.connection = connection;\n    this.closeConnection = closeConnection;\n    if (doMulti) multi();\n  }\n\n  private static CommandObjects createCommandObjects(Connection connection) {\n    return new CommandObjects(RedisProtocol.orServerDefault(connection.getRedisProtocol()));\n  }\n\n  @Override\n  public final void multi() {\n    connection.sendCommand(MULTI);\n    String status = connection.getStatusCodeReply();\n    if (!\"OK\".equals(status)) {\n      throw new JedisException(\"MULTI command failed. Received response: \" + status);\n    }\n    inMulti = true;\n  }\n\n  @Override\n  public String watch(final String... keys) {\n    String status = connection.executeCommand(commandObjects.watch(keys));\n    inWatch = true;\n    return status;\n  }\n\n  @Override\n  public String watch(final byte[]... keys) {\n    String status = connection.executeCommand(commandObjects.watch(keys));\n    inWatch = true;\n    return status;\n  }\n","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/redis/jedis/blob/6dac31d4c224fb3257c216f3985340c6f500cdcb/src/main/java/redis/clients/jedis/ReliableTransaction.java#L78-L114","documentation":"ReliableTransaction.multi() sends the MULTI command and expects an 'OK' status reply. If the server replies with anything else, it throws JedisException('MULTI command failed. Received response: <status>'). A non-OK MULTI reply indicates the server refused to enter the queued-transaction state (e.g. connection in an unexpected state or an error reply instead of a status).","triggerScenarios":"Calling transaction.multi() when the connection's state desynced from the server — for example reusing a connection that already had errors, a proxy mangling the reply, or a server returning an error string instead of +OK.","commonSituations":"Connection sharing/pooling bugs where a previous command's error reply is consumed as the MULTI status; failover mid-transaction; sending commands on a broken or stale connection.","solutions":["Inspect the status text in the exception to identify the server's actual reply, then reset the connection (return to pool / reconnect).","Ensure no commands were issued or left unread on the connection before multi(); use a fresh transaction instance per connection.","Check for proxies/pool configs that corrupt the protocol stream; retry the transaction on a new connection."],"exampleFix":"// before\nTransaction t = jedis.multi();\nt.multi(); // may throw on stale connection\n\n// after\ntry {\n  t.multi();\n} catch (JedisException e) {\n  connection.close(); // force reconnect\n  t = jedis.multi();\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  transaction.multi();\n} catch (JedisException e) {\n  connection.close(); // reset desynced connection\n  transaction = createNewTransaction();\n}","preventionTips":["Use one transaction per dedicated connection; never share transactions across threads.","Drain or close connections that produced protocol errors instead of reusing them.","Avoid proxies/pools that can interleave replies on transactional connections."],"tags":["transaction","multi","redis-protocol"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"6dac31d4c224fb3257c216f3985340c6f500cdcb","analyzedAt":"2026-09-08T04:55:01.204Z","contentChangedAt":"2026-09-08T04:55:01.204Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}