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

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

Merged
merged 26 commits into from
May 3, 2024

Conversation

alvarowolfx
Copy link
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 as a code owner 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
@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
src/managedwriter/stream_connection.ts Outdated Show resolved Hide resolved
src/managedwriter/stream_connection.ts Outdated Show resolved Hide resolved
system-test/managed_writer_client_test.ts Outdated Show resolved Hide resolved
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);

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.

src/managedwriter/stream_connection.ts Outdated Show resolved Hide resolved
src/managedwriter/stream_connection.ts Outdated Show resolved Hide resolved
src/managedwriter/stream_connection.ts Outdated Show resolved Hide resolved
src/managedwriter/stream_connection.ts Outdated Show resolved Hide resolved
@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
this.trace('data arrived', response);
const pw = this.getNextPendingWrite();
if (!pw) {
this.trace('data arrived', response, this._pendingWrites.length);

Choose a reason for hiding this comment

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

This is probably too much logging, it will log one line per request. If it is debug logging then it is fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

those trace calls are only on DEBUG mode.

Choose a reason for hiding this comment

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

Is there a LOG mode? I think those reconnect errors need to be in LOG mode. Even for debug mode, per request logging might be too much, but I am less concerned.

Copy link

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

gonna be the first user of that new logger @feywind 🚀

const pw = this.getNextPendingWrite();
if (!pw) {
this.trace('data arrived', response, this._pendingWrites.length);
if (!this.hasPendingWrites()) {
this.trace('data arrived with no pending write available', response);

Choose a reason for hiding this comment

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

Same here.

src/managedwriter/stream_connection.ts Outdated Show resolved Hide resolved
src/managedwriter/writer.ts Outdated Show resolved Hide resolved
@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
@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

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

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

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

src/managedwriter/stream_connection.ts Show resolved Hide resolved
src/managedwriter/writer.ts Outdated Show resolved Hide resolved
system-test/managed_writer_client_test.ts Outdated Show resolved Hide resolved
src/managedwriter/stream_connection.ts Outdated Show resolved Hide resolved
src/managedwriter/stream_connection.ts Outdated Show resolved Hide resolved
src/managedwriter/stream_connection.ts Outdated Show resolved Hide resolved
@@ -69,6 +74,10 @@ export class WriterClient {
connectionList: [],
};
this._open = false;
this._retrySettings = {
enableWriteRetries: false,
maxRetryAttempts: 4,
Copy link
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
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

src/managedwriter/stream_connection.ts Show resolved Hide resolved
@alvarowolfx alvarowolfx requested a review from a team as a code owner May 2, 2024 13:38
Copy link
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

src/managedwriter/stream_connection.ts Outdated Show resolved Hide resolved
src/managedwriter/stream_connection.ts Outdated Show resolved Hide resolved
src/managedwriter/stream_connection.ts Show resolved Hide resolved
src/managedwriter/stream_connection.ts Outdated Show resolved Hide resolved
@@ -69,6 +74,10 @@ export class WriterClient {
connectionList: [],
};
this._open = false;
this._retrySettings = {
enableWriteRetries: false,
maxRetryAttempts: 4,
Copy link
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

src/managedwriter/stream_connection.ts Show resolved Hide resolved
src/managedwriter/stream_connection.ts Outdated Show resolved Hide resolved
src/managedwriter/stream_connection.ts Outdated Show resolved Hide resolved
@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
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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