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

fix: gcs manager cancels context #2662

Merged
merged 1 commit into from
Nov 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions services/filemanager/gcsmanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ func (manager *GCSManager) ListFilesWithPrefix(ctx context.Context, startAfter,
return
}

ctx, cancel := context.WithTimeout(ctx, manager.getTimeout())
defer cancel()

// Create GCS Bucket handle
if manager.Config.Iterator == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

@BonapartePC why are we caching the iterator? Is this thread safe??

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The way this function is being used is: With a given manager, calling subsequent ListFilesWithPrefix() should return us continuous items one after the other. This is the reason we cache it in the manager itself.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is not safe, we need to revisit. Can we guarantee that filemanager will be used exclusively by one goroutine and then never reused?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

this is a bad api design, I am confident we can do much better than that

manager.Config.Iterator = client.Bucket(manager.Config.Bucket).Objects(ctx, &storage.Query{
Expand Down