I've been having a few issues recently working with a large MySQL database within django, MySQL seems to be having issues with deadlocks.
I keep getting the error:
(1213, 'Deadlock found when trying to get lock; try restarting transaction')
Usually this seems to happen when calling the save or create functions for a new model instance (e.g).
payment = Payment.objects.create(
to_member=to_member,
to_name="%s" % to_member.username,
from_member=from_member,
from_name="%s" % from_member.username,
description="Resubscription",
type='resubscription',
amount=5.00,
currency=from_member,
processor='e-wallet'
)
The particular table I'm trying to insert into has about 3.1 million rows and a size of 2.2 GB.
In production the application has quite a number of active users (Member). The Payment model has two particular foreign keys (to_creator and from_member). So I wondered if that might be the cause of the be the cause of the issue rather than just on the Payment model?
I've tried tweaking various aspect of the mysql configuration to manage this, but I seem to either get more deadlocks or the whole system locks up!
Below are my current settings for the locks:
Any help would be greatly appreciated. I've been pulling my hair out over the last few days about this.
Dan