Title: Spanner: TransactionRunner.run() sometimes doesn't retry on ABORTED · Issue #4939 · googleapis/google-cloud-java · GitHub
Open Graph Title: Spanner: TransactionRunner.run() sometimes doesn't retry on ABORTED · Issue #4939 · googleapis/google-cloud-java
X Title: Spanner: TransactionRunner.run() sometimes doesn't retry on ABORTED · Issue #4939 · googleapis/google-cloud-java
Description: Hello, we've noticed that sometimes running executeUpdate throws an AbortedException (directly from inside executeUpdate). This happens, for example, when running queries like DELETE FROM Table WHERE true. When this happens inside Transa...
Open Graph Description: Hello, we've noticed that sometimes running executeUpdate throws an AbortedException (directly from inside executeUpdate). This happens, for example, when running queries like DELETE FROM Table WHE...
X Description: Hello, we've noticed that sometimes running executeUpdate throws an AbortedException (directly from inside executeUpdate). This happens, for example, when running queries like DELETE FROM Table...
Opengraph URL: https://github.com/googleapis/google-cloud-java/issues/4939
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Spanner: TransactionRunner.run() sometimes doesn't retry on ABORTED","articleBody":"Hello, we've noticed that sometimes running executeUpdate throws an AbortedException (directly from inside executeUpdate). This happens, for example, when running queries like `DELETE FROM Table WHERE true`. When this happens inside TransactionRunner.run(), the transaction is not automatically retried, but the AbortedException is immediately rethrown to the caller. Note that the AbortedException appears to be thrown from `executeUpdate`, not transaction.commit().\r\n\r\nThe message in the exception says something like:\r\n\r\n```\r\ncom.google.cloud.spanner.AbortedException: ABORTED: com.google.api.gax.rpc.AbortedException: io.grpc.StatusRuntimeException: ABORTED: Transaction aborted. Database schema probably changed during transaction, retry may succeed.\r\n```\r\n\r\nWe've found that if we wrap this in a retry loop, it does in fact succeed as suggested. We're wondering whether this is a case that should be handled by TransactionRunner's retry logic, or whether there's something we should be doing differently in our code. Thanks!\r\n\r\n#### Environment details\r\n\r\n2. OS type and version: OSX High Sierra.\r\n3. Java version: 1.8.0\r\n4. google-cloud-java version(s): google-cloud-spanner v0.70.0\r\n\r\n#### Code example\r\n\r\n```java\r\n// we are primarily seeing this while using RemoteSpannerHelper\r\nfinal RemoteSpannerHelper remoteSpannerHelper = RemoteSpannerHelper.create();\r\nfinal Database db = remoteSpannerHelper.createTestDatabase(DDL);\r\nfinal DatabaseClient dbClient = remoteSpannerHelper.getDatabaseClient(db);\r\n\r\nwhile (true) {\r\n dbClient.readWriteTransaction().run(tx -\u003e {\r\n // this sometimes throws AbortedException\r\n tx.executeUpdate(Statement.of(\"DELETE FROM Table WHERE true\"));\r\n });\r\n}\r\n```\r\n\r\n#### Stack trace\r\n```\r\ncom.google.cloud.spanner.AbortedException: ABORTED: com.google.api.gax.rpc.AbortedException: io.grpc.StatusRuntimeException: ABORTED: Transaction aborted. Database schema probably changed during transaction, retry may succeed.\r\nretry_delay {\r\n nanos: 10997310\r\n}\r\n\r\n\tat com.google.cloud.spanner.SpannerExceptionFactory.newSpannerExceptionPreformatted(SpannerExceptionFactory.java:117)\r\n\tat com.google.cloud.spanner.SpannerExceptionFactory.newSpannerException(SpannerExceptionFactory.java:43)\r\n\tat com.google.cloud.spanner.SpannerExceptionFactory.newSpannerException(SpannerExceptionFactory.java:80)\r\n\tat com.google.cloud.spanner.spi.v1.GapicSpannerRpc.get(GapicSpannerRpc.java:526)\r\n\tat com.google.cloud.spanner.spi.v1.GapicSpannerRpc.executeQuery(GapicSpannerRpc.java:456)\r\n\tat com.google.cloud.spanner.SpannerImpl$TransactionContextImpl$2.call(SpannerImpl.java:1643)\r\n\tat com.google.cloud.spanner.SpannerImpl$TransactionContextImpl$2.call(SpannerImpl.java:1640)\r\n\tat com.google.cloud.spanner.SpannerImpl.runWithRetries(SpannerImpl.java:246)\r\n\tat com.google.cloud.spanner.SpannerImpl$TransactionContextImpl.executeUpdate(SpannerImpl.java:1639)\r\n\t(one line from our closure, that calls executeUpdate)\r\n\tat com.google.cloud.spanner.SpannerImpl$TransactionRunnerImpl.runInternal(SpannerImpl.java:1312)\r\n\tat com.google.cloud.spanner.SpannerImpl$TransactionRunnerImpl.run(SpannerImpl.java:1280)\r\n\tat com.google.cloud.spanner.SessionPool$PooledSession$1.run(SessionPool.java:410)\r\n```","author":{"url":"https://github.com/fyhuang-rideos","@type":"Person","name":"fyhuang-rideos"},"datePublished":"2019-04-11T18:53:53.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/4939/google-cloud-java/issues/4939"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:d20eee57-222b-fad4-1b3d-75424b16fb19 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BC5A:B2172:198D716:24AFE3B:6A4CDA8F |
| html-safe-nonce | ddff083277fa4078aea16cc69616efc869521cb4645d8e00c43a044b01f81b51 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQzVBOkIyMTcyOjE5OEQ3MTY6MjRBRkUzQjo2QTRDREE4RiIsInZpc2l0b3JfaWQiOiI4NDYwOTI3OTE1MjQzOTIwMDE1IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6d423b88645d49356cc83b1bdb7bc3a8e21188e80f5565e0c00dd0081c2baf1e |
| hovercard-subject-tag | issue:432190606 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/googleapis/google-cloud-java/4939/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d9293f6543df1819ce87943b4cb764067924afc0aa775c9a747a7c652a0d7ad5/googleapis/google-cloud-java/issues/4939 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d9293f6543df1819ce87943b4cb764067924afc0aa775c9a747a7c652a0d7ad5/googleapis/google-cloud-java/issues/4939 |
| og:image:alt | Hello, we've noticed that sometimes running executeUpdate throws an AbortedException (directly from inside executeUpdate). This happens, for example, when running queries like DELETE FROM Table WHE... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | fyhuang-rideos |
| hostname | github.com |
| expected-hostname | github.com |
| None | 299b43bca6e02ad35197ffeba30d2466846d5fb02ab96fbced5b5e6cec589fb8 |
| turbo-cache-control | no-preview |
| go-import | github.com/googleapis/google-cloud-java git https://github.com/googleapis/google-cloud-java.git |
| octolytics-dimension-user_id | 16785467 |
| octolytics-dimension-user_login | googleapis |
| octolytics-dimension-repository_id | 26181278 |
| octolytics-dimension-repository_nwo | googleapis/google-cloud-java |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 26181278 |
| octolytics-dimension-repository_network_root_nwo | googleapis/google-cloud-java |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3eeb74f55ccd8a31bdaec6839577c592bbf7844c |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width