0

We are trying to design a distributed transaction across multiple Redis databases. Is it possible to use Lua Script to achieve this? We do not want to implement via 2 phase commit, as that can cause data loss. We cannot afford to have data loss.

Example scenario: I have 3 Redis DBs. We need to update all 3. Updates can be sequential, but we want to end the transaction with success only if all three are successful. If any one of them fails, we should be able to rollback all of them.

1 Answer 1

0

No, it's impossible to implement distributed transactions between Redis instances relying on Lua scripts only because Redis doesn't expose libraries for network calls. However, you can use Lua scripts as parts of a solution to build distributed transactions (I used Lua scripts to implement Paxos on top of Redis servers).

BTW, in your question, there is a misconception about 2 phase commit causing data loss. It can't happen. The textbook implementation of 2PC may lead to a situation when a system is blocked but it doesn't lead to data loss. But even blocking isn't an issue because there are non-blocking versions of 2PC, like the one from the Percolator paper by Google.

I've created a visualization of non-blocking 2PC. It may help you to understand its moving parts.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.