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

Fix corner case where an update mod is applied twice

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.2.1, 2.3.0
    • Component/s: Write Ops
    • Labels:
      None
    • Operating System:
      ALL

      Description

      The bug can be triggered by adding this test to dbtests/updatetests.cpp

      Uncomment DEBUGUPDATE in db/ops/update_internal.cpp and check that the second mod is being applied twice

             class TwoNestedPulls {
              public:
                  void run() {
                      BSONObj obj = fromjson( "{ a:{ b:[ 1, 2 ], c:[ 1, 2 ]} }" );
                      BSONObj mod = fromjson( "{ $pull:{ 'a.b':2, 'a.c':2 }}" );
                      ModSet modSet( mod );
                      auto_ptr<ModSetState> modSetState = modSet.prepare(obj );
                      ASSERT_FALSE( modSetState->canApplyInPlace() );
                      modSetState->createNewFromMods();
                      // This is incorrectly logged as { $set:{ 'a.b':[ 1 ]}, $unset:{ 'a.c':1 } }.
                      ASSERT_EQUALS( fromjson( "{ $set:{ 'a.b':[ 1 ] }, $set:{ 'a.c':[ 1 ] } }" ), modSetState->getOpLogRewrite() );
                  }
              };

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              eliot Eliot Horowitz (Inactive)
              Reporter:
              alerner Alberto Lerner
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: