[LRUG] Best way to implement an increasing number?
Andrew Stewart
boss at airbladesoftware.com
Fri Apr 19 03:22:44 PDT 2013
On 19 Apr 2013, at 12:16, Oskar Pearson wrote:
> Could you tell us a little bit more about your actual db setup, and when/how this problem occurs? For example, does it happen in your dev environment, or only under high server load? Does it only occur when two users are uploading their spreadsheets at the same time?
I haven't seen this in my dev environment, only in production. Server load is nothing special. Only one user was uploading a spreadsheet when this happened and nobody was looking at the web page of A's Bs.
> You've mentioned uploading files from spreadsheets: are you using a background processing job to handle them? Or are you doing it 'in the frontend' while the http layer waits for the db to return? If you are running a background job, is it through something like a queueing system, or is it through a process fork?
I'm using delayed_job to handle this in the background.
There are two workers although obviously only one should be working the job. Having said that, I have observed one or two other weirdnesses this morning which suggest that jobs are currently being processed twice (maybe related to an incorrect restart after server freeze a few days ago?). If this is the case, and the import job was run twice concurrently, perhaps that would generate the deadlock.
> I presume everything runs in one database, and that table A isn't in db 1, and B in a completely separate db instance?
Everything sits in one database.
> As http://dev.mysql.com/doc/refman/5.0/en/innodb-deadlocks.html says you should be prepared to re-issue a deadlocked transaction, and you can do this by catching the thrown exception and re-trying. There are some hints in that page to help try and figure out the root cause of the deadlocks at a MySQL level that could help.
Thanks for the link. I'll investigate.
> That said, deadlocks are unusual if the db is being treated well. The deadlocks are possibly a symptom of something else if they are frequent, or are happening on a single user dev box. Examples of problem causes are long running db transactions (where db transactions aren't appropriate) with activity by concurrent users.
>
> Deadlocks may also be a symptom of a process forking and trying to update something that that's still locked in the parent process, as it's not yet committed to the db.
>
> So, all in all, some extra info would help narrow down the cause. My suspicion is that the issue isn't in the few lines of code you sent, but perhaps the broader context that you're using them in.
Thanks for all the info.
Yours,
Andy
More information about the Chat
mailing list