Skip to content

Conversation

@eramongodb
Copy link
Contributor

Resolves CXX-3237 and CXX-3238 for the v1::transaction component.

Unlike recently-reviewed PRs, the v_noabi::options::transaction class does not contain T const& getters, thus it can be fully reimplemented in terms of v1::transaction. However, unlike previously-reviewed PRs for classes which were reimplemented in terms of v1, this is the first class which may throw an "invalid object" exception for the assign-or-destroy-only state. In order to preserve v_noabi API backward compatibility while respecting the v1 API's own assign-or-destroy-only invariants, the check_moved_from() helper implements the null check by reusing the (unchecked) raw pointer returned by the v1 as_mongoc() internal helper function. This pattern will also used by upcoming components/PRs for other classes which may throw an "invalid object" exception for backward compatibility (that is, classes which have a potentially-throwing _get_impl() helper).

@eramongodb eramongodb requested a review from kevinAlbs December 5, 2025 21:33
@eramongodb eramongodb self-assigned this Dec 5, 2025
@eramongodb eramongodb requested a review from a team as a code owner December 5, 2025 21:33
Copy link
Collaborator

@kevinAlbs kevinAlbs left a comment

Choose a reason for hiding this comment

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

LGTM with minor comments and a possible rename of v1::transaction to v1::transaction_options.

transaction target;

auto const source_secs = secs{123};
auto const target_secs = secs{123};
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use different value to ensure target is overwritten:

Suggested change
auto const target_secs = secs{123};
auto const target_secs = secs{456};

Copy link
Collaborator

Choose a reason for hiding this comment

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

It did not occur to me in #1491, but I vote for renaming transaction to transaction_options.

I think v1::transaction may give the impression it is responsible for performing a transaction. And transaction_options better matches the name in the specification: TransactionOptions.

MONGOCXX_ABI_EXPORT_CDECL() transaction();

///
/// Set the "maxCommitTimeMS" field.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
/// Set the "maxCommitTimeMS" field. 0 is equivalent to "unset".

Suggest noting 0 is a special case, since this is not mentioned in the specification.

@eramongodb eramongodb merged commit 060fa29 into mongodb:master Dec 8, 2025
11 of 12 checks passed
@eramongodb eramongodb deleted the cxx-abi-v1-transaction branch December 8, 2025 18:59
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.

2 participants