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

fix: executeBatch did not respect statement timeout#871

Merged
olavloite merged 1 commit intomainfrom
timeout-execute-batch
May 14, 2022
Merged

fix: executeBatch did not respect statement timeout#871
olavloite merged 1 commit intomainfrom
timeout-execute-batch

Conversation

@olavloite
Copy link
Copy Markdown
Collaborator

The Statement#executeBatch() method did not respect the statement timeout that had been set on a statement. This meant that a batch like the following would always use the default timeout that is set in the Gapic generated client, and ignore the timeout set in Statement#setTimeout(int):

statement.setQueryTimeout(120);
statement.addBatch("insert into foo (id) values (1)");
statement.executeBatch(); // This ignored the statement timeout

Fixes #870

The Statement#executeBatch() method did not respect the statement
timeout that had been set on a statement. This meant that a batch like
the following would always use the default timeout that is set in the
Gapic generated client, and ignore the timeout set in
Statement#setTimeout(int):

statement.setTimeout(120);
statement.addBatch("insert into foo (id) values (1)");
statement.executeBatch(); // This ignored the statement timeout

Fixes #870
@olavloite olavloite requested review from a team, ansh0l, asthamohta and rajatbhatta May 4, 2022 09:22
@product-auto-label product-auto-label Bot added size: m Pull request size is medium. api: spanner Issues related to the googleapis/java-spanner-jdbc API. labels May 4, 2022
Copy link
Copy Markdown
Contributor

@rajatbhatta rajatbhatta left a comment

Choose a reason for hiding this comment

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

LGTM, just had one query.

Comment thread pom.xml
Comment on lines +224 to +225
<exclude>com.google.cloud.spanner.jdbc.it.**</exclude>
<exclude>com.google.cloud.spanner.jdbc.JdbcStatementTimeoutTest</exclude>
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 did we exclude the tests under it/ and the new test that we added this in PR (JdbcStatementTimeoutTest)?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The integration tests should already have been excluded, but the existing exclude didn't actually work (it references a Category that is not used). The reason that the integration tests weren't executed by the maven-surefire-plugin was because of the default shared configuration that excluded them. So in theory we could remove the exclude here. But as it was already present and intentional, but not working, I decided to fix it so it does work.

The reason that we are excluding the StatementTimeoutTest here is that it is relatively slow. I felt that it was overkill to execute the test every time you execute mvn test, which is already taking quite long for this library, and instead only run it together with the integration tests. So the test is executed by the CI, but not locally unless you explicitly enable it.

Copy link
Copy Markdown
Contributor

@ansh0l ansh0l left a comment

Choose a reason for hiding this comment

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

LGTM

@olavloite olavloite merged commit 3c6eab4 into main May 14, 2022
@olavloite olavloite deleted the timeout-execute-batch branch May 14, 2022 18:46
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

api: spanner Issues related to the googleapis/java-spanner-jdbc API. size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Statement.executeBatch() ignores statement timeout

3 participants