DBAtlas · Database operations atlas

ERR WATCH inside MULTI is not allowed: WATCH inside MULTI is not allowed

Redis

What does it mean?

WATCH was sent while inside an open MULTI block. For optimistic locking, WATCH must put keys under watch BEFORE the transaction starts; if called after MULTI it is rejected. The error does not abort the transaction; only WATCH fails and nothing is watched.

Why does it happen?

WATCH and MULTI written in reverse order in code (MULTI first, then WATCH); calling WATCH inside the client library's pipeline/transaction wrapper; or using a pooled connection left in MULTI state. In this case EXEC runs even if the keys expected to be watched have changed; the expected conflict protection does not kick in.

How to fix it

Correct order: WATCH key -> (read values) -> MULTI -> commands -> EXEC. If EXEC returns nil, a watched key changed; retry the operation from the start. Use the client library's WATCH/transaction API (e.g., watch + pipeline helpers). Note: pub/sub commands such as SUBSCRIBE are not rejected inside MULTI; they are queued and the connection switches to subscribe mode after EXEC; this is also not recommended, use a dedicated connection for pub/sub.

Open in DBAtlas →

More from this engine