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

Pre-Epoch dates in v0 indexes cannot be found in 2.0.x-series servers

    • Type: Icon: Bug Bug
    • Resolution: Won't Fix
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.0.4, 2.1.0
    • Component/s: None
    • Labels:
      None
    • ALL

      v0 indexes on 2.0.x and 2.1.x servers cannot find dates before the UNIX epoch:

      > db.serverStatus().version
      1.8.5
      > db.dates.insert({_id: "before", date: new Date(-3600000)})
      > db.dates.insert({_id: "after", date: new Date(3600000)})
      > db.dates.ensureIndex({date: 1})
      > db.dates.find({date: new Date(3600000)})
      { "_id" : "after", "date" : ISODate("1970-01-01T01:00:00Z") }
      > db.dates.find({date: new Date(-3600000)})
      { "_id" : "before", "date" : ISODate("1969-12-31T23:00:00Z") }
      
      // restart in same dbpath with 2.0.4 server here
      
      > db.serverStatus().version
      2.0.4
      > db.dates.find({date: new Date(3600000)})
      { "_id" : "after", "date" : ISODate("1970-01-01T01:00:00Z") }
      > db.dates.find({date: new Date(-3600000)})
      >
      

      Note that after reindexing, the documents can then be found in the (now v1) index:

      > db.dates.reIndex()
      [...]
      > db.dates.find({date: new Date(3600000)})
      { "_id" : "after", "date" : ISODate("1970-01-01T01:00:00Z") }
      > db.dates.find({date: new Date(-3600000)})
      { "_id" : "before", "date" : ISODate("1969-12-31T23:00:00Z") }
      >
      

      Also this is reproduceable when explicitly creating v0 indexes on a 2.x server:

      > db.serverStatus().version
      2.1.0
      > db.dates.drop()
      true
      > db.dates.insert({_id: "before", date: new Date(-3600000)})
      > db.dates.insert({_id: "after", date: new Date(3600000)})
      > db.dates.ensureIndex({date: 1}, {v: 0})
      > db.dates.find({date: new Date(3600000)})
      { "_id" : "after", "date" : ISODate("1970-01-01T01:00:00Z") }
      > db.dates.find({date: new Date(-3600000)})
      > 
      

            Assignee:
            Unassigned Unassigned
            Reporter:
            dcrosta Daniel Crosta
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: