Skip to content
This repository was archived by the owner on Sep 4, 2024. It is now read-only.
This repository was archived by the owner on Sep 4, 2024. It is now read-only.

startDate column has unique index, but uniqueness is not enforced #4

@markstos

Description

@markstos

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions