Skip to content

src/transction:fix Snapshot.createReadStream on error this.begin() invocation when no transactionID is detected and it was not aborted #2170

@odeke-em

Description

@odeke-em

As a consequence of this problem, in my observability changes I have to invoke await this.begin() so as to ensure proper span production but @surbhigarg raised a point in a code review with

Can we hold on this change of making 'error' event async. I know this would mean that our few spans wont work correctly.
I am working on another PR to see if this check can be removed #2168

Adding async here will cause other issues like in below when runTransactionAsync method tries to insert an invalid error, normally this error event is invoked first and then catch block. But if you add async here, this would make catch block invoked first as error event is called asynchronously which will cause other issues.

try {
    await database.runTransactionAsync(async transaction => {
      await transaction.run(
        "INSERT INTO Singers (SingerId, FirstName) VALUES (310, 'abc')"
      );
      await transaction.commit();
    });
    await database.runTransactionAsync(async transaction => {
      await transaction.run(
        "INSERT INTO Singers (SingerId, FirstName) VALUES (310, 'abc')"
      );
      await transaction.commit();
    });
  } catch (err) {
    console.error('ERROR:', err);
    // throw err;
  } finally {
    database.close();
  }

Remove this change and add a bug where we mention what scenarios are not working and I will take it up separately.

Originally posted by @surbhigarg92 in #2158 (comment)

Metadata

Metadata

Assignees

Labels

api: spannerIssues related to the googleapis/nodejs-spanner API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions