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

Fix corner case where an update mod is applied twice

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.2.1, 2.3.0
    • Affects Version/s: None
    • Component/s: Write Ops
    • None
    • ALL

      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() );
                  }
              };
      

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

              Created:
              Updated:
              Resolved: