Skip to content
This repository was archived by the owner on Mar 5, 2026. It is now read-only.

feat: enable write retry and nack pending writes on reconnect#443

Merged
alvarowolfx merged 26 commits intogoogleapis:mainfrom
alvarowolfx:fix-ack-on-reconnect
May 3, 2024
Merged

feat: enable write retry and nack pending writes on reconnect#443
alvarowolfx merged 26 commits intogoogleapis:mainfrom
alvarowolfx:fix-ack-on-reconnect

Conversation

@alvarowolfx
Copy link
Copy Markdown
Contributor

This PR fix an issue that can happen when an error is returned by the service side and we trigger a reconnect, in some cases where a in-flight/pending write is still waiting for response can be left without any ack/nack.

Towards internal b/329875851

@alvarowolfx alvarowolfx requested a review from a team April 22, 2024 19:16
@product-auto-label product-auto-label Bot added size: m Pull request size is medium. api: bigquerystorage Issues related to the googleapis/nodejs-bigquery-storage API. labels Apr 22, 2024
@alvarowolfx alvarowolfx added the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 22, 2024
@gcf-owl-bot gcf-owl-bot Bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 22, 2024
Comment thread src/managedwriter/stream_connection.ts Outdated
Comment thread src/managedwriter/stream_connection.ts Outdated
@product-auto-label product-auto-label Bot added size: l Pull request size is large. and removed size: m Pull request size is medium. labels Apr 23, 2024
Comment thread src/managedwriter/stream_connection.ts Outdated
Comment thread src/managedwriter/stream_connection.ts Outdated
Comment thread src/managedwriter/writer_client.ts
Comment thread system-test/managed_writer_client_test.ts Outdated
it('should manage to send data in scenario where every 10 request drops the connection', async () => {
bqWriteClient.initialize();
const client = new WriterClient();
client.enableWriteRetries(true);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

You should also be able to test the nonretried behavior.

Comment thread src/managedwriter/stream_connection.ts Outdated
Comment thread src/managedwriter/stream_connection.ts Outdated
Comment thread src/managedwriter/stream_connection.ts Outdated
Comment thread src/managedwriter/stream_connection.ts Outdated
Comment thread src/managedwriter/stream_connection.ts Outdated
Comment thread src/managedwriter/stream_connection.ts Outdated
@alvarowolfx alvarowolfx changed the title fix: nack pending writes on reconnect feat: enable write retry and nack pending writes on reconnect Apr 24, 2024
@alvarowolfx alvarowolfx added kokoro:force-run Add this label to force Kokoro to re-run the tests. owlbot:run Add this label to trigger the Owlbot post processor. labels Apr 25, 2024
@gcf-owl-bot gcf-owl-bot Bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 25, 2024
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Apr 25, 2024
Comment thread src/managedwriter/stream_connection.ts
Comment thread src/managedwriter/stream_connection.ts Outdated
Comment thread src/managedwriter/stream_connection.ts Outdated
Comment thread src/managedwriter/writer.ts Outdated
@alvarowolfx alvarowolfx added the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 30, 2024
@gcf-owl-bot gcf-owl-bot Bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 30, 2024
@alvarowolfx alvarowolfx requested a review from feywind April 30, 2024 15:02
@alvarowolfx alvarowolfx added the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 30, 2024
@gcf-owl-bot gcf-owl-bot Bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 30, 2024
@alvarowolfx alvarowolfx added the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 30, 2024
@gcf-owl-bot gcf-owl-bot Bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 30, 2024
Copy link
Copy Markdown

@feywind feywind left a comment

Choose a reason for hiding this comment

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

Nothing super important, I think...

Comment thread src/managedwriter/stream_connection.ts Outdated
this.trace('data arrived', response);
const pw = this.getNextPendingWrite();
if (!pw) {
this.trace('data arrived', response, this._pendingWrites.length);
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This might be a place that could benefit from the logger I'm working on elsewhere. (Probably said that already, but specifically here...)

Comment thread src/managedwriter/stream_connection.ts
Comment thread src/managedwriter/writer.ts Outdated
Comment thread system-test/managed_writer_client_test.ts Outdated
Comment thread src/managedwriter/stream_connection.ts Outdated
Comment thread src/managedwriter/stream_connection.ts Outdated
Comment thread src/managedwriter/stream_connection.ts Outdated
this._open = false;
this._retrySettings = {
enableWriteRetries: false,
maxRetryAttempts: 4,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why these values? Can they be overridden?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

they can be overwritten via the enableWriteRetries and setMaxRetryAttempts methods. The default values came from the Go ManagedWriter - https://github.com/googleapis/google-cloud-go/blob/5a8c88956ea11eaf3e8aa8cffadfca06bf58c51d/bigquery/storage/managedwriter/retry.go#L31

Comment thread src/managedwriter/stream_connection.ts
@alvarowolfx alvarowolfx requested review from a team and agrawal-siddharth May 2, 2024 13:38
Copy link
Copy Markdown
Contributor Author

@alvarowolfx alvarowolfx left a comment

Choose a reason for hiding this comment

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

answered some question and pushed updates to the PR cc @leahecole @feywind

Comment thread src/managedwriter/stream_connection.ts Outdated
Comment thread src/managedwriter/stream_connection.ts Outdated
Comment thread src/managedwriter/stream_connection.ts
Comment thread src/managedwriter/stream_connection.ts Outdated
this._open = false;
this._retrySettings = {
enableWriteRetries: false,
maxRetryAttempts: 4,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

they can be overwritten via the enableWriteRetries and setMaxRetryAttempts methods. The default values came from the Go ManagedWriter - https://github.com/googleapis/google-cloud-go/blob/5a8c88956ea11eaf3e8aa8cffadfca06bf58c51d/bigquery/storage/managedwriter/retry.go#L31

Comment thread src/managedwriter/stream_connection.ts
Comment thread src/managedwriter/stream_connection.ts Outdated
Comment thread src/managedwriter/stream_connection.ts Outdated
@alvarowolfx alvarowolfx added the owlbot:run Add this label to trigger the Owlbot post processor. label May 2, 2024
@gcf-owl-bot gcf-owl-bot Bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label May 2, 2024
@alvarowolfx alvarowolfx merged commit ce4f88c into googleapis:main May 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: bigquerystorage Issues related to the googleapis/nodejs-bigquery-storage API. size: l Pull request size is large.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants