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

Filtering on dates outside of the 32 bit epoch range returns wrong results

    • Query Optimization
    • Fully Compatible
    • ALL
    • v6.3, v6.0, v5.0
    • Hide

      db.createCollection(timeColl, {timeseries: {timeField: time}});
       
      // Note that all dates are within the epoch, i.e. between the years 1970 and 2038
      const dates = [

      {[timeFieldName]: new Date("1971-01-01")}

      ,

      {[timeFieldName]: new Date("1975-01-01")}

      ,

      {[timeFieldName]: new Date("1980-01-01")}

      ,

      {[timeFieldName]: new Date("1995-01-01")}

      ,

      {[timeFieldName]: new Date("2030-01-01")}

      ];
      db.timeColl.insert(dates);
       
      // 1920 falls outside the epoch, triggering the failure.
      db.timeColl.find({time: {$gt:newDate("1920-01-01"), $lt:newDate("1980-01-01")}};
       
      /* Should result in 
      [

      {time: new Date("1965-01-01")}

      ,

      {time: new Date("1975-01-01")}

      ,
      ]);
      but does not
      */

      Show
      db.createCollection(timeColl, {timeseries: {timeField: time}});   // Note that all dates are within the epoch, i.e. between the years 1970 and 2038 const dates = [ {[timeFieldName]: new Date("1971-01-01")} , {[timeFieldName]: new Date("1975-01-01")} , {[timeFieldName]: new Date("1980-01-01")} , {[timeFieldName]: new Date("1995-01-01")} , {[timeFieldName]: new Date("2030-01-01")} ]; db.timeColl.insert(dates);   // 1920 falls outside the epoch, triggering the failure. db.timeColl.find({time: {$gt:newDate("1920-01-01"), $lt:newDate("1980-01-01")}};   /* Should result in  [ {time: new Date("1965-01-01")} , {time: new Date("1975-01-01")} , ]); but does not */
    • QO 2023-02-06, QO 2023-02-20, QO 2023-03-06
    • 166

      Literals outside the 32 bit epoch are currently compared to _id, which has already been trimmed to 32 bits,  so we cannot accurately match against them. This obvious fix is to determine whether the compared dates can be outside the epoch range and not relying on _id in that case.

            Assignee:
            david.percy@mongodb.com David Percy
            Reporter:
            joel.redman@mongodb.com Joel Redman (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            14 Start watching this issue

              Created:
              Updated:
              Resolved: