Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally delete stale distributed state #55

Merged
merged 3 commits into from
Jun 12, 2024

Conversation

divergentdave
Copy link
Contributor

This adds a new optional configuration parameter, to allow deleting stale distributed rate limiter state. Closes #50.

I have manually tested this locally, next I plan to add unit testing.

@divergentdave
Copy link
Contributor Author

FWIW, I saw the following error a few times after testing a large flux of instances in and out of a deployment. This can happen due to a race condition when one instance deletes a stale entry in the window between when another instance lists and reads the entry. This error message is still useful for identifying real problems with a storage backend, so I think the best option for now is to leave it as-is and accept the log noise. Depending on the storage backend, the ideal way to fix the noise would be to list and read the entries in one transaction, or to skip listing up-front, and iterate over all entries using some sort of cursor. That will have to wait for a v2 of the Storage interface.

{
    "level": "ERROR",
    "timestamp": "2024-06-12T15:23:38.418344685Z",
    "logger": "http.handlers.rate_limit",
    "msg": "unable to load distributed rate limiter state",
    "key": "rate_limit/instances/7303b16e-44dd-4dcf-b4dd-d6134d2ba788.rlstate",
    "error": "file does not exist"
}

Copy link
Owner

@mholt mholt left a comment

Choose a reason for hiding this comment

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

Looks good. Just one minor nit about phrasing, but I'd accept this as-is too. Thank you!

distributed.go Show resolved Hide resolved
distributed.go Outdated Show resolved Hide resolved
@divergentdave divergentdave marked this pull request as ready for review June 12, 2024 19:04
@mholt mholt merged commit 9f619ad into mholt:master Jun 12, 2024
3 checks passed
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.

Storage keys from ephemeral Caddy instances are never deleted
2 participants