Reputation: 405
I've got several question about using transactions from StackExchange.Redis:
{1}
hashtag and second command's key has {2}
hashtag.Execute()
/ExecuteAsync()
returns false
? Only when set conditions were not met? Could it return false
if there were no conditions set?Execute()
/ExecuteAsync()
throw or just return false
? Should I also check commands' tasks (assuming that commands are fully correct and normally are not expected to throw) or they will just be cancelled?Unfortunately the doc doesn't explain #2 and #3 in details.
Upvotes: 12
Views: 3934
Reputation: 405
I've digged a bit into StackExchange.Redis source code and played with the driver, here are my observations:
ITransaction
instanceExecute()
/ExecuteAsync()
The answers seem to be the following:
Execute()
/ExecuteAsync()
returns false
in two cases: when transaction was discarded because conditions were not met, and when driver failed to queue the command (for example because of server OOM). All command tasks will be marked as canceled. Also Execute()
/ExecuteAsync()
does not return false
if one of the commands failed during execution (for example, because of wrong type operation).Execute()
/ExecuteAsync()
will throw an exception and all commands tasks will remain in "waiting for activation" state.To sum it up, command tasks should only be checked if Execute()
/ExecuteAsync()
returned true
: every task will either contain a result or an error (see Exception
property).
Upvotes: 8
Reputation: 1258
You can't send multi-key operations with multi cluster keys.
A command may fail to be queued, so there may be an error before EXEC is called. For instance the command may be syntactically wrong (wrong number of arguments, wrong command name, ...), or there may be some critical condition like an out of memory condition (if the server is configured to have a memory limit using the maxmemory directive).
A command may fail after EXEC is called, for instance since we performed an operation against a key with the wrong value (like calling a list operation against a string value)." https://redis.io/topics/transactions
Upvotes: 2