Skip to content

fix: redis reacquire - #4319

Closed
seth-shi wants to merge 5 commits into
zeromicro:masterfrom
seth-shi:fix/redis-reacquire
Closed

fix: redis reacquire#4319
seth-shi wants to merge 5 commits into
zeromicro:masterfrom
seth-shi:fix/redis-reacquire

Conversation

@seth-shi

Copy link
Copy Markdown

see: TestRedisLock_SameAcquire test

@seth-shi

Copy link
Copy Markdown
Author

locker id just use as release key

@kevwan
kevwan self-requested a review August 19, 2024 15:31
@kevwan kevwan self-assigned this Aug 19, 2024
@kevwan
kevwan requested a review from zcong1993 August 19, 2024 15:32
@kevwan

kevwan commented Aug 19, 2024

Copy link
Copy Markdown
Contributor

Thanks for your contribution! Would you please resolve conflicts?

@kevwan kevwan changed the title Fix/redis reacquire fix: redis reacquire Aug 19, 2024
@seth-shi

Copy link
Copy Markdown
Author

done

@codecov

codecov Bot commented Aug 19, 2024

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.11%. Comparing base (8690859) to head (531ccf5).
Report is 124 commits behind head on master.

Additional details and impacted files
Files Coverage Δ
core/stores/redis/redislock.go 86.48% <100.00%> (+5.09%) ⬆️

... and 254 files with indirect coverage changes

@zcong1993

zcong1993 commented Aug 19, 2024

Copy link
Copy Markdown
Member

go-zero's redis lock is a bit like etcd's lease.
When you first acquire a lock with a TTL, you own the lock, then you can do two things:

  1. release the lock
  2. refresh TTL of the lock, recall Acquire method if you own the lock, same like keepalive of etcd's lease

So the lock's owner can call Acquire multi times, and will always return true if you own the lock.

@seth-shi

Copy link
Copy Markdown
Author

that' s a good explanation, but I think the lock should be for other language users not to create ambiguity. because distributed locks can't be reowned even by themselves

@seth-shi

Copy link
Copy Markdown
Author

a typical example is 'redis set nx ex'
the effect is the same whether it's the same client or a different client call

@kevwan

kevwan commented Aug 21, 2024

Copy link
Copy Markdown
Contributor

It's better to do a rebase, which will make your changes easy to review.

@seth-shi seth-shi closed this Aug 21, 2024
@seth-shi seth-shi reopened this Aug 21, 2024
@seth-shi seth-shi closed this Aug 21, 2024
@seth-shi seth-shi mentioned this pull request Aug 21, 2024
@seth-shi

Copy link
Copy Markdown
Author

new pr: #4325

@Issues-translate-bot

Copy link
Copy Markdown

Bot detected the issue body's language is not English, translate it automatically. 👯👭🏻🧑‍🤝‍🧑👫🧑🏿‍🤝‍🧑🏻👩🏾‍🤝‍👨🏿👬🏿


New on: https://github.com/zeromicro/joe-zero/pull/4325

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants