-
Notifications
You must be signed in to change notification settings - Fork 45
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
generateorders: "order.models.MultipleObjectsReturned: get() returned more than one Order -- it returned 2!" #828
Comments
I'm able to reproduce it with manually running
|
Going further back in time, sometimes one day will get generated and then the crash will happen:
|
I've traced the code; what's happening is that in
like the exception says, that get() is choking on multiple results where it's only expecting one. I found a client ("xxxx") that triggers this and poked around the database. I found, for example:
There's quite a few of these duplicate orders:
Here they all our (censored for privacy):
|
I've spot checked a few, and most cases contain a cancellation ( We never want to have more than one order per client per day, that would break our business logic, so I think adding a UNIQUE constraint is the proper first step, and then we have to work backwards from that to every create on this table, turning them all into upserts that flips existing order into Also |
@kousu Great analysis! Could you provide a patch to fix this? |
Before hacking away at this issue, I'd love to check in with you Nick about that. Whenever you're in the office |
To be clear, this causes |
@kousu @JeanFrancoisFournier any information in this issue? It's not clear to me what should be the solution. |
@erozqba this got down-prioritized on our end because the daily workflow involves regenerated all the orders for the day, fresh, so we never run into an order made by The immediate solution here would be, I think, adding some other try-except clauses in judicious places. I haven't sat down to do this but I would like to, unless someone beats me to it. I kind of doubt that will happen because reproducing this is tricky without access to our production database; it's really not clear to me what the root cause here is; some combination of cancelling some portion of repeated orders and then regenerating them, maybe? Without working that out the best I can think to do is to try to patch this in production, which I'm not suuuuper keen on, and then extract the patch and push it up here. |
EDIT: sometimes it returns 3 as well. It could be any number. 1 is the most likely, 2 is the next most likely.
On our production server, at on Fri, Mar 2, 2018 at 9:00 PM, running the cronjob
gave
and the next night, Sat, Mar 3, 2018 at 9:00 PM
We only just thought to make the cronjobs log what they're doing to email, so I don't know how long this has been going on.
The output was back to normal tonight (Sun, Mar 4, 2018 at 9:00 PM):
The text was updated successfully, but these errors were encountered: