Redis does not guarantee consistency. You didn't account for the case that the Redis instances crashes while the commands within the EXEC are running. Since there is no rollback, writes can not be undone and your data will be in an inconsistent state.
To be more precise, this is true not only because of instance crashes, but for any error that would arise during EXEC time. So if for instance your transaction includes an LPOP command on a non-list key, this command will generate an error at exec-time. The client will receive an error for that LPOP, and will thus consider the transaction as failed. But the execution of the other commands of the transaction will proceed despite that LPOP error; because there are no roll-backs, the state changes that occurred as part of the transaction will still be there. So it's not really atomic.
@vbcodep what about redis-check-aof? It comes with redis by default and cleans the AOF file from any corrupted transactions to avoid these possible inconsistencies.
Is there an equivalent to Integrity Constraints, to say that a key (eg _account_ key) cannot be less than 0? I see that you're using WATCH as way to avoid such a problem, so I suppose that there's no such thing as Integrity Constraints in Redis?
Thanks a lot for the explanation, I really like your smile.
Great content! Keep going!
Thank you!
Useful and fast, very helpful
Thanks for sharing!
Redis does not guarantee consistency. You didn't account for the case that the Redis instances crashes while the commands within the EXEC are running. Since there is no rollback, writes can not be undone and your data will be in an inconsistent state.
To be more precise, this is true not only because of instance crashes, but for any error that would arise during EXEC time. So if for instance your transaction includes an LPOP command on a non-list key, this command will generate an error at exec-time. The client will receive an error for that LPOP, and will thus consider the transaction as failed. But the execution of the other commands of the transaction will proceed despite that LPOP error; because there are no roll-backs, the state changes that occurred as part of the transaction will still be there. So it's not really atomic.
nice to know! thanks for sharing!
@vbcodep what about redis-check-aof? It comes with redis by default and cleans the AOF file from any corrupted transactions to avoid these possible inconsistencies.
@@ggman8216 If the transaction does complete all commands during the EXEC then the change is not recorded in the AOF.
Amazing!
Thank you!
that forced smile 😆
Looks like a Canadian speaking from South Park.
@zz-ox7ud that was a funny one 😂
Is there an equivalent to Integrity Constraints, to say that a key (eg _account_ key) cannot be less than 0? I see that you're using WATCH as way to avoid such a problem, so I suppose that there's no such thing as Integrity Constraints in Redis?
Great question! That is true. Redis does not have a built-in implementation for integrity constraints.
@@marcelamiontakayanagi9672 thanks!
I think that transactions in redis does not work this way.
why are you trying to smile all the time?
Because Im a happy person. Thanks for noticing!