Tuesday, March 26, 2013

Redis Transactions ve Rollback

Azizim transaction denildiğinde iki ana başlık temeldir "Rollback" ve "Rollforward" [1]. Hatta bana sorarsan en önemli olay rollbak olayıdır. Bir şeyler fena halde sarpa sararsa bir şeyler kötü giderse rollback eylersin. 
Lakin benim de pek sevdiğim Redis'de işler böyle yürümüyor. 
Redis özelliklerinni listelendiği sayfada "Transaction" da yer alıyor : 

Fakat redis transaction ile şunu kastediyor :
  1. Failsafe query
  2. Sorgularınızın ya tamamı çalışır ya da hiç biri çalışmaz.
Aklınızda olsun her transaction özelliği rollback özelliği var demek olmuyor. Redis'de kendiniz rollback yapacaksınız. 
Redisin bu duruma mantıklı bir açıklaması var tabi 

Why Redis does not support roll backs?
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 queueing), 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.
An argument against Redis point of view is that bugs happen, however it should be noted that in general the roll back does not save you from programming errors. For instance if a query increments a key by 2 instead of 1, or increments the wrong key, there is no way for a rollback mechanism to help. Given that no one can save the programmer from his errors, and that the kind of errors required for a Redis command to fail are unlikely to enter in production, we selected the simpler and faster approach of not supporting roll backs on errors.


Konuyla ilgili diğer bağlantılar






[1] Transaction processing : http://en.wikipedia.org/wiki/Transaction_processing

No comments: