What's the easiest way to simulate a "lock timeout" DatabaseError with Django using the MySQL backend?
I have a piece of code, that operates over large querysets, and occasionally it throws the exception:
DatabaseError: (1205, 'Lock wait timeout exceeded; try restarting transaction')
I understand what causes this and how to fix it, but I'm not sure how to test my fix since the error only happens in a production environment where several users are accessing certain tables simultaneously.
I first tried to run some sample code in a separate process to make Django apply a lock in MySQL, and while it does seem to lock the target table and make all other requests wait, a lock timeout never occurs when I test on my localhost with runserver. I let it run for 20 minutes without a timeout occurring.