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

Move unlock call to a background context in GC #2198

Merged
merged 1 commit into from
Jan 9, 2025

Conversation

josephschorr
Copy link
Member

This ensures that if the GC operation times out, the unlock still can run

@github-actions github-actions bot added the area/datastore Affects the storage system label Jan 9, 2025
@josephschorr josephschorr marked this pull request as ready for review January 9, 2025 21:30
@josephschorr josephschorr requested a review from a team as a code owner January 9, 2025 21:30
@github-actions github-actions bot added the area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) label Jan 9, 2025
@josephschorr josephschorr force-pushed the gc-background-ctx branch 2 times, most recently from 20c8720 to 780f704 Compare January 9, 2025 21:40
tstirrat15
tstirrat15 previously approved these changes Jan 9, 2025
Copy link
Contributor

@tstirrat15 tstirrat15 left a comment

Choose a reason for hiding this comment

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

Added a comment for my own edification, LGTM

internal/datastore/common/gc.go Outdated Show resolved Hide resolved
tstirrat15
tstirrat15 previously approved these changes Jan 9, 2025
Copy link
Contributor

@tstirrat15 tstirrat15 left a comment

Choose a reason for hiding this comment

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

LGTM

@josephschorr josephschorr enabled auto-merge January 9, 2025 21:45
@josephschorr josephschorr force-pushed the gc-background-ctx branch 3 times, most recently from 216010f to 013f1ab Compare January 9, 2025 22:00
err := gc.UnlockAfterGCRun(ctx)
// NOTE: this uses a separate context to run the DB unlock logic, ensuring that
// a timeout in the parent context won't prevent a lock release.
err := gc.UnlockAfterGCRun(context.Background())
Copy link
Contributor

Choose a reason for hiding this comment

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

wouldn't this be clearer?

err := gc.UnlockAfterGCRun()

and then the implementations for the datastores can handle it as appropriate (i.e. it may make sense to have an internal timeout and kill the session)

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure if it is clearer (as a caller I'd expect a context), but I can document it

This ensures that if the GC operation times out, the unlock still can run
@josephschorr
Copy link
Member Author

Updated

Copy link
Contributor

@tstirrat15 tstirrat15 left a comment

Choose a reason for hiding this comment

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

LGTM

@josephschorr josephschorr added this pull request to the merge queue Jan 9, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 9, 2025
@josephschorr josephschorr added this pull request to the merge queue Jan 9, 2025
Merged via the queue into authzed:main with commit 7b9f388 Jan 9, 2025
23 checks passed
@josephschorr josephschorr deleted the gc-background-ctx branch January 9, 2025 22:49
@github-actions github-actions bot locked and limited conversation to collaborators Jan 9, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/datastore Affects the storage system area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants