Skip to content

fix: set timeouts for BatchGetDocuments/RunQuery#799

Merged
schmidt-sebastian merged 4 commits intomainfrom
mrschmidt/timeout
Oct 27, 2021
Merged

fix: set timeouts for BatchGetDocuments/RunQuery#799
schmidt-sebastian merged 4 commits intomainfrom
mrschmidt/timeout

Conversation

@schmidt-sebastian
Copy link
Copy Markdown
Contributor

We currently only apply the retry settings to Unary methods, which means that the user cannot specify a custom timeout for BatchGetDocuments and RunQuery requests.

@schmidt-sebastian schmidt-sebastian requested a review from a team as a code owner October 26, 2021 19:57
@product-auto-label product-auto-label bot added the api: firestore Issues related to the googleapis/java-firestore API. label Oct 26, 2021
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 26, 2021
@schmidt-sebastian schmidt-sebastian added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 26, 2021
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 26, 2021
FirestoreOptions.newBuilder()
.setRetrySettings(
RetrySettings.newBuilder()
.setMaxRpcTimeout(Duration.ofMillis(1))
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.

might be nice to add some asserts to the retry settings once built in a unit test?

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.

Unfortunately, the code in the stub handler is not exercised by unit tests.

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.

right, can we add one? Something along the lines of:

 FirestoreOptions firestoreOptions =
                FirestoreOptions.newBuilder()
                        .setRetrySettings(
                                RetrySettings.newBuilder()
                                        .setMaxRpcTimeout(Duration.ofMillis(1))
                                        .setTotalTimeout(Duration.ofMillis(1))
                                        .setInitialRpcTimeout(Duration.ofMillis(1))
                                        .build())
                        .build();

Duration maxRpcTimeout = firestoreOptions.getRetrySettings().getMaxRpcTimeout();
Truth.assertThat(maxRpcTimeout).isEqualTo(Duration.ofMillis(1));

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.

and could add additional cases for the unary timeouts that were already getting set.

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.

IMHO, this would not catch the issue here. The issue is that the retry settings do not get applied correctly to the underlying RCPs, not that the settings itself are off. The code snippet you provided is just auto-generated code (unless I misunderstood the intent)

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.

Got it - I thought FirestoreOptions was handwritten. SGTM

@schmidt-sebastian schmidt-sebastian merged commit 6cd2a45 into main Oct 27, 2021
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/timeout branch October 27, 2021 18:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: firestore Issues related to the googleapis/java-firestore API. cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants