Skip to content

Conversation

@erezrokah
Copy link
Member

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 WriteTable is not called from multiple concurrent Go routines

@erezrokah erezrokah requested review from a team, bbernays and blesniewski and removed request for a team and blesniewski July 9, 2024 20:59
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()
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we can use a RWMutex sync we want the entire operation to be atomic

@erezrokah erezrokah marked this pull request as draft July 9, 2024 21:03
@erezrokah erezrokah marked this pull request as ready for review July 9, 2024 21:04
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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why is this assumption not true anymore? Or was it never true?

Copy link
Member Author

Choose a reason for hiding this comment

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

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

@erezrokah
Copy link
Member Author

We decided to ship this hot fix for s3 then look at the SDK code to see what's causing WriteTable to be called from multiple Go routines

@erezrokah erezrokah added the automerge Automatically merge once required checks pass label Jul 9, 2024
@kodiakhq kodiakhq bot merged commit 34fb27a into main Jul 9, 2024
@kodiakhq kodiakhq bot deleted the fix/handle_s3_concurrent_write_table branch July 9, 2024 21:38
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).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/plugin/destination/s3 automerge Automatically merge once required checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants