Skip to content

Clear memcache keys after unlock - #16800

Closed
icewind1991 wants to merge 3 commits into
masterfrom
compare-and-delete-locking
Closed

icewind1991 wants to merge 3 commits into
masterfrom
compare-and-delete-locking

Conversation

@icewind1991

Copy link
Copy Markdown
Contributor

This adds compare-and-delete to the memcache backend (emulated for everything but redis atm)

For redis cad and cas are implemented using eval which allows running lua scripts atomically on the server.

cc @DeepDiver1975 @PVince81

@scrutinizer-notifier

Copy link
Copy Markdown

A new inspection was created.

@PVince81

PVince81 commented Jun 8, 2015

Copy link
Copy Markdown
Contributor

@icewind1991 did you have a look if it was possible to use a transaction instead of Lua scripts ?
Just a bit worried that evaluating such scripts could affect performance.

@PVince81

PVince81 commented Jun 8, 2015

Copy link
Copy Markdown
Contributor

I'll have a test nevertheless.

@icewind1991

Copy link
Copy Markdown
Contributor Author

Transactions dont allow conditional statements which we need here.

According to the redis documentation the overhead for using a script is very low

@PVince81

PVince81 commented Jun 8, 2015

Copy link
Copy Markdown
Contributor

Hmm right. I was wrong in my reasoning.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seriously? Do we want to walk this path?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And I thought I have seen everything 😄

@PVince81

PVince81 commented Jun 8, 2015

Copy link
Copy Markdown
Contributor

Tested with csync's "t1.pl" suite. The keys were properly removed afterwards.

👍

I'd also like to get an opinion from redis fan @butonic

I do agree with @DeepDiver1975 that using Lua scripts sounds wrong here.
I wonder if redis is really a good idea for such things as locking.

Isn't it possible to start a transaction in one call, read a value in PHP, then delete it, then finish the transaction ? It seems that the MULTI command is only for passing a one-shot multi-list of commands.

@DeepDiver1975

Copy link
Copy Markdown
Contributor

I wonder if redis is really a good idea for such things as locking.

Isn't it possible to start a transaction in one call, read a value in PHP, then delete it, then finish the transaction ? It seems that the MULTI command is only for passing a one-shot multi-list of commands.

well - the original idea (as in design precondition) was to NOT use the database because we wanted easy and fast (?) access. Meanwhile this sounds as complicated as doing it directly in the database.

Time for a database based locking provider??????

@PVince81

PVince81 commented Jun 8, 2015

Copy link
Copy Markdown
Contributor

@icewind1991

Copy link
Copy Markdown
Contributor Author

I will try it with using WATCH but I would think this approach is faster since there are less roundtrips to redis

@icewind1991

Copy link
Copy Markdown
Contributor Author

076810c implements cas and cad using WATCH

We should check if there is a significant performance difference between the implementations

@ghost

ghost commented Jun 8, 2015

Copy link
Copy Markdown

🚀 Test PASSed.🚀
chuck

@PVince81

PVince81 commented Jun 9, 2015

Copy link
Copy Markdown
Contributor

@icewind1991 I submit your branch as PR here #16821 (because floating branches/commits aren't convenient to review)

@PVince81

PVince81 commented Jun 9, 2015

Copy link
Copy Markdown
Contributor

@icewind1991 test results here: #16821 (comment)

I still vote for the WATCH approach

@PVince81 PVince81 added this to the 8.1-current milestone Jun 12, 2015
@icewind1991

Copy link
Copy Markdown
Contributor Author

Closing in favor of #16821

@DeepDiver1975
DeepDiver1975 deleted the compare-and-delete-locking branch June 15, 2015 12:06
@lock lock Bot locked as resolved and limited conversation to collaborators Aug 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants