Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-36349

Handle the ShardingOperationFailedStatus in the OperationShardingState destructor when the OperationContext is not created in a ServiceEntryPoint



    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 4.0.0, 4.1.1
    • Fix Version/s: 4.0.5, 4.1.6
    • Component/s: Sharding
    • Labels:
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
    • Backport Requested:
    • Sprint:
      Sharding 2018-11-05, Sharding 2018-11-19, Sharding 2018-12-03, Sharding 2018-12-17
    • Linked BF Score:


      Whenever an OperationContext is created, an OperationShardingState is created as a decoration on the OperationContext. When it's created through the regular process of a ServiceEntryPoint, a ScopedOperationCompletionShardingAction is created that will go out of scope at the end of ServiceEntryPoint::execCommandDatabase(). When an OperationContext is created outside of the regular process of a ServiceEntryPoint, a ScopedOperationCompletionShardingAction is not created.

      If an exception occurs during a WriteOp that matches StaleConfigInfo or CannotImplicitlyCreateCollectionInfo, the OperationShardingState will set a failed status in an error Status member variable. This Status is expected to be handled and reset by the destructor of ScopedOperationCompletionShardingActions. That is currently the only place where the Status could be reset.

      When the OperationShardingState is destructed, an invariant exists that asserts that the error Status member variable in OperationShardingState has been reset.

      In the case that an OperationContext is created outside of the ServiceEntryPoint codepath, a ScopedOperationCompletionShardingActions object will never exist to reset the error Status member variable. Upon destruction of the OperationContext, the destructor for the OperationShardingState will be called as well. If there was ever a StaleConfig or CannotImplicitlyCreateCollection status/exception, in a WriteOp, during the lifetime of the OperationContext, the destructor will trip the invariant.

      We should either relax the invariant, or think of other appropriate places to reset the OperationShardingState error Status member variable.




            • Votes:
              0 Vote for this issue
              7 Start watching this issue


              • Created: