Repository navigation
fix(datastore): avoid copying auto-generated channelProvider in toBuilder - #15415
jinseopkim0 wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a hasCustomChannelProvider flag in DatastoreOptions to track whether the TransportChannelProvider was explicitly provided or auto-generated. This ensures that auto-generated providers are correctly cleared and rebuilt when configuration settings like host, transport options, universe domain, or OpenTelemetry options change. The review feedback correctly identifies a serialization issue where hasCustomChannelProvider is not marked as transient, which could lead to inconsistent state and stale endpoints after deserialization since channelProvider itself is transient.
|
@gemini-code-assist review |
There was a problem hiding this comment.
Code Review
This pull request introduces a hasCustomChannelProvider flag to DatastoreOptions to track whether a channel provider was explicitly supplied by the caller. This ensures that auto-generated channel providers are correctly cleared and rebuilt when configuration settings like transport options, host, universe domain, or OpenTelemetry options are modified. The review feedback suggests several improvements: adding null checks to prevent a potential NullPointerException when comparing transport options, and checking if the host, universe domain, or OpenTelemetry options have actually changed before clearing the channel provider to avoid unnecessary recreation.
| // Setting a non-null provider marks it as caller-owned so later host/universe changes do not | ||
| // discard it; passing null reverts to auto-generated provider behavior. | ||
| this.hasCustomChannelProvider = channelProvider != null; |
There was a problem hiding this comment.
taking a look at this and I think I'm missing the issue here. Though I think this does bring in some interesting behavior that we should try to standardize via Gax/ Datastore.
Gax endpoint resolution works like this:
- TransportchannelProvider configures an endpoint (use this first if set )
- Client#setEndpoint configures (then use this)
- configure default via UD
I think we already check for transportchannelprovider to be non-null for gRPC only (http doesn't seem to support setting a transportchannelprovider).
IIUC, perhaps we just need to update the logic to capture the custom host to also account for any endpoint set via TransportchannelProvider?
There was a problem hiding this comment.
Thanks for the feedback. When built with a custom host and no explicit channelProvider, DatastoreOptions auto-generates an InstantiatingGrpcChannelProvider with that host baked in. toBuilder() copied it, so later setHost(...) or setUniverseDomain(...) calls were overridden by the stale provider's endpoint (#1 above).
I simplified to only copy caller-supplied customChannelProvider in toBuilder(), removing the flag and setter overrides while preserving TransportChannelProvider precedence.
9fbd11e to
9c8958e
Compare
b/588887355
Track caller-supplied
customChannelProviderseparately inDatastoreOptionssotoBuilder()does not carry over an auto-generated gRPCchannelProviderwhose baked-in endpoint or telemetry configurator may become stale.