Redis Lock Primite

29 views
Skip to first unread message

Yair Lenga

unread,
Jun 30, 2021, 11:26:35 AM6/30/21
to Redis DB
I'm working on an application, which need to implement distributed locking.

I've found the page: https://redis.io/topics/distlock, which provide explanation on how to do it right with current commands, with references to implementation in multiple languages.

My question: Given that
* The locking problem is common to many applications.
* Many database system provide support for explciit locking
* Redis already has the "SETNX" to atomically acquire a lock

Why doesn't Redis include "DEL-IF-MATCH" that will provide safe, bullet-proof unlock operator in a single round-trip. No transactions, no LUA scripts, no libraries, no corner cases.

DEL-IF-MATCH key value  -- Delete key, only if it currently holds "value"

Yair

Itamar Haber

unread,
Jun 30, 2021, 11:31:32 AM6/30/21
to Redis DB

Hello Yair,

I believe you can find precious insights into this topic at https://groups.google.com/g/redis-db/c/a4zK2k1Lefo/m/hOjM9iwDGhIJ

Cheers,
Itamar

Yair Lenga

unread,
Jul 5, 2021, 1:07:11 PM7/5/21
to redi...@googlegroups.com, ita...@redislabs.com
Hi Itamar,

Thanks for the point regard the CAS limitations.

I agree about the point of tje known limitations for the CAS, and it is far from a perfect solution.

The article also highlights the need for a (long-term) solution for the locking/unlocking use cases (and few similar TX related scenarios). Hopefully, a solution that does not require complex Lua scripting. I hope that the redis lab team can review this issue, and give it the proper priority - to solve a problem that large number of your users are facing, or a regular basis. Trying to be practical - any solution (even if it's currently not perfect) is better than no solution.

Thanks again,
Yair



Disclaimer

The information contained in this communication from the sender is confidential. It is intended solely for use by the recipient and others authorized to receive it. If you are not the recipient, you are hereby notified that any disclosure, copying, distribution or taking action in relation of the contents of this information is strictly prohibited and may be unlawful.

--
You received this message because you are subscribed to a topic in the Google Groups "Redis DB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/redis-db/QtzJBDoER1M/unsubscribe.
To unsubscribe from this group and all its topics, send an email to redis-db+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/redis-db/3de33a8f-6eee-4fd9-a958-f87e572c8c64n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages