You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the client has some kind of network issue connecting to Spanner, it seems to hang indefinitely. Is there a way to specify the timeout? I don't see anything in SpannerOptions.
Can you be more specific about in what situation Spanner hangs indefinitely? (i.e., which api call/calls) If it's for the LRO methods (e.g., create a database), you could specify a timeout when making the call:
We are also working on migrating the spanner library to use gax-java types and there would be timeout/retry settings for all API calls.
Edit: I believe the class Andrea mentioned would be useful when the migration is finished, but they are not used by spanner library for the moment.
@snehashah16
Modified the callable in createSession to throw a retryable exception. Verified that this will indeed cause an infinite retry attempt with exponential sleep.
Is this the intended design? I can imagine for transactions where this might be intentional. Do we want to set a retry limit for createSession()?
@hzyi-google - does the SpannerSettings work in this case (when the client is using the new library) ? Since this is a corner case (of netw issues ), I would be inclined to wait and adopt the new library v/s fixing code that we are in the process of deprecating.
Edit: I feel I need to be more clear about this. The gapic migration work does not touch SpannerSettings and the spanner library will still be using the SpannerOptions to configure a Spanner client after the work is done, meaning that caller still cannot specify a timeout. However SpannerSettings does provide the functionality of configuring retry logics. We will need to migrate SpannerOptions to SpannerSettings to enable this feature.
If this problem occurs consistently on one specific VM or server, then there's a good chance that it is the same problem as in #3889 where an SSLHandshakeException is thrown. The first call to Spanner that needs a session will try to create one. That call would end up in an infinite retry loop in the createSession(...) method.
This code hangs indefinitely before the fix of #3889 when the client computer does not accept the SSL certificate of the server, and throws an SSLHandshakeException after the fix.
Returning to the original question: It is now possible to specify timeout settings for grpc calls for a Spanner service by setting these on one of the StubSettings.Builders exposed by the SpannerOptions.Builder. Setting a specific timeout value for all unary methods for the Spanner interface can be done like this:
@olavloite I experienced the same situation. I tried to delete 1 billion rows with Partitioned DML, but it failed with [deadline exceeded] error. It seemed like timeout problem.
So I tried to specify the timeout with the method you provided.
I got a new error [Error:(44,54) java: type com.google.cloud.spanner.SpannerOptions.Builder does not take parameters]. Why it's not working?
The code is like following
`
final RetrySettings retrySettings =
RetrySettings.newBuilder()
.setInitialRpcTimeout(Duration.ofMinutes(60L))
.setMaxRpcTimeout(Duration.ofMinutes(60L))
.setMaxAttempts(5)
.setTotalTimeout(Duration.ofMinutes(60L))
.build();
SpannerOptions.Builder builder =
SpannerOptions.newBuilder()
.setProjectId("my project");
Hi @FengnaLiu
What version of the client library are you using?
We introduced a specific timeout setting for Partitioned DML a while ago, because it often requires a different timeout than other RPCs. It can be set like this:
I'm not sure why your code example is giving an error. The following example does not return any errors for me (although it's not the way you should set the timeout for Partitioned DML, use the example above):
@olavloite
I really appreciate your reply. The client library should be the latest version.
I also tried SpannerOptions options = SpannerOptions.newBuilder().setPartitionedDmlTimeout(Duration.ofHours(30L)).build();
It gave the same error 「504 Deadline Exceeded」 after about 5 hours. The data I tried to delete is very large about 1 billion rows.
Is it not possible to delete so large number data with PartitionedDML at once?
And the code example you provided is running right and it does seem like not the right way to set timeout for PartitionedDML. Thanks a lot for your useful information.
It gave the same error 「504 Deadline Exceeded」 after about 5 hours.
That is strange. Would you mind opening a new issue in https://github.com/googleapis/java-spanner/issues for this problem? That makes it easier for others to also chime in if they have any ideas, and to track the progress of this specific problem.
That is strange. Would you mind opening a new issue in https://github.com/googleapis/java-spanner/issues for this problem? That makes it easier for others to also chime in if they have any ideas, and to track the progress of this specific problem.
@olavloite I will open a new issue about this problem. Thanks a lot.
Activity
andreamlin commentedon Aug 29, 2018
Hello, SpannerSettings.java has timeout settings, and there is a sample code snippet in the class javadoc as an example.
yihanzhen commentedon Aug 29, 2018
Hi @meltsufin ,
Can you be more specific about in what situation Spanner hangs indefinitely? (i.e., which api call/calls) If it's for the LRO methods (e.g., create a database), you could specify a timeout when making the call:
We are also working on migrating the spanner library to use gax-java types and there would be timeout/retry settings for all API calls.
Edit: I believe the class Andrea mentioned would be useful when the migration is finished, but they are not used by spanner library for the moment.
meltsufin commentedon Aug 29, 2018
I think the issue is happening on creation of the session. What is the current timeout? Whatever it is, currently there is no way to change it, right?
snehashah16 commentedon Aug 31, 2018
@nithinsujir - could u please help here.
For our createSession(db) call, it does a retry using:
static T runWithRetries(Callable callable) { .. } code
Could u please verify behavior (infinite retry attempts w/ exponential sleep ?) when it is a retry-able SpannerException ?
nithinsujir commentedon Aug 31, 2018
Will take a look.
nithinsujir commentedon Sep 5, 2018
@snehashah16
Modified the callable in createSession to throw a retryable exception. Verified that this will indeed cause an infinite retry attempt with exponential sleep.
Is this the intended design? I can imagine for transactions where this might be intentional. Do we want to set a retry limit for createSession()?
snehashah16 commentedon Sep 12, 2018
@hzyi-google - does the SpannerSettings work in this case (when the client is using the new library) ? Since this is a corner case (of netw issues ), I would be inclined to wait and adopt the new library v/s fixing code that we are in the process of deprecating.
yihanzhen commentedon Sep 13, 2018
@snehashah16
Yes SpannerSettings should work.Edit: I feel I need to be more clear about this. The gapic migration work does not touch
SpannerSettingsand the spanner library will still be using theSpannerOptionsto configure a Spanner client after the work is done, meaning that caller still cannot specify a timeout. HoweverSpannerSettingsdoes provide the functionality of configuring retry logics. We will need to migrateSpannerOptionstoSpannerSettingsto enable this feature.11 remaining items
olavloite commentedon Mar 15, 2019
If this problem occurs consistently on one specific VM or server, then there's a good chance that it is the same problem as in #3889 where an SSLHandshakeException is thrown. The first call to Spanner that needs a session will try to create one. That call would end up in an infinite retry loop in the createSession(...) method.
This code hangs indefinitely before the fix of #3889 when the client computer does not accept the SSL certificate of the server, and throws an SSLHandshakeException after the fix.
I'll also look into whether it is possible to add a timeout setting for the clients that are using
SpannerOptions.googleapis#3616 use retry settings when executing runWithRetries(Call…
olavloite commentedon Jun 6, 2019
Returning to the original question: It is now possible to specify timeout settings for grpc calls for a
Spannerservice by setting these on one of theStubSettings.Builders exposed by theSpannerOptions.Builder. Setting a specific timeout value for all unary methods for the Spanner interface can be done like this:FengnaLiu commentedon May 5, 2020
@olavloite I experienced the same situation. I tried to delete 1 billion rows with Partitioned DML, but it failed with [deadline exceeded] error. It seemed like timeout problem.
So I tried to specify the timeout with the method you provided.
I got a new error [Error:(44,54) java: type com.google.cloud.spanner.SpannerOptions.Builder does not take parameters]. Why it's not working?
The code is like following
`
final RetrySettings retrySettings =
RetrySettings.newBuilder()
.setInitialRpcTimeout(Duration.ofMinutes(60L))
.setMaxRpcTimeout(Duration.ofMinutes(60L))
.setMaxAttempts(5)
.setTotalTimeout(Duration.ofMinutes(60L))
.build();
SpannerOptions.Builder builder =
SpannerOptions.newBuilder()
.setProjectId("my project");
`
olavloite commentedon May 6, 2020
Hi @FengnaLiu
What version of the client library are you using?
We introduced a specific timeout setting for Partitioned DML a while ago, because it often requires a different timeout than other RPCs. It can be set like this:
I'm not sure why your code example is giving an error. The following example does not return any errors for me (although it's not the way you should set the timeout for Partitioned DML, use the example above):
FengnaLiu commentedon May 7, 2020
@olavloite
I really appreciate your reply. The client library should be the latest version.
I also tried
SpannerOptions options = SpannerOptions.newBuilder().setPartitionedDmlTimeout(Duration.ofHours(30L)).build();It gave the same error 「504 Deadline Exceeded」 after about 5 hours. The data I tried to delete is very large about 1 billion rows.
Is it not possible to delete so large number data with PartitionedDML at once?
And the code example you provided is running right and it does seem like not the right way to set timeout for PartitionedDML. Thanks a lot for your useful information.
olavloite commentedon May 7, 2020
@FengnaLiu
That is strange. Would you mind opening a new issue in https://github.com/googleapis/java-spanner/issues for this problem? That makes it easier for others to also chime in if they have any ideas, and to track the progress of this specific problem.
FengnaLiu commentedon May 7, 2020
@olavloite I will open a new issue about this problem. Thanks a lot.
chore(deps): update dependency com.google.cloud:google-cloud-bigquery…
deps: update google http client dependencies to v1.46.1 (#3616)
chore(main): release 2.53.0 (#3594)
deps: update dependency com.google.cloud:sdk-platform-java-config to …