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

Consolidate validation flags for update/upsert stage

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.7.0
    • Affects Version/s: None
    • Component/s: Aggregation Framework
    • Labels:
      None
    • Fully Compatible
    • Sharding 2020-05-18, Sharding 2020-06-01

      Rationale:
      At the moment there are several flags used both in the update/upsert stage code that are used to decide which checks and validation needs to be performed around the document being updated.

      This ticket has the goal of consolidating these flags and documenting them.

      These flags at the end will be a combination of the following:

      • isFromOplogReplication: means that this runs on secondaries, so absolutely no
        validation/shard version check must be done; also no oplog entries will be
        generated so no need to include the shard key in the oplog.
      • !writesAreReplicated means that this may or may not run on primary, but the
        caller is managing its own replication; none of the collections could possibly
        be sharded that use this (or it would be a bug); I imagine that the content of
        the document technically still can be validated if we wanted to add schemas for
        internal collections, but currently we don't do that, so again we don't have to
        validate for storage
      • isFromMigrate means that this document came from migration, so it should be
        accepted unconditionally as well

      Requested changes:

      • isUserInitiatedWrite (to be committed yet) flags needs to be promoted from function level flags to class level, and it will take the place of _enforceOkForStorage.
      • _shouldCheckForShardKeyUpdate needs to be constructed on top of isUserInitiatedWrite.
      • isInternalRequest flag on the upsert stage can be removed and we can use the class level flag _isUserInitiatedWrite instead.
      • _assertDocumentToBeInsertedIsValid function on the upsert stage can use directly _isUserInitiatedWrite  and doesn't need to accept any flags.

      To be investigated:

      • Do we really need to take into account if the request is versioned for _shouldCheckForShardKeyUpdate flag? can't we just use _isUserInitiatedWrite instead?

            Assignee:
            pierlauro.sciarelli@mongodb.com Pierlauro Sciarelli
            Reporter:
            tommaso.tocci@mongodb.com Tommaso Tocci
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: