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: migrate connection API to use the new auto-generated admin clients. #2879

Closed
wants to merge 24 commits into from

Conversation

arpan14
Copy link
Contributor

@arpan14 arpan14 commented Feb 12, 2024

  • Connection API internally uses the handwritten admin client earlier. Migrating them to new auto-generated admin clients which we would we recommending to customers.
  • Ensuring that all tests pass and we don't see any surprises.

@arpan14 arpan14 requested review from a team as code owners February 12, 2024 09:22
@product-auto-label product-auto-label bot added the size: l Pull request size is large. label Feb 12, 2024
@arpan14 arpan14 marked this pull request as draft February 12, 2024 09:22
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/java-spanner API. label Feb 12, 2024
@arpan14 arpan14 closed this Feb 13, 2024
@arpan14 arpan14 force-pushed the admin-connection-api branch from 2b5f0c0 to 53bcb3e Compare February 13, 2024 14:46
@product-auto-label product-auto-label bot added size: u Pull request is empty. and removed size: l Pull request size is large. labels Feb 13, 2024
@arpan14 arpan14 reopened this Feb 13, 2024
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: u Pull request is empty. labels Feb 13, 2024
@arpan14 arpan14 marked this pull request as ready for review February 14, 2024 18:43
@arpan14 arpan14 requested a review from olavloite February 14, 2024 18:43
@arpan14 arpan14 added the owlbot:run Add this label to trigger the Owlbot post processor. label Feb 15, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Feb 15, 2024
@arpan14 arpan14 added the owlbot:run Add this label to trigger the Owlbot post processor. label Feb 15, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Feb 15, 2024
*
* @return the SQL dialect that is used by the database.
*/
default DatabaseDialect getDatabaseDialect() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we really need this? I think it will be confusing for customers when to use which of these two methods (getDialect() and getDatabaseDialect()). Could we instead instruct users to use Dialect.toProto() instead when they need the proto version?

@@ -273,7 +275,8 @@ static UnitOfWorkType of(TransactionMode transactionMode) {
this.autoPartitionMode = options.isAutoPartitionMode();
this.maxPartitions = options.getMaxPartitions();
this.maxPartitionedParallelism = options.getMaxPartitionedParallelism();
this.ddlClient = createDdlClient();
this.databaseAdminClient = spanner.createDatabaseAdminClient();
Copy link
Collaborator

Choose a reason for hiding this comment

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

This will create a separate admin client for each connection that is created, including underlying gRPC channels. That means that an application that uses a JDBC connection that opens 100 connections, all of a sudden uses 4 channels (for the normal Spanner instance) + 100 (or 400? I don't remember exactly what channel settings we are using for the generated admin clients) channels for the 100 DatabaseAdmin clients.

It also means that creating a new Connection is suddenly a much heavier operation, meaning that applications that do not use connection pooling could potentially experience a performance degradation.

Currently, creating a Connection instance is an non-blocking method, and creating multiple connections to the same database does not incur much cost (it only costs the bit of memory that is required to keep track of the Connection state, but it does not create any additional physical connections to Spanner).

databaseAdminClient.close();
}
} catch (RuntimeException ex) {
throw SpannerExceptionFactory.newSpannerException(ex);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are we sure that we want to propagate this exception? Or should we just ignore it? Are there any potential things that the user might have done wrong that could cause an exception here? If yes, then it is probably best to propagate it. If this is more of a 'better-safe-than-sorry' and/or 'this sometimes randomly causes an exception, no idea why'-kind of situation, then I would suggest that we ignore the exception.

But see also above: I don't think we should create a separate DatabaseAdminClient for each connection that is created.

@olavloite
Copy link
Collaborator

Closing as there has not been any activity in the past several weeks. Please re-open if this is still relevant.

@olavloite olavloite closed this Oct 11, 2024
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. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants