chore(spanner): introduce commitRpcTimeout to connection properties#13801
chore(spanner): introduce commitRpcTimeout to connection properties#13801sagnghos wants to merge 1 commit into
Conversation
This explicitly sets an operation timeout bound for Spanner transactions so that severe network blockholes do not lead to an infinite connection timeout at the YCSB or application layer when proxy mechanisms (like PGAdapter) are routing via EKS Load Balancers.
There was a problem hiding this comment.
Code Review
This pull request introduces a new commitRpcTimeout configuration option to customize the RPC timeout specifically for commit operations in Spanner. The feedback highlights a few areas for improvement: correcting misplaced Javadoc comments in ConnectionOptions.java, ensuring consistent private final visibility and this reference usage for the new field in SpannerPoolKey, and adding a precondition check in SpannerOptions.Builder to prevent negative timeout values.
| /** The gRPC keepalive time for this connection. */ | ||
| /** The commit RPC timeout for this connection. */ | ||
| public Duration getCommitRpcTimeout() { | ||
| return getInitialConnectionPropertyValue(COMMIT_RPC_TIMEOUT); | ||
| } | ||
|
|
||
| public Duration getGrpcKeepAliveTime() { | ||
| return getInitialConnectionPropertyValue(GRPC_KEEPALIVE_TIME); | ||
| } |
There was a problem hiding this comment.
The Javadoc comment for getGrpcKeepAliveTime() was accidentally moved above getCommitRpcTimeout(), resulting in duplicated Javadoc blocks for getCommitRpcTimeout() and leaving getGrpcKeepAliveTime() without any documentation. Please correct the placement of these Javadoc comments.
| /** The gRPC keepalive time for this connection. */ | |
| /** The commit RPC timeout for this connection. */ | |
| public Duration getCommitRpcTimeout() { | |
| return getInitialConnectionPropertyValue(COMMIT_RPC_TIMEOUT); | |
| } | |
| public Duration getGrpcKeepAliveTime() { | |
| return getInitialConnectionPropertyValue(GRPC_KEEPALIVE_TIME); | |
| } | |
| /** The commit RPC timeout for this connection. */ | |
| public Duration getCommitRpcTimeout() { | |
| return getInitialConnectionPropertyValue(COMMIT_RPC_TIMEOUT); | |
| } | |
| /** The gRPC keepalive time for this connection. */ | |
| public Duration getGrpcKeepAliveTime() { | |
| return getInitialConnectionPropertyValue(GRPC_KEEPALIVE_TIME); | |
| } |
| private final String host; | ||
| private final String projectId; | ||
| private final Duration grpcKeepAliveTime; | ||
| final Duration commitRpcTimeout; |
There was a problem hiding this comment.
The field commitRpcTimeout in SpannerPoolKey is declared with package-private visibility, whereas all other fields in this class are declared as private final. For consistency and proper encapsulation, please make it private final.
| final Duration commitRpcTimeout; | |
| private final Duration commitRpcTimeout; |
| this.universeDomain, | ||
| this.grpcInterceptorProvider, | ||
| this.grpcKeepAliveTime, | ||
| commitRpcTimeout, |
| public Builder setCommitRpcTimeout(Duration commitRpcTimeout) { | ||
| this.commitRpcTimeout = commitRpcTimeout; | ||
| return this; | ||
| } |
There was a problem hiding this comment.
To prevent invalid configurations early, consider adding a check to ensure that commitRpcTimeout is not negative when it is non-null.
public Builder setCommitRpcTimeout(Duration commitRpcTimeout) {
if (commitRpcTimeout != null) {
Preconditions.checkArgument(
!commitRpcTimeout.isNegative(), "commitRpcTimeout cannot be negative");
}
this.commitRpcTimeout = commitRpcTimeout;
return this;
}
This explicitly sets an operation timeout bound for Spanner transactions so that severe network blockholes do not lead to an infinite connection timeout at the YCSB or application layer when proxy mechanisms (like PGAdapter) are routing via EKS Load Balancers.