Skip to content

GODRIVER-3698 Support command logging for transactions#2288

Merged
prestonvasquez merged 7 commits intomongodb:release/2.4from
prestonvasquez:bug/godriver3698-txn-cmds-not-logging
Jan 23, 2026
Merged

GODRIVER-3698 Support command logging for transactions#2288
prestonvasquez merged 7 commits intomongodb:release/2.4from
prestonvasquez:bug/godriver3698-txn-cmds-not-logging

Conversation

@prestonvasquez
Copy link
Member

GODRIVER-3698

Summary

Add pipelines to support command logging for abortTransaction and commitTransaction.

Background & Motivation

Only handshake and heartbeat commands are excluded from logging. Transaction commands are not excluded.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR implements command logging support for MongoDB transaction operations (abortTransaction and commitTransaction), addressing the requirement that only handshake and heartbeat commands should be excluded from logging.

Changes:

  • Added logger field and Logger() setter method to CommitTransaction and AbortTransaction operation structs
  • Updated session methods to pass the client's logger to transaction operations
  • Updated specifications submodule reference

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
x/mongo/driver/operation/commit_transaction.go Added logger field and Logger() method to enable command logging for commit operations
x/mongo/driver/operation/abort_transaction.go Added logger field and Logger() method to enable command logging for abort operations
mongo/session.go Updated AbortTransaction and CommitTransaction to pass client logger to operations
testdata/specifications Updated submodule reference to newer specifications version

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +206 to +208
if ct == nil {
ct = new(CommitTransaction)
}
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

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

The nil check pattern is incorrect for a method receiver. If ct is nil when Logger() is called, this will panic before reaching the nil check. This pattern should be removed since calling a method on a nil receiver will panic regardless of this check.

Copilot uses AI. Check for mistakes.
Comment on lines +217 to +219
if at == nil {
at = new(AbortTransaction)
}
Copy link

Copilot AI Jan 14, 2026

Choose a reason for hiding this comment

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

The nil check pattern is incorrect for a method receiver. If at is nil when Logger() is called, this will panic before reaching the nil check. This pattern should be removed since calling a method on a nil receiver will panic regardless of this check.

Copilot uses AI. Check for mistakes.
@prestonvasquez
Copy link
Member Author

@qingyang-hu Note that the specification updates intentionally point at a forked commit to test: prestonvasquez/specifications@e3259f0

Context: mongodb/specifications#1881

@mongodb-drivers-pr-bot
Copy link
Contributor

mongodb-drivers-pr-bot bot commented Jan 14, 2026

🧪 Performance Results

Commit SHA: 9ca15a4

There were no significant changes to the performance to report for version 697259a064b388000722f6d8.

For a comprehensive view of all microbenchmark results for this PR's commit, please check out the Evergreen perf task for this patch.

@mongodb-drivers-pr-bot
Copy link
Contributor

API Change Report

./v2/x/mongo/driver/operation

compatible changes

(*AbortTransaction).Logger: added
(*CommitTransaction).Logger: added

qingyang-hu
qingyang-hu previously approved these changes Jan 15, 2026
@prestonvasquez prestonvasquez changed the title Support command logging for transactions GODRIVER-3698 Support command logging for transactions Jan 15, 2026
@prestonvasquez prestonvasquez force-pushed the bug/godriver3698-txn-cmds-not-logging branch from 031f942 to 8809a27 Compare January 15, 2026 17:10
@prestonvasquez prestonvasquez changed the base branch from master to release/2.4 January 15, 2026 17:12
qingyang-hu
qingyang-hu previously approved these changes Jan 16, 2026
@prestonvasquez prestonvasquez added the review-priority-normal Medium Priority PR for Review: within 1 business day label Jan 22, 2026
@prestonvasquez prestonvasquez merged commit fd84052 into mongodb:release/2.4 Jan 23, 2026
33 of 35 checks passed
@prestonvasquez prestonvasquez deleted the bug/godriver3698-txn-cmds-not-logging branch January 23, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug review-priority-normal Medium Priority PR for Review: within 1 business day

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants