[SERVER-5601] Pre-Epoch dates in v0 indexes cannot be found in 2.0.x-series servers Created: 13/Apr/12  Updated: 04/Jun/13  Resolved: 04/Jun/13

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 2.0.4, 2.1.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Daniel Crosta Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Operating System: ALL
Participants:

 Description   

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



 Comments   
Comment by Ian Whalen (Inactive) [ 04/Jun/13 ]

this is probably not something we'll be able to do now since it's about v0 indexes - probably too many changes relative to the benefit.

Generated at Thu Feb 08 03:09:22 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.