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

fix: gcs manager cancels context #2662

merged 1 commit into from
Nov 7, 2022

Conversation

BonapartePC
Copy link
Contributor

@BonapartePC BonapartePC commented Nov 7, 2022

Description

GCS Manager creates an iterator to fetch objects. Bug: We were passing context to it and later cancelling at the end of the function call although the iterator will be used for every call of the function

Notion Ticket

https://www.notion.so/rudderstacks/Fix-GCS-Replay-2dd4e0f0e97942a5bcce282a5f61ea77

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

@codecov
Copy link

codecov bot commented Nov 7, 2022

Codecov Report

Base: 43.73% // Head: 45.42% // Increases project coverage by +1.68% 🎉

Coverage data is based on head (940d097) compared to base (43dde0c).
Patch coverage: 70.31% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2662      +/-   ##
==========================================
+ Coverage   43.73%   45.42%   +1.68%     
==========================================
  Files         191      287      +96     
  Lines       40483    47785    +7302     
==========================================
+ Hits        17707    21708    +4001     
- Misses      21671    24697    +3026     
- Partials     1105     1380     +275     
Impacted Files Coverage Δ
config/backend-config/types.go 74.07% <ø> (+74.07%) ⬆️
enterprise/reporting/noop.go 50.00% <0.00%> (+50.00%) ⬆️
services/filemanager/gcsmanager.go 33.54% <ø> (+3.29%) ⬆️
services/streammanager/kafka/client/producer.go 82.24% <46.66%> (+1.85%) ⬆️
enterprise/reporting/reporting.go 15.89% <66.66%> (+6.12%) ⬆️
services/streammanager/kafka/kafkamanager.go 75.40% <100.00%> (+12.18%) ⬆️
config/backend-config/namespace_config.go 70.83% <0.00%> (-3.13%) ⬇️
router/router.go 74.04% <0.00%> (ø)
utils/googleutils/googleutils.go 85.71% <0.00%> (ø)
services/alert/pagerduty.go 0.00% <0.00%> (ø)
... and 177 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@BonapartePC BonapartePC marked this pull request as ready for review November 7, 2022 17:20
@BonapartePC BonapartePC merged commit 0964e83 into master Nov 7, 2022
@chandumlg chandumlg deleted the fix.gcs branch November 7, 2022 17:47
@@ -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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants