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: add support for tagging to Connection API #623

Merged
merged 7 commits into from Jul 5, 2021

Conversation

olavloite
Copy link
Collaborator

@olavloite olavloite commented Nov 13, 2020

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.

@olavloite olavloite added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Nov 13, 2020
@olavloite olavloite requested review from a team as code owners November 13, 2020 17:20
@google-cla google-cla bot added the cla: yes This human has signed the Contributor License Agreement. label Nov 13, 2020
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/java-spanner API. label Nov 13, 2020
@olavloite olavloite changed the title Connection api tagging feat: add support for tagging to Connection API Nov 13, 2020
Copy link

@yoshi-code-bot yoshi-code-bot left a comment

Choose a reason for hiding this comment

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

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)
Copy link
Contributor

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?

Copy link
Collaborator Author

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) {
Copy link
Contributor

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.

Copy link
Collaborator Author

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

Copy link
Collaborator Author

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;

@olavloite olavloite removed the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Apr 13, 2021
@codecov
Copy link

codecov bot commented Apr 13, 2021

Codecov Report

Merging #623 (0868a05) into master (004c5d7) will increase coverage by 0.17%.
The diff coverage is 86.90%.

❗ Current head 0868a05 differs from pull request most recent head df0b11d. Consider uploading reports for the commit df0b11d to get more accurate results
Impacted file tree graph

@@             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     
Impacted Files Coverage Δ
...a/com/google/cloud/spanner/SessionPoolOptions.java 69.53% <ø> (-0.79%) ⬇️
.../java/com/google/cloud/spanner/SpannerOptions.java 89.50% <ø> (-0.04%) ⬇️
...a/com/google/cloud/spanner/TransactionManager.java 100.00% <ø> (ø)
...spanner/admin/database/v1/DatabaseAdminClient.java 87.96% <ø> (+4.74%) ⬆️
...anner/admin/database/v1/DatabaseAdminSettings.java 15.94% <ø> (ø)
...nner/admin/database/v1/stub/DatabaseAdminStub.java 3.70% <ø> (ø)
...in/database/v1/stub/DatabaseAdminStubSettings.java 93.45% <ø> (-0.10%) ⬇️
...base/v1/stub/GrpcDatabaseAdminCallableFactory.java 50.00% <ø> (ø)
.../admin/database/v1/stub/GrpcDatabaseAdminStub.java 97.60% <ø> (+0.29%) ⬆️
...spanner/admin/instance/v1/InstanceAdminClient.java 82.99% <ø> (+3.85%) ⬆️
... and 122 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f257671...df0b11d. Read the comment docs.

@googleapis googleapis deleted a comment from generated-files-bot bot Apr 13, 2021
@googleapis googleapis deleted a comment from generated-files-bot bot Apr 13, 2021
@olavloite
Copy link
Collaborator Author

@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 Connection interface. Do we need a version bump for this?

@thiagotnunes thiagotnunes added the do not merge Indicates a pull request not ready for merge, due to either quality or timing. label Apr 14, 2021
@olavloite olavloite added automerge Merge the pull request once unit tests and other checks pass. and removed do not merge Indicates a pull request not ready for merge, due to either quality or timing. labels Jul 5, 2021
@olavloite olavloite merged commit 5722372 into master Jul 5, 2021
@olavloite olavloite deleted the connection-api-tagging branch July 5, 2021 08:45
@gcf-merge-on-green gcf-merge-on-green bot removed the automerge Merge the pull request once unit tests and other checks pass. label Jul 5, 2021
ansh0l pushed a commit to ansh0l/java-spanner that referenced this pull request Nov 10, 2022
This is an auto-generated regeneration of the .pb.go files by
cloud.google.com/go/internal/gapicgen. Once this PR is submitted, genbot will
update the corresponding PR to depend on the newer version of go-genproto, and
assign reviewers. Whilst this or any regen PR is open in go-genproto, genbot
will not create any more regeneration PRs. If all regen PRs are closed,
gapicgen will create a new set of regeneration PRs once per night.

If you have been assigned to review this PR, please:

- Ensure that CI is passing. If it's failing, it requires your manual attention.
- Approve and submit this PR if you believe it's ready to ship. That will prompt
genbot to assign reviewers to the google-cloud-go PR.

Corresponding google-cloud-go PR: googleapis/google-cloud-go#4311

Changes:

chore: Update networksecurity v1beta1 BUILD.bazel for python
  PiperOrigin-RevId: 381257429
  Source-Link: googleapis/googleapis@f5b06c2

chore: regenerate API index

  Source-Link: googleapis/googleapis@8cd4d12

feat(servicedirectory): Update Service Directory v1beta1 protos to include VPC Network field, and create/modify timestamp fields.
  PiperOrigin-RevId: 381234166
  Source-Link: googleapis/googleapis@d69baf2

fix(servicecontrol): add dependency log_severity.proto
  Committer: @summerji
  PiperOrigin-RevId: 381179420
  Source-Link: googleapis/googleapis@8b976f7

feat(spanner): add JSON type
  PiperOrigin-RevId: 381156241
  Source-Link: googleapis/googleapis@fb5c4fb

chore: regenerate API index

  Source-Link: googleapis/googleapis@c4d3151

feat: filestore public protos
  Committer: @vchudnov-g
  PiperOrigin-RevId: 381148500
  Source-Link: googleapis/googleapis@4c8d14a

feat(asset): add new searchable fields (memberTypes, roles, project, folders and organization), new request fields (assetTypes and orderBy) and new response fields (assetType, folders and organization) in SearchAllIamPolicies
  PiperOrigin-RevId: 381145907
  Source-Link: googleapis/googleapis@5d301f9

chore: regenerate API index

  Source-Link: googleapis/googleapis@aeb62a6

feat: dataflow public protos
  Committer: @alexander-fenster
  PiperOrigin-RevId: 380930750
  Source-Link: googleapis/googleapis@3dc9b8e

chore: regenerate API index

  Source-Link: googleapis/googleapis@02f6236

feat: networksecurity public protos
  Committer: @alexander-fenster
  PiperOrigin-RevId: 380923948
  Source-Link: googleapis/googleapis@370df45

chore: release gapic-generator-java v1.0.15
  Committer: @miraleung
  PiperOrigin-RevId: 380916790
  Source-Link: googleapis/googleapis@7c7d22f

chore: remove legacy, unused YAML from gapic directory
  PiperOrigin-RevId: 380835888
  Source-Link: googleapis/googleapis@dba65e3

chore(resourcesettings): update resourcesettings build rules
  Committer: @neenushaji
  PiperOrigin-RevId: 380831596
  Source-Link: googleapis/googleapis@2c1d1b2

build(clouddms): fix package name hint
  PiperOrigin-RevId: 380817131
  Source-Link: googleapis/googleapis@284d1dd

feat(documentai): update ReviewDocumentRequest to allow set priority and enable validation.
  PiperOrigin-RevId: 380732771
  Source-Link: googleapis/googleapis@87fc4d4

feat!(dialogflow/cx): mark agent.default_language_code as required feat: add return_partial response to Fulfillment docs: add notes to train agent before sending queries
  PiperOrigin-RevId: 380726996
  Source-Link: googleapis/googleapis@a5cec0a

chore: Update source_v1 BUILD.bazel for python
  PiperOrigin-RevId: 380710437
  Source-Link: googleapis/googleapis@0e48ca4

chore: regenerate API index

  Source-Link: googleapis/googleapis@89b01d8

feat(pubsublite): Add SeekSubscription and Operations to API
  PiperOrigin-RevId: 380660182
  Source-Link: googleapis/googleapis@b601f02

chore(gkeconnect/gateway): fix multi-version package names in grpc_service_config for gkeconnect
  Committer: @miraleung
  PiperOrigin-RevId: 380655273
  Source-Link: googleapis/googleapis@9250dff

chore: remove all monolith Bazel deps chore: release gapic-generator-csharp v1.3.7 chore: release gapic-generator-go 0.20.5 chore: release gapic-generator-java 1.0.14 chore: release gapic-generator-php 1.0.1 chore: release gapic-generator-python 0.50.0 chore: update gapic-generator-ruby to the latest commit chore: release gapic-generator-typescript 1.5.0
  Committer: @miraleung
  PiperOrigin-RevId: 380641501
  Source-Link: googleapis/googleapis@076f7e9

docs(dialogflow): added notes to train agent prior to sending queries fix: added resource reference to agent_version
  PiperOrigin-RevId: 380595849
  Source-Link: googleapis/googleapis@5fe3c63

docs(dialogflow/cx): added notes to train agent before sending queries
  PiperOrigin-RevId: 380267079
  Source-Link: googleapis/googleapis@01bad53

chore(gkeconnect/gateway): Update gkeconnect/gateway v1beta1 BUILD.bazel for python
  PiperOrigin-RevId: 380077711
  Source-Link: googleapis/googleapis@9d8dbc0

chore: regenerate API index

  Source-Link: googleapis/googleapis@052eb55

chore(resourcemanager): remove protoc-gen-docs_plugin from WORKSPACE
  PiperOrigin-RevId: 380020641
  Source-Link: googleapis/googleapis@cb44b17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/java-spanner API. cla: yes This human has signed the Contributor License Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants