Skip to content

GODRIVER-3889 Move commitTransaction and abortTransaction to the mongo package.#2473

Open
matthewdale wants to merge 3 commits into
mongodb:masterfrom
matthewdale:godriver3889-move-transaction-ops
Open

GODRIVER-3889 Move commitTransaction and abortTransaction to the mongo package.#2473
matthewdale wants to merge 3 commits into
mongodb:masterfrom
matthewdale:godriver3889-move-transaction-ops

Conversation

@matthewdale

@matthewdale matthewdale commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

GODRIVER-3889

Summary

Move the commitTransaction and abortTransaction operation logic from the x/mongo/driver/operations package to the mongo package, removing the unnecessary chainable setters. Don't export the moved types.

Background & Motivation

Part of a larger effort to reduce unnecessary code by removing the x/mongo/driver/operations package.

@mongodb-drivers-pr-bot

mongodb-drivers-pr-bot Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

🧪 Performance Results

Commit SHA: 5d392f2

The following benchmark tests for version 6a56c1d4b5dbe1000779be8f had statistically significant changes (i.e., |z-score| > 1.96):

Benchmark Measurement % Change Patch Value Stable Region H-Score Z-Score
BenchmarkMultiFindMany ops_per_second_med 1.8567 3717472.1190 Avg: 3649708.2244
Med: 3642999.3364
Stdev: 18906.6614
0.8768 3.5841

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
Copy Markdown
Contributor

API Change Report

./v2/x/mongo/driver/operation

incompatible changes

AbortTransaction: removed
CommitTransaction: removed
NewAbortTransaction: removed
NewCommitTransaction: removed

@matthewdale matthewdale added review-priority-low Low Priority PR for Review: within 3 business days ignore-for-release labels Jul 9, 2026
@matthewdale matthewdale marked this pull request as ready for review July 9, 2026 22:40
@matthewdale matthewdale requested a review from a team as a code owner July 9, 2026 22:40

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 relocates the commitTransaction and abortTransaction operation implementations from x/mongo/driver/operation into the mongo package as unexported helpers, aligning with the ongoing effort to shrink/remove the x/mongo/driver/operation(s) surface area.

Changes:

  • Removed CommitTransaction and AbortTransaction operation types (and their chainable setters) from x/mongo/driver/operation.
  • Added unexported commitTransactionOp / abortTransactionOp implementations in the mongo package.
  • Updated mongo.Session.CommitTransaction and mongo.Session.AbortTransaction to use the new mongo-package ops directly.

Reviewed changes

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

Show a summary per file
File Description
x/mongo/driver/operation/commit_transaction.go Removed CommitTransaction operation implementation from the x operation package.
x/mongo/driver/operation/abort_transaction.go Removed AbortTransaction operation implementation from the x operation package.
mongo/session.go Switched session commit/abort paths to use unexported mongo-package ops instead of x/mongo/driver/operation.
mongo/op_commit_transaction.go Added unexported commitTransactionOp implementation used by Session.CommitTransaction.
mongo/op_abort_transaction.go Added unexported abortTransactionOp implementation used by Session.AbortTransaction.

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

Comment thread mongo/op_commit_transaction.go
Comment thread mongo/op_commit_transaction.go
Comment thread mongo/op_abort_transaction.go
Comment thread mongo/op_abort_transaction.go
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@matthewdale matthewdale requested review from linborland and removed request for prestonvasquez July 14, 2026 17:11
linborland
linborland previously approved these changes Jul 14, 2026
Comment thread mongo/op_abort_transaction.go Outdated
Comment thread mongo/op_commit_transaction.go Outdated
Co-authored-by: Lin Borland <lin.borland@mongodb.com>
}

// Execute runs this operation and returns an error if the operation did not execute successfully.
func (ct *commitTransactionOp) Execute(ctx context.Context) error {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

[nit] We should unexport method names. Additionally, is this more naturally a function? What are your thoughts?

func executeCommitTxn(ctx context.Context, ct commitTransactionOp) { }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ignore-for-release review-priority-low Low Priority PR for Review: within 3 business days

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants