Forums

Simple Django REST API Crashing??

I'm running a simple REST API on Django, but it keeps crashing on PythonAnywhere.

I'm trying to do 3 things at separate times that's causing a crash:

  • single insert
  • bulk_create
  • bulk delete

I don't think it's code related because even a simple thing like a single insert is causing it to crash. When I try an insert I'll get a 500 error, but then I'll wait 5 seconds and try again and it'll work??

I also get a Lock wait timeout exceeded when I try to bulk_insert or bulk_delete, but I'm only bulk inserting and bulk deleting around 1000 entries which should be a breeze.

Anyone have any suggestions?

2021-01-24 23:51:29 (1205, 'Lock wait timeout exceeded; try restarting transaction')

2021-01-24 23:53:13 Sun Jan 24 23:53:12 2021 - *** HARAKIRI ON WORKER 3 (pid: 32, try: 1) *** 
2021-01-24 23:53:13 Sun Jan 24 23:53:12 2021 - HARAKIRI !!! worker 3 status !!! 
2021-01-24 23:53:13 Sun Jan 24 23:53:12 2021 - HARAKIRI [core 0] 10.0.0.124 - DELETE /api/to_check_proxies/bulk_delete_nonworking_proxy/ since 1611531791 
2021-01-24 23:53:13 Sun Jan 24 23:53:12 2021 - HARAKIRI !!! end of worker 3 status !!! 
2021-01-24 23:53:13 DAMN ! worker 3 (pid: 32) died, killed by signal 9 :( trying respawn ... 
2021-01-24 23:53:13 Respawned uWSGI worker 3 (new pid: 38) 2021-01-24 23:53:13 spawned 2 offload threads for uWSGI worker 3

There's something locking your database -- could you try to reproduce the error? You could try using SHOW PROCESSLIST command in the MySQL command line to check which process is being responsible for that.