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

Change comparison order so all Dates sort before all Timestamps

    • Minor Change
    • ALL
    • Hide
      var t = db.server3304;
      
      // this will cause an assertion in the mongod process
      t.drop();
      t.save({a: new Date(0)});
      t.find({a: new Timestamp()});
      
      Show
      var t = db.server3304; // this will cause an assertion in the mongod process t.drop(); t.save({a: new Date(0)}); t.find({a: new Timestamp()});

      Queries (including range queries) on one type will no longer match values of the other type. Previously the comparison depended on which type was on the left hand side, which is incompatible with a total ordering.

      Original title: mongod assertion when attempt is made to compare a Date to a Timestamp

      The assertion will happen when the collection contains a Date and the query filter is using a Timestamp, but not the other way around.

      Here's the assertion and stack trace from a mongod running version 2.4.7.

      Fri Nov  1 09:54:12.974 [conn2] Assertion: 13111:wrong type for field (a) 17 != 9
      0x10044c66b 0x10042601e 0x1004260dd 0x100401380 0x10005ce97 0x1002227ec 0x100218a03 0x1002191da 0x1002236c2 0x1002238e0 0x10019b3f0 0x100239e0f 0x10014d796 0x100147ae5 0x100148a0c 0x1001492dc 0x10024093e 0x10024113f 0x1001ee28f 0x10000b802 
       0   mongod                              0x000000010044c66b _ZN5mongo15printStackTraceERSo + 43
       1   mongod                              0x000000010042601e _ZN5mongo11msgassertedEiPKc + 174
       2   mongod                              0x00000001004260dd _ZN5mongo11msgassertedEiRKSs + 29
       3   mongod                              0x0000000100401380 _ZNK5mongo11BSONElement3chkEi + 800
       4   mongod                              0x000000010005ce97 _ZN5mongo20compareElementValuesERKNS_11BSONElementES2_ + 679
       5   mongod                              0x00000001002227ec _ZNK5mongo7Matcher11valuesMatchERKNS_11BSONElementES3_iRKNS_14ElementMatcherE + 100
       6   mongod                              0x0000000100218a03 _ZNK5mongo7Matcher13matchesDottedEPKcRKNS_11BSONElementERKNS_7BSONObjEiRKNS_14ElementMatcherEbPNS_12MatchDetailsE + 3459
       7   mongod                              0x00000001002191da _ZNK5mongo7Matcher7matchesERKNS_7BSONObjEPNS_12MatchDetailsE + 314
       8   mongod                              0x00000001002236c2 _ZNK5mongo19CoveredIndexMatcher7matchesERKNS_7BSONObjERKNS_7DiskLocEPNS_12MatchDetailsEb + 450
       9   mongod                              0x00000001002238e0 _ZNK5mongo19CoveredIndexMatcher14matchesCurrentEPNS_6CursorEPNS_12MatchDetailsE + 212
       10  mongod                              0x000000010019b3f0 _ZN5mongo6Cursor14currentMatchesEPNS_12MatchDetailsE + 56
       11  mongod                              0x0000000100239e0f _ZN5mongo8runCountEPKcRKNS_7BSONObjERSsRi + 1455
       12  mongod                              0x000000010014d796 _ZN5mongo8CmdCount3runERKSsRNS_7BSONObjEiRSsRNS_14BSONObjBuilderEb + 268
       13  mongod                              0x0000000100147ae5 _ZN5mongo12_execCommandEPNS_7CommandERKSsRNS_7BSONObjEiRSsRNS_14BSONObjBuilderEb + 37
       14  mongod                              0x0000000100148a0c _ZN5mongo7Command11execCommandEPS0_RNS_6ClientEiPKcRNS_7BSONObjERNS_14BSONObjBuilderEb + 2516
       15  mongod                              0x00000001001492dc _ZN5mongo12_runCommandsEPKcRNS_7BSONObjERNS_11_BufBuilderINS_16TrivialAllocatorEEERNS_14BSONObjBuilderEbi + 1036
       16  mongod                              0x000000010024093e _ZN5mongo11runCommandsEPKcRNS_7BSONObjERNS_5CurOpERNS_11_BufBuilderINS_16TrivialAllocatorEEERNS_14BSONObjBuilderEbi + 46
       17  mongod                              0x000000010024113f _ZN5mongo8runQueryERNS_7MessageERNS_12QueryMessageERNS_5CurOpES1_ + 1551
       18  mongod                              0x00000001001ee28f _ZN5mongo16assembleResponseERNS_7MessageERNS_10DbResponseERKNS_11HostAndPortE + 1519
       19  mongod                              0x000000010000b802 _ZN5mongo16MyMessageHandler7processERNS_7MessageEPNS_21AbstractMessagingPortEPNS_9LastErrorE + 198
      Fri Nov  1 09:54:12.991 [conn2] Count with ns: test.server3304 and query: { a: Timestamp 0|0 } failed with exception: 13111 wrong type for field (a) 17 != 9 code: 13111
      

        1. server3304.js
          0.4 kB
          Benety Goh

            Assignee:
            mathias@mongodb.com Mathias Stearn
            Reporter:
            aaron Aaron Staple
            Votes:
            0 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated:
              Resolved: