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

Add atomic writes to local backend #528

Closed
wants to merge 2 commits into from

Conversation

mac-chaffee
Copy link

Fixes #527

Also I noticed the tests were writing to ../../.test which is outside the repo's directory when you run make test, so I moved that path back to ./.test.

@@ -35,7 +36,20 @@ func NewLocalFilesystemBackend(rootDirectory string) *LocalFilesystemBackend {
if err != nil {
panic(err)
}
b := &LocalFilesystemBackend{RootDirectory: absPath}
// Create a temporary folder for partially-completed writes (if not present)
tempPath := filepath.Join(absPath, ".tmp")
Copy link
Collaborator

@cbuto cbuto Apr 27, 2022

Choose a reason for hiding this comment

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

this temp directory creation might be better suited in the PutObject function (like we do with the RootDirectory). This way the temp directory will always be recreated if it doesn't exist during a put, so if that directory was deleted while chartmuseum is running, uploads will continue to work without restarting chartmuseum.

Copy link
Author

Choose a reason for hiding this comment

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

That would require an extra stat per invocation of PutObject. Do we really want that performance overhead?

Copy link
Collaborator

Choose a reason for hiding this comment

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

that is definitely a consideration, but it seems like we should be treating the root dir and this new dir similarly. i.e. either both are created in NewLocalFilesystemBackend or both are created in PutObject. @jdolitsky @scbizu do you have any thoughts here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

For @cbuto 's consideration , how about do anther os.MkdirAll() and ignore the dir already exist error in PutObject , I agree with cbuto's opinion and it is maybe reasonable even we do some overhead tradeoff here.

@mac-chaffee mac-chaffee closed this by deleting the head repository Sep 13, 2024
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.

Request: Support atomic writes for local storage backend
3 participants