
Currently, for nested MULTI or executing WATCH in MULTI, we will return an error but we will not abort the transaction. ``` 127.0.0.1:6379> multi OK 127.0.0.1:6379(TX)> multi (error) ERR MULTI calls can not be nested 127.0.0.1:6379(TX)> set key value QUEUED 127.0.0.1:6379(TX)> exec 1) OK 127.0.0.1:6379> multi OK 127.0.0.1:6379(TX)> watch key (error) ERR WATCH inside MULTI is not allowed 127.0.0.1:6379(TX)> set key value QUEUED 127.0.0.1:6379(TX)> exec 1) OK ``` This is an unexpected behavior that should abort the transaction. The number of elements returned by EXEC also doesn't match the number of commands in MULTI. Add the NO_MULTI flag to them so that they will be rejected in processCommand and rejectCommand will abort the transaction. So there are two visible changes: - Different words in the error messages. (Command not allowed inside a transaction) - Exec returns error. Signed-off-by: Binbin <binloveplay1314@qq.com>
52 lines
1.2 KiB
JSON
52 lines
1.2 KiB
JSON
{
|
|
"WATCH": {
|
|
"summary": "Monitors changes to keys to determine the execution of a transaction.",
|
|
"complexity": "O(1) for every key.",
|
|
"group": "transactions",
|
|
"since": "2.2.0",
|
|
"arity": -2,
|
|
"function": "watchCommand",
|
|
"command_flags": [
|
|
"NOSCRIPT",
|
|
"LOADING",
|
|
"STALE",
|
|
"FAST",
|
|
"NO_MULTI",
|
|
"ALLOW_BUSY"
|
|
],
|
|
"acl_categories": [
|
|
"TRANSACTION"
|
|
],
|
|
"key_specs": [
|
|
{
|
|
"flags": [
|
|
"RO"
|
|
],
|
|
"begin_search": {
|
|
"index": {
|
|
"pos": 1
|
|
}
|
|
},
|
|
"find_keys": {
|
|
"range": {
|
|
"lastkey": -1,
|
|
"step": 1,
|
|
"limit": 0
|
|
}
|
|
}
|
|
}
|
|
],
|
|
"reply_schema": {
|
|
"const": "OK"
|
|
},
|
|
"arguments": [
|
|
{
|
|
"name": "key",
|
|
"type": "key",
|
|
"key_spec_index": 0,
|
|
"multiple": true
|
|
}
|
|
]
|
|
}
|
|
}
|