Skip to content

fix: Fix deadlock in BigQuery destination if error occurs during write#5550

Merged
kodiakhq[bot] merged 3 commits intomainfrom
fix-bq-deadlock
Dec 13, 2022
Merged

fix: Fix deadlock in BigQuery destination if error occurs during write#5550
kodiakhq[bot] merged 3 commits intomainfrom
fix-bq-deadlock

Conversation

@hermanschaaf
Copy link
Copy Markdown
Contributor

This fixes a deadlock that occurs if the BigQuery destination encounters an error that causes one of the writers to fail. Previously, the loop would have continued to try and send items to the channel, but these would not get processed. We now check that gctx is not done, and exit the loop either when gctx is done (so a worker error occurred) or r, ok := <-res has ok as false, which means the res channel was closed.

This issue might also happen in some other destinations, I will take a look there shortly.

@hermanschaaf hermanschaaf requested review from a team and candiduslynx and removed request for a team December 12, 2022 15:23
@hermanschaaf hermanschaaf added the automerge Automatically merge once required checks pass label Dec 13, 2022
@kodiakhq kodiakhq bot merged commit e087095 into main Dec 13, 2022
@kodiakhq kodiakhq bot deleted the fix-bq-deadlock branch December 13, 2022 07:47
kodiakhq bot pushed a commit that referenced this pull request Dec 13, 2022
(Similar to: #5550)

If a worker returns an error, it will no longer be consuming from its `writeChan`, and in this case we should exit the loop early to avoid deadlock.
kodiakhq bot pushed a commit that referenced this pull request Dec 13, 2022
🤖 I have created a release *beep* *boop*
---


## [1.1.2](plugins-destination-bigquery-v1.1.1...plugins-destination-bigquery-v1.1.2) (2022-12-13)


### Bug Fixes

* BigQuery destination: wait for table migrations to complete ([#5544](#5544)) ([712ee39](712ee39))
* **deps:** Update module github.com/cloudquery/plugin-sdk to v1.12.0 ([#5539](#5539)) ([fb71293](fb71293))
* Fix deadlock in BigQuery destination if error occurs during write ([#5550](#5550)) ([e087095](e087095))

---
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

automerge Automatically merge once required checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants