Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redis Transaction rollback

Tags:

redis

hiredis

I am new to redis. I have an application in which i have multiple redis commands which makes a transaction. If one of them fails does redis rollback the transaction like relational databases ? Is it users responsibility to rollback the transaction ?

like image 419
Vishnu Avatar asked Apr 24 '13 07:04

Vishnu


People also ask

What happens if a command in a Redis transaction fails?

It's important to note that even when a command fails, all the other commands in the queue are processed – Redis will not stop the processing of commands. This time due to the syntax error the bad INCR command is not queued at all.

Are Redis transactions Atomic?

Redis transaction is also atomic. Atomic means either all of the commands or none are processed.

How many transactions can Redis handle?

Using a single AWS EC2 instance, Redis was able to achieve 1,200,000 transactions per second at <1 msec (sub millisecond) latency. Redis is an open source in-memory NoSQL database that has taken the developer community by storm.

What does Redis watch do?

The watch command in Redis allows you to implement the check-and-set feature. The WATCH commands accept Redis keys as parameters and monitor them. If any of the specified keys are changed before the EXEC command is called, Redis automatically terminates the transaction and returns a Null reply.


2 Answers

Redis does not rollback transactions like the relational databases does.

If you have a relational databases background, the fact that Redis commands can fail during a transaction, but still Redis will execute the rest of the transaction instead of rolling back, may look odd to you.

However there are good opinions for this behavior:

  • Redis commands can fail only if called with a wrong syntax (and the problem is not detectable during the command queuing), or against keys holding the wrong data type: this means that in practical terms a failing command is the result of a programming errors, and a kind of error that is very likely to be detected during development, and not in production.

  • Redis is internally simplified and faster because it does not need the ability to roll back.

Check it out Why redis does not support rollback transactions from the documentation and from here .

like image 120
Gopinagh.R Avatar answered Oct 03 '22 12:10

Gopinagh.R


Documentaion here. Redis does not supports rollback.

like image 37
Biswanath Avatar answered Oct 03 '22 13:10

Biswanath