There's a unique index on the 'startDate' column, however, nothing enforces the uniqueness. It appears that an expectation that new Date() will always produce unique result. In our case, this is certainly not the case.
Our logs are filling up with about 15 million entries which look like this:
{ [MongoError: insertDocument :: caused by :: 11000 E11000 duplicate key error index: foo-production.nodes.$startDate_1 dup key: { : new Date(1438769951417) }]
(This is across several clusters in several databases, so the indexes and dates involved vary some).
I think there may be an infinite loop bug here:
https://github.com/mattpker/node-is-master/blob/master/is-master.js#L97
There is an attempt to detect the duplicate case and try a new startDate, but it appears to me that the lines below should change the startDate and updatedDate on this.worker, not this.
It appears to be this bug is causing an infinite loop in our system, since the function recurses and tries the same wrong value over and over, logging each time....
I'm looking at a patch in our fork right now.