googleapis / java-spanner Public
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: add support for tagging to Connection API #623
Conversation
Some suggestions could not be made:
- google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/Connection.java
- lines 38-38
@@ -959,6 +1034,7 @@ private UnitOfWork createNewUnitOfWork() { | |||
.setReadOnlyStaleness(readOnlyStaleness) | |||
.setStatementTimeout(statementTimeout) | |||
.withStatementExecutor(statementExecutor) | |||
.setTransactionTag(transactionTag) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How will this behave if the user never set a transaction tag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is nullable, so that is not a problem. It is verified by this test case.
} | ||
|
||
@Override | ||
public void setStatementTag(String tag) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of curiosity, could we prevent the calling of this for a COMMIT
? The user should not be able to do a statement tag in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. We can't prevent it before the COMMIT
, but we can throw an exception if COMMIT
is called after a statement tag has been set, and I think that makes sense as we are quite strict in checking the order of other statements (e.g. you are only allowed to get a commit timestamp if you actually committed etc.).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed the implementation to check for this, and to throw an error if the application tries to set a statement tag for a COMMIT
or ROLLBACK
statement. This change also adds a change relating to DML batches: DML batches can only include one statement tag, as the statements are sent as one ExecuteBatchDmlRequest
, which only allows one statement tag. This statement tag must be set before calling START BATCH DML
, e.g.
SET STATEMENT_TAG = 'tag-1';
START BATCH DML;
INSERT INTO Singers (SingerId, Name) VALUES (1, 'Morrison');
INSERT INTO Singers (SingerId, Name) VALUES (2, 'Pieterson');
RUN BATCH;
3ab89ea
to
510fdb3
Compare
Codecov Report
@@ Coverage Diff @@
## master #623 +/- ##
============================================
+ Coverage 85.06% 85.23% +0.17%
- Complexity 2585 2687 +102
============================================
Files 143 155 +12
Lines 14130 14531 +401
Branches 1368 1376 +8
============================================
+ Hits 12019 12386 +367
- Misses 1540 1570 +30
- Partials 571 575 +4
Continue to review full report at Codecov.
|
@thiagotnunes Would you mind taking a final look before I merge? I've rebased on master and realigned with the last choice that were made for tagging in the client library. Also: This is a binary breaking change as it adds methods to the |
🤖 I have created a release \*beep\* \*boop\* --- ## [6.9.0](https://www.github.com/googleapis/java-spanner/compare/v6.8.0...v6.9.0) (2021-07-05) ### Features * add support for tagging to Connection API ([#623](https://www.github.com/googleapis/java-spanner/issues/623)) ([5722372](https://www.github.com/googleapis/java-spanner/commit/5722372b7869828e372dec06e80e5b0e7280af61)) * **spanner:** add leader_options to InstanceConfig and default_leader to Database ([#1271](https://www.github.com/googleapis/java-spanner/issues/1271)) ([f257671](https://www.github.com/googleapis/java-spanner/commit/f25767144344f0df67662f1b3ef662902384599a)) * support setting an async executor provider ([#1263](https://www.github.com/googleapis/java-spanner/issues/1263)) ([369c8a7](https://www.github.com/googleapis/java-spanner/commit/369c8a771ec48fa1476236f800b0e8eb5982a33c)) ### Dependencies * update dependency com.google.cloud:google-cloud-shared-dependencies to v1.4.0 ([#1269](https://www.github.com/googleapis/java-spanner/issues/1269)) ([025e162](https://www.github.com/googleapis/java-spanner/commit/025e162813d6321dabe49e32f00934f9ae334e24)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Adds support for tagging in the Connection API. This is needed to support tagging in the JDBC driver.
This is a binary breaking change, as it adds 4 methods to the
Connection
interface. That interface is marked as@InternalApi
and warns that it may make breaking changes without prior notice.