Skip to content

Lock.Refresh method: use provided RetryStrategy#83

Closed
iSerganov wants to merge 1 commit into
bsm:mainfrom
iSerganov:refresh_retry
Closed

Lock.Refresh method: use provided RetryStrategy#83
iSerganov wants to merge 1 commit into
bsm:mainfrom
iSerganov:refresh_retry

Conversation

@iSerganov
Copy link
Copy Markdown
Contributor

@iSerganov iSerganov commented Mar 27, 2026

At the moment Refresh method doesn't do any retries and returns immediately if Redis client encounters an error. I find it misleading since Refresh accepts Options which contain RetryStrategy. So why not to use it?

Also added comprehensive unit tests for Refresh

@dim, could you please have a look whether this change makes sense to you?

At the moment Refresh method doesn't do any retries and returns immediately if Redis client encounters an error. I find it misleading since Refresh accepts Options which contain RetryStrategy. So why not to use it?
Copy link
Copy Markdown
Member

@dim dim left a comment

Choose a reason for hiding this comment

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

Hey, so sorry, just noticed this PR. Missed it somehow completely - my apologies.

I genuinely appreciate the effort but I think you are doing too much for one PR. Could you please just submit the part where you apply the retry strategy on refresh only?

Comment thread redislock.go
}

func isRetryableRedisError(err error) bool {
return !redis.IsPermissionError(err)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why is this a retryable error?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Actually it's not, !redis.IsPermissionError(err) returns true if it is NOT a PermissionError, so this type of errors should never been retried.

Comment thread refresh_test.go

func setupMiniRedis(t *testing.T) (*miniredis.Miniredis, *redis.Client) {
t.Helper()
mr, err := miniredis.Run()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I tried this, but tests still failed for me

@dim
Copy link
Copy Markdown
Member

dim commented May 18, 2026

See #88

@dim dim closed this May 18, 2026
@iSerganov
Copy link
Copy Markdown
Contributor Author

See #88

@dim, thank you for fixing this for me! If you find it useful, I can submit a PR with miniredis usage in unit tests. Let me know what you think about it.

@dim
Copy link
Copy Markdown
Member

dim commented May 18, 2026

See #88

@dim, thank you for fixing this for me! If you find it useful, I can submit a PR with miniredis usage in unit tests. Let me know what you think about it.

I would prefer to use miniredis but it doesn't fully support scripting it seems. You can give it a try though

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.

2 participants