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

Memcached: Fix issue where non-zero TTLs were trunctated to zero #530

Merged
merged 1 commit into from
Jun 11, 2024

Conversation

56quarters
Copy link
Contributor

@56quarters 56quarters commented Jun 11, 2024

What this PR does:

Fixes an issue where if a non-zero TTL smaller than a full second was passed to the SetAsync or SetMultiAsync methods, the TTL would be truncated to zero seconds which results in the item being cached forever.

Specifically, this fixes an issue in Mimir where items that were supposed to have a several minute TTL computed as $ttl - time.Since($start) ended up being cached forever. They were never evicted by Memcached because there was no need to free space in this particular cache due to low usage.

Which issue(s) this PR fixes:

Internal postmortem

Checklist

  • Tests updated
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Fixes an issue where if a non-zero TTL smaller than a full second was passed
to the `SetAsync` or `SetMultiAsync` methods, the TTL would be truncated to
zero seconds which results in the item being cached forever.

Specifically, this fixes an issue in Mimir where items that were supposed to
have a several minute TTL computed as `$start - $desired_ttl` ended up being
cached forever. They were never evicted by Memcached because there was no need
to free space in this particular cache due to low usage.

Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
@56quarters 56quarters force-pushed the 56quarters/memcached-zero-ttl branch from 9388145 to 6628102 Compare June 11, 2024 16:57
@56quarters 56quarters marked this pull request as ready for review June 11, 2024 17:04
@56quarters 56quarters merged commit 87c7e9e into main Jun 11, 2024
6 checks passed
@56quarters 56quarters deleted the 56quarters/memcached-zero-ttl branch June 11, 2024 17:17
56quarters added a commit to grafana/mimir that referenced this pull request Jun 11, 2024
Specifically, pulls in grafana/dskit#530 to fix an
issue where we may inadvertently cache things forever.

Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
56quarters added a commit to grafana/mimir that referenced this pull request Jun 11, 2024
Specifically, pulls in grafana/dskit#530 to fix an
issue where we may inadvertently cache things forever.

Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
56quarters added a commit to grafana/mimir that referenced this pull request Jun 11, 2024
Specifically, pulls in grafana/dskit#530 to fix an
issue where we may inadvertently cache things forever.

Signed-off-by: Nick Pillitteri <nick.pillitteri@grafana.com>
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