-
Notifications
You must be signed in to change notification settings - Fork 443
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
[spanner] : STATUS_UNAVAILABLE isn't retried in some cases in Result->rows() #5880
Comments
@oprudkyi thanks for reporting this issue. There are reasons due to which all UNAVAILABLE errors are not recommended for retry such as non-idempotent calls. Can you help me understand if this is a rarely occurring issue, can a retry on user code be helpful? |
Meanwhile, I am trying to understand what should be the behavior when there's no resume token. |
as for me it looks like idempotent - it calls SELECT via https://cloud.google.com/spanner/docs/reference/rpc/google.spanner.v1#google.spanner.v1.Spanner.ExecuteSql
return original call ? i.e.
|
@oprudkyi I couldn't get the reason(s) why a resume token isn't there for certain rare cases like you pointed. |
@vishwarajanand it's not rare, we are getting 50+ errors daily on prod.
|
just for info, the next ugly workaround helped. The first retry passes without error
where parent::select is from https://github.com/colopl/laravel-spanner/blob/fbd7a2cab4b0b5e4d11857d356b4518177aed4e3/src/Connection.php#L258
@taka-oyama but I am still unsure if this this workaround needed in laravel-spanner |
I just checked the logs for our service and saw similar errors at the rate of 1~2 an hour.
Can we do something like Within transaction -> Retry the whole transaction through below. google-cloud-php/Spanner/src/Database.php Line 845 in 104537e
Outside the transaction -> Retry individual queries through below. google-cloud-php/Spanner/src/Result.php Line 175 in 104537e
|
Nodejs version seems to have fixed this back in 2020. Dotnet has fixed a similar issue. |
Hi @taka-oyama
For us there weren't any exceptions inside explicit transactions. |
Looking at node, dotnet, and java, @olavloite seems to know a lot about how it works and has made PRs for many similar issues. @olavloite, would it be possible to get some insight on how this is suppose to be handled? |
(Caution, not a PHP expert here, so I might be reading something wrong in this code)
From what I can see the only thing that needs to be modified here is this line: google-cloud-php/Spanner/src/Result.php Line 180 in fda8c6c
It is safe to retry the initial call as long as the method has not returned any rows to the caller. |
Wow! Thank you so much for the quick response! 👏🥹 |
@vishwarajanand |
I raised a fix to retry when no results have yielded, with or without the resume token. |
Thank you! |
Environment details
Steps to reproduce
it happens very rarely , once per day or week, on relatively loaded clusters and with simple random queries and I can't reproduce it
according to https://cloud.google.com/spanner/docs/error-codes the call should be retried
but according to source
google-cloud-php/Spanner/src/Result.php
Line 231 in fda8c6c
i.e. it retried only when there is set $resumeToken , but it never set for queries with small results
sample code I used
The text was updated successfully, but these errors were encountered: