Set ForwardableOperationMetadata implicitly in coordinators (buildPhaseHandler)

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Fixed
    • Priority: Major - P3
    • 8.2.0-rc0
    • Affects Version/s: 6.0.0, 7.0.0, 8.1.0-rc0, 8.0.0, 8.2.0-rc0
    • Component/s: Catalog, Sharding
    • None
    • Catalog and Routing
    • Fully Compatible
    • CAR Team 2025-04-14
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      ShardingDDLCoordinator follows a pattern for creating an OperationContext that looks like this:

      return ExecutorFuture<void>(**executor).then(
      	_buildPhaseHandler(Phase::kStuff,
      		[this, executor = executor, anchor = shared_from_this()] {
      			const auto opCtxHolder = cc().makeOperationContext();
      			auto* opCtx = opCtxHolder.get();
      			getForwardableOpMetadata().setOn(opCtx);
      			doStuff(opCtx);
      		}
      	)
      );
      

      Aside from being repetitive, this pattern introduces the possibility for oversights such as missing the line that sets ForwardableOpMetadata on the OperationContext.
      This ticket is for eliminating this boilerplate pattern. For example:

      return ExecutorFuture<void>(**executor).then(
      	_buildPhaseHandler(Phase::kStuff,
      		[this, executor = executor, anchor = shared_from_this()](auto* opCtx) {
      			doStuff(opCtx);
      		}
      	)
      );
      

              Assignee:
              Joan Bruguera Micó
              Reporter:
              Robert Sander
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: