@@ -3253,27 +3253,23 @@ TEST(ConnectionImplTest, CommitSuccessExcludeFromChangeStreamsExplicitTxn) {
32533253 .WillOnce (Return (MakeCommitResponse (
32543254 spanner::MakeTimestamp (std::chrono::system_clock::from_time_t (123 ))
32553255 .value ())));
3256- EXPECT_CALL (*mock,
3257- AsyncDeleteSession (_, _, _, HasSessionName (" test-session-name" )))
3258- .WillOnce (Return (make_ready_future (Status{})));
32593256
3257+ // Transaction is created before the usual Connection and Client creation.
3258+ // This is the crux of reproducing this issue.
3259+ auto txn = spanner::Transaction (spanner::Transaction::ReadWriteOptions{});
3260+
3261+ // Connection and OptionsSpan creation mimics what occurs prior to calling
3262+ // ConnectionImpl::Commit in Client::Commit(Transaction, Mutations, Options).
32603263 auto conn = MakeConnectionImpl (db, mock);
32613264 internal::OptionsSpan span (
32623265 MakeLimitedTimeOptions ()
32633266 .set <spanner::ExcludeTransactionFromChangeStreamsOption>(true ));
3264-
3265- // Introduce additional scope here to ensure that when txn is destroyed
3266- // the session_pool contained by the Connection is still present, such that,
3267- // the session associated with the transaction can be returned to the pool.
3268- {
3269- auto txn = spanner::Transaction (spanner::Transaction::ReadWriteOptions{});
3270- auto commit = conn->Commit ({txn, {}});
3271- EXPECT_THAT (
3272- commit,
3273- IsOkAndHolds (Field (
3274- &spanner::CommitResult::commit_timestamp,
3275- Eq (spanner::MakeTimestamp (absl::FromUnixSeconds (123 )).value ()))));
3276- }
3267+ auto commit = conn->Commit ({txn, {}});
3268+ EXPECT_THAT (
3269+ commit,
3270+ IsOkAndHolds (Field (
3271+ &spanner::CommitResult::commit_timestamp,
3272+ Eq (spanner::MakeTimestamp (absl::FromUnixSeconds (123 )).value ()))));
32773273}
32783274
32793275TEST (ConnectionImplTest, CommitSuccessWithMaxCommitDelay) {
0 commit comments