Skip to content
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

TransactionRunner can get stuck if the first statement is a query and ResultSet#next() is never called #641

Closed
olavloite opened this issue Nov 17, 2020 · 0 comments · Fixed by #643
Assignees
Labels
api: spanner priority: p1 type: bug

Comments

@olavloite
Copy link
Contributor

@olavloite olavloite commented Nov 17, 2020

The following transaction will wait indefinitely because the first query of the transaction will never actually be executed. All subsequent statements will however wait for a transaction id to be returned by this query.

DatabaseClient client =
        spanner.getDatabaseClient(DatabaseId.of("p", "i", "d"));
client.readWriteTransaction().run(new TransactionCallable<Void>() {
      @Override
      public Void run(TransactionContext transaction) throws Exception {
        transaction.executeQuery("SELECT 1");
        // Any RPC on the transaction after this will hang, including the Commit call that will
        // be executed when this method returns. So this transaction will never finish.
        return null;
      }
});
@olavloite olavloite added type: bug priority: p1 labels Nov 17, 2020
@olavloite olavloite self-assigned this Nov 17, 2020
@product-auto-label product-auto-label bot added the api: spanner label Nov 17, 2020
olavloite added a commit that referenced this issue Nov 17, 2020
If the first statement of a read/write transaction was a query or a read operation,
and the application would not call ResultSet#next() on the return result, the transaction
would hang indefinetely as the query would be marked as the one that should initiate the
transaction (inline the BeginTransaction option). The query would however never be
executed, as the actual query execution is deferred until the first call to ResultSet#next().

Fixes #641
thiagotnunes pushed a commit that referenced this issue Nov 18, 2020
…643)

If the first statement of a read/write transaction was a query or a read operation,
and the application would not call ResultSet#next() on the return result, the transaction
would hang indefinetely as the query would be marked as the one that should initiate the
transaction (inline the BeginTransaction option). The query would however never be
executed, as the actual query execution is deferred until the first call to ResultSet#next().

Fixes #641
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner priority: p1 type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant