-
Notifications
You must be signed in to change notification settings - Fork 925
chore: use database in current context for file cache #18490
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
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
353f193
to
2a37b9b
Compare
2a37b9b
to
a33fad3
Compare
635c56b
to
b7985e3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the file cache implementation to use the current database context when acquiring files, thereby preventing potential deadlocks when running in a transaction. Key changes include:
- Updating the Acquire method signatures in files/closer.go, files/cache.go, and related files to accept an explicit database.Store parameter.
- Modifying tests in cache_test.go and other parts of the code to use the updated Acquire method.
- Removing the deprecated NewFromStore constructor and switching to the new New constructor in coderd/coderd.go.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
coderd/files/closer.go | Updated Acquire method signature to include a database parameter. |
coderd/files/cache_test.go | Adjusted test calls to use the new signature for Acquire. |
coderd/files/cache.go | Changed Acquire and prepare functions to accept db, and moved fetch logic to a package-level func. |
coderd/dynamicparameters/render.go | Updated Acquire calls with db parameter for template and module file acquisition. |
coderd/coderd.go | Replaced the deprecated NewFromStore with the new New constructor for FileCache. |
Comments suppressed due to low confidence (1)
coderd/files/cache.go:140
- Update the function documentation to reflect the addition of the db parameter and explain its role in avoiding deadlocks by providing the current database context.
func (c *Cache) Acquire(ctx context.Context, db database.Store, fileID uuid.UUID) (*CloseFS, error) {
b7985e3
to
467aca3
Compare
a33fad3
to
9245e87
Compare
Using the db.Store when in a TX causes a deadlock for dbmem. In production, this can cause a deadlock if at the current conn pool limit.
9245e87
to
7349e1f
Compare
467aca3
to
659b787
Compare
043cd58
to
37c71f1
Compare
Using the db.Store when in a TX causes a deadlock for dbmem.
In production, this can cause a deadlock if at the current conn pool
limit.
Example: