Skip to content

Conversation

@scotthart
Copy link
Member

@scotthart scotthart commented Aug 14, 2025

This change is Reviewable


// Transaction is created before the usual Connection and Client creation.
// This is the crux of reproducing this issue.
auto txn = spanner::Transaction(spanner::Transaction::ReadWriteOptions{});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want the ExcludeTransactionFromChangeStreamsOption to have an effect, you have to instantiate it before you create the transaction.

That is, in general you need to build the OptionsSpan before you call into the library.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. However the current API doesn't enforce that. If the user creates a Transaction first, then creates the Connection and Client, they may not get the behavior they expect and there is no diagnostic indicating such.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These operations can come in any order you like, modulo their data dependencies (and the test expectations that would have to be tweaked here due to the lifetime differences).

The issue is not the relative ordering of the Transaction and Connection/Client, but rather the ordering of the Transaction and the OptionsSpan. As mentioned above, "If you want the ExcludeTransactionFromChangeStreamsOption to have an effect, you have to instantiate it before you create the transaction." Write before read.

There is no way to enforce/diagnose that because the Option setting is, after all, optional.

Copy link
Member Author

@scotthart scotthart left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @devbww)


// Transaction is created before the usual Connection and Client creation.
// This is the crux of reproducing this issue.
auto txn = spanner::Transaction(spanner::Transaction::ReadWriteOptions{});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. However the current API doesn't enforce that. If the user creates a Transaction first, then creates the Connection and Client, they may not get the behavior they expect and there is no diagnostic indicating such.

Copy link
Contributor

@devbww devbww left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 1 unresolved discussion (waiting on @scotthart)


// Transaction is created before the usual Connection and Client creation.
// This is the crux of reproducing this issue.
auto txn = spanner::Transaction(spanner::Transaction::ReadWriteOptions{});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These operations can come in any order you like, modulo their data dependencies (and the test expectations that would have to be tweaked here due to the lifetime differences).

The issue is not the relative ordering of the Transaction and Connection/Client, but rather the ordering of the Transaction and the OptionsSpan. As mentioned above, "If you want the ExcludeTransactionFromChangeStreamsOption to have an effect, you have to instantiate it before you create the transaction." Write before read.

There is no way to enforce/diagnose that because the Option setting is, after all, optional.

@scotthart scotthart closed this Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the Spanner API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants