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

Drop unnecessary expire time check in ttl event handler #385

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

brandond
Copy link
Member

Follow-up to the discussion at #382 (comment)

handleTTLEvents already calls loadTTLEventKV which gets the most recent event for the key while holding a lock. This is then checked to confirm expiration before calling deleteTTLEvent.

Because it's checked before calling, we don't need to do a locked check of the store AGAIN in deleteTTLEvent. If another goroutine updated the key in the time between when loadTTLEventKV returned the event, and the time that deleteTTLEvent tries to delete it, the actual Delete will fail because the modRevision is no longer current, and the error path will ensure that the key is re-enqueued and processed at the correct time.

@brandond brandond requested a review from a team as a code owner December 16, 2024 20:09
handleTTLEvents already calls loadTTLEventKV which gets the most recent
event for the key while holding a lock. This is then checked to confirm
expiration before calling deleteTTLEvent.

Because it's checked before calling, we don't need to do a locked check
of the store AGAIN in deleteTTLEvent. If another goroutine updated the
key in the time between when loadTTLEventKV returned the event, and the
time that deleteTTLEvent tries to delete it, the actual Delete will fail
because the modRevision is no longer current, and the error path will
ensure that the key is re-enqueued and processed at the correct time.

Without this extra check there's not much logic left in deleteTTLEvent,
and there are no other call sites, so just move it into handleTTLEvents.

Signed-off-by: Brad Davidson <[email protected]>
@brandond brandond force-pushed the drop-redundant-ttl-check branch from 3746ea8 to e149b21 Compare December 18, 2024 09:32
@brandond brandond merged commit a4169b9 into k3s-io:master Dec 18, 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.

2 participants