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

findAndModify with remove=true doesn't retry deleting document on WCE

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: 3.1.2
    • Fix Version/s: 3.1.8
    • Component/s: Querying, Write Ops
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Sprint:
      Quint 9 09/18/15

      Description

      The WorkingSetMember is transitioned into the OWNED_OBJ state prior to the deletion of the document from the collection.

      if (_params.returnDeleted) {
          // Save a copy of the document that is about to get deleted.
          BSONObj deletedDoc = member->obj.value();
          member->obj.setValue(deletedDoc.getOwned());
          member->loc = RecordId();
          member->transitionToOwnedObj();
      }
      

      Consider the following sequence of events:

      1. The user does {findAndModify: 'coll', query: {}, remove: true}}.
      2. The child of the DeleteStage advances and the corresponding WorkingSetMember is in the LOC_AND_OBJ state.
      3. We intend to return the delete document, so the WorkingSetMember is transitioned into the OWNED_OBJ state.
      4. Collection::deleteDocument() is called and throws a WriteConflictException.
      5. The WorkingSetID of the WorkingSetMember is saved in _idRetrying and the DeleteStage returns NEED_YIELD.
      6. DeleteStage::work() is called again and status is set to ADVANCED and the id is set to _idRetrying.
      7. The WorkingSetMember is in the OWNED_OBJ state and therefore returns false when member->hasLoc() is called.
      8. nInvalidateSkips is incremented and the DeleteStage returns NEED_TIME.

      Thus, we won't actually retry deleting the document if a WriteConflictException occurred. Instead, we should transition the WorkingSetMember to the OWNED_OBJ state after the delete occurs.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: