[SERVER-36259] Allow aggregations with $out to be run in a transaction when the "mode" does not perform DDL operations Created: 24/Jul/18  Updated: 06/Dec/22

Status: Backlog
Project: Core Server
Component/s: Aggregation Framework
Affects Version/s: None
Fix Version/s: None

Type: Task Priority: Major - P3
Reporter: Kyle Suarez Assignee: Backlog - Query Optimization
Resolution: Unresolved Votes: 0
Labels: 4.2-agg-txn
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on SERVER-35897 Support dropTarget false in $out Closed
Assigned Teams:
Query Optimization
Participants:

 Description   

With SERVER-35897 complete, we have the ability to perform a $out in a way that performs no catalog changes (i.e. no collection drops or renames). In theory, this should allow us to allow an aggregation $out in a transaction as long as we run in one of those modes.

This ticket will track work to simply remove the prohibition of $out in a transaction as long as the "mode" is compatible. We'll also write tests that exercise this behavior as appropriate.

(Currently, we plan to use the DBDirectClient and the ClusterWriter to perform writes inside of $out. We will have to investigate whether this will work in a transaction. One concern is the risk of a deadlock on checking out the session or stashed transaction resources, especially with the DBDirectClient. We may have to either unstash resources or refactor the code in a way that does not depend on the DBDirectClient.)



 Comments   
Comment by Kyle Suarez [ 23/Aug/18 ]

I'm removing this from the $out project and placing it on the backlog for now. We'll revisit this again in 4.2 at our next planning meeting and consider transaction support for $out together with $lookup.

Comment by Kyle Suarez [ 21/Aug/18 ]

Yep, you're correct. It may "just work" out of the box, though, as there is already existing code in write_ops_exec that will fail writes that attempt to implicitly create a collection:

write_ops_exec.cpp

192
void makeCollection(OperationContext* opCtx, const NamespaceString& ns) {
193
    auto txnParticipant = TransactionParticipant::get(opCtx);
194
    auto inTransaction = txnParticipant && txnParticipant->inMultiDocumentTransaction();
195
    uassert(ErrorCodes::OperationNotSupportedInTransaction,
196
            str::stream() << "Cannot create namespace " << ns.ns()
197
                          << " in multi-document transaction.",
198
            !inTransaction);

Comment by Nicholas Zolnierz [ 21/Aug/18 ]

kyle.suarez Is implicit collection creation considered a DDL operation? If so we may want to disallow it as part of this ticket?

Generated at Thu Feb 08 04:42:33 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.