fix: Handle concurrent map writes#18538
Merged
Merged
Conversation
erezrokah
commented
Jul 9, 2024
| objKey := c.spec.ReplacePathVariables(table.Name, uuid.NewString(), time.Now().UTC(), c.syncID) | ||
| // if object was already initialized, use the same key | ||
| // We don't need any locking here because all messages for the same table are processed sequentially | ||
| c.initializedTablesLock.Lock() |
Member
Author
There was a problem hiding this comment.
I don't think we can use a RWMutex sync we want the entire operation to be atomic
bbernays
reviewed
Jul 9, 2024
| table := msg.GetTable() | ||
| objKey := c.spec.ReplacePathVariables(table.Name, uuid.NewString(), time.Now().UTC(), c.syncID) | ||
| // if object was already initialized, use the same key | ||
| // We don't need any locking here because all messages for the same table are processed sequentially |
Collaborator
There was a problem hiding this comment.
Why is this assumption not true anymore? Or was it never true?
Member
Author
There was a problem hiding this comment.
Looking at the batch code (even before cloudquery/plugin-sdk#1719) I'm not sure we ever had a guarantee that WriteTable is not called from multiple Go routines
bbernays
approved these changes
Jul 9, 2024
Member
Author
|
We decided to ship this hot fix for s3 then look at the SDK code to see what's causing |
kodiakhq Bot
pushed a commit
that referenced
this pull request
Jul 9, 2024
🤖 I have created a release *beep* *boop* --- ## [7.2.8](plugins-destination-s3-v7.2.7...plugins-destination-s3-v7.2.8) (2024-07-09) ### Bug Fixes * **deps:** Update module github.com/cloudquery/plugin-sdk/v4 to v4.49.3 ([#18513](#18513)) ([d12da90](d12da90)) * Handle concurrent map writes ([#18538](#18538)) ([34fb27a](34fb27a)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes https://github.com/cloudquery/cloudquery-issues/issues/1999 (hopefully).
While the comment in the code is correct and all messages for the same table are processed sequentially, I don't think there's a guarantee that
WriteTableis not called from multiple concurrent Go routines