Skip to content

RUBY-3824 Restore conditional skip logic in transactions spec runner#3033

Merged
comandeo-mongo merged 2 commits intomongodb:masterfrom
comandeo-mongo:RUBY-3824-fix-transactions-runner-skip
Apr 29, 2026
Merged

RUBY-3824 Restore conditional skip logic in transactions spec runner#3033
comandeo-mongo merged 2 commits intomongodb:masterfrom
comandeo-mongo:RUBY-3824-fix-transactions-runner-skip

Conversation

@comandeo-mongo
Copy link
Copy Markdown
Contributor

@comandeo-mongo comandeo-mongo commented Apr 28, 2026

A rubocop autocorrect in commit
8db64312b
("Enable rubocop on all files, with exceptions" — #3005) flattened
the original if test.skip_reason and unless req.satisfied? guards
in spec/runners/transactions.rb into bare skip calls inside a
single before(:all) block:

before(:all) do
  ...
  skip test.skip_reason            # always skips, even when nil
  skip 'Requirements not satisfied' # always skips
  test.setup_test                   # never reached
end

Effect: every transactions_spec.rb and transactions_api_spec.rb
example reports as PENDING regardless of topology or actual
requirements. The transactions spec test suite has not run locally on
master since that commit (2026-03-27).

The fix restores the conditional checks and passes req through to
the block (it was renamed to _req because it had become unused after
the regression).

Test plan

Against a local 3-node replica set (replicaSet=replset):

  • bundle exec rspec spec/spec_tests/transactions_spec.rb — 1809 examples, 0 failures, 965 pending (sharded-only). Before: all pending.
  • bundle exec rspec spec/spec_tests/transactions_api_spec.rb — 370 examples, 0 failures, 185 pending (sharded-only). Before: all pending.
  • bundle exec rubocop spec/runners/transactions.rb — clean

A rubocop autocorrect in commit 8db6431 flattened the original
guarded skips into bare `skip` calls inside a single before(:all)
block, so every transactions and transactions_api example was
unconditionally pending with "Requirements not satisfied" (or
"No reason given") regardless of topology or other requirements.

Restore the original behavior: skip on `test.skip_reason` only when
one is set, skip on unmet requirements only when `req.satisfied?` is
false. Receive `req` from the block instead of `_req`.
Copilot AI review requested due to automatic review settings April 28, 2026 12:03
@comandeo-mongo comandeo-mongo requested a review from a team as a code owner April 28, 2026 12:03
@comandeo-mongo comandeo-mongo requested a review from jamis April 28, 2026 12:03
Copy link
Copy Markdown
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

Restores correct conditional skipping behavior in the transactions spec runner so that transaction spec tests execute when applicable instead of always being marked pending.

Changes:

  • Reintroduces conditional guard for test.skip_reason before calling skip.
  • Reintroduces conditional guard for spec req satisfaction before skipping due to unmet requirements.
  • Restores use of the req argument yielded by define_spec_tests_with_requirements.

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

@comandeo-mongo comandeo-mongo marked this pull request as draft April 28, 2026 12:41
The transactions runner triggers Session#unpin twice for the same network
error on the bulk_write code path: once from the unpin_maybe handler in
Operation::Executable#do_execute, and again from the unpin_maybe handler
in BulkWrite#execute_operation wrapping the same OpMsg execution. The
second call tried to check the connection back into the pool that had
already received it, raising "Trying to check in a connection which is
not currently checked out by this pool". This regression had been hidden
since the rubocop autocorrect on the runner (commit 8db6431) skipped
all transactions tests; it surfaced as soon as PR 3033 re-enabled them
on sharded clusters.

Guard Session#unpin to return early when there is no pinned state. The
single-document path is unaffected (only one unpin_maybe layer there).
Copy link
Copy Markdown
Contributor

@jamis jamis left a comment

Choose a reason for hiding this comment

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

Great catch! I was afraid something like this might slip through the cracks, after I discovered that the supposedly "safe" Rubocop autocorrect mode (-a) is not actually guaranteed to be safe. Thanks for fixing this. 👍

@comandeo-mongo comandeo-mongo marked this pull request as ready for review April 29, 2026 09:56
@comandeo-mongo comandeo-mongo merged commit 55a7526 into mongodb:master Apr 29, 2026
197 of 198 checks passed
@comandeo-mongo comandeo-mongo deleted the RUBY-3824-fix-transactions-runner-skip branch April 29, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants