diff --git a/mongo/session.go b/mongo/session.go index 22aa026c9e..8f1e029b95 100644 --- a/mongo/session.go +++ b/mongo/session.go @@ -233,7 +233,7 @@ func (s *sessionImpl) WithTransaction(ctx context.Context, fn func(ctx SessionCo CommitLoop: for { - err = s.CommitTransaction(ctx) + err = s.CommitTransaction(newBackgroundContext(ctx)) // End when error is nil, as transaction has been committed. if err == nil { return res, nil