[SERVER-47830] Consolidate validation flags for update/upsert stage Created: 29/Apr/20  Updated: 29/Oct/23  Resolved: 25/May/20

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

Type: Task Priority: Major - P3
Reporter: Tommaso Tocci Assignee: Pierlauro Sciarelli
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Gantt Dependency
has to be done after SERVER-47748 The update stage will not treat as "s... Closed
Backwards Compatibility: Fully Compatible
Sprint: Sharding 2020-05-18, Sharding 2020-06-01
Participants:

 Description   

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?


 Comments   
Comment by Githook User [ 25/May/20 ]

Author:

{'name': 'Pierlauro Sciarelli', 'email': 'pierlauro.sciarelli@mongodb.com', 'username': 'pierlauro'}

Message: SERVER-47830 Consolidate validation flags for update/upsert stage
Branch: master
https://github.com/mongodb/mongo/commit/5d1e30e739653f52e25e0a139867def12ccfe9cb

Generated at Thu Feb 08 05:15:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.