Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
markstos opened this issue Aug 5, 2015 · 2 comments
Closed

Comments

@markstos
Copy link
Contributor

markstos commented Aug 5, 2015

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.

@mattpker
Copy link
Owner

mattpker commented Aug 5, 2015

Thanks, yeah it looks like you are correct, I referenced the wrong this so the startDate was not updating on the new insert attempt after a fail. I will get this fixed soon unless you already have a pull request in the works.

mattpker added a commit that referenced this issue Aug 5, 2015
@mattpker
Copy link
Owner

mattpker commented Aug 5, 2015

Should be fixed, I verified that it works properly by forcing the date to a specific date when I was testing. Let me know if you have any other issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants