Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

Add watching dog to extend TTL #30

Open
TsingJyujing opened this issue Nov 14, 2019 · 4 comments
Open

Add watching dog to extend TTL #30

TsingJyujing opened this issue Nov 14, 2019 · 4 comments

Comments

@TsingJyujing
Copy link

I'd like to implement a function like we can extend a lock every N secs, the purpose to do that is designed for some transaction that can't control the timeout, but we also want the lock be released while the server is down.

Do you have any advice?

@eedalong
Copy link

eedalong commented Dec 30, 2019

@TsingJyujing

  1. if u want to use watchdog feature, u can just use redission with java
  2. I've been thinking about this problem this morning, and I came to a rough conclusion that, if we dont want write a new redis client, maybe multithread can be one of the solutions to this problem.I mean use another thread to check and extend the lock for N secs. This can ensure that
    a) if the server goes down, the thread also dies, and the lock will not be extended, so the lock can be auto released by redis
    however, this solution may have some bad effect on the performance of the worker thread.

@TsingJyujing
Copy link
Author

@eedalong
Thank you for reply!!!!

I can't use Java because I'm writing a server with Python (the deep reason is PIL is convient in Python and Java do not have a such useful lib).

And I think it's also tricky to stop/kill the thread, I think we should use context manager to make a high level API to manage these troublism things like we described in #25 .

If you have intention to make this high level API, I'd like to make a PR, how about you idea?

@eedalong
Copy link

eedalong commented Jan 9, 2020

@TsingJyujing check this out https://zhuanlan.zhihu.com/p/101913195

@brainix
Copy link

brainix commented Mar 18, 2021

Pottery’s implementation of Redlock has an .extend() method that does what you’re looking for. Disclaimer: I develop/maintain Pottery. Good luck!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants