In a unittest we run this:
BEGIN; TRUNCATE table1; TRUNCATE table2; ... UPDATE ...; ROLLBACK;
Unfortunately this results in a dead lock if a cron job starts and this job operates on table1 and table2.
DatabaseError: deadlock detected DETAIL: Process 15815 waits for AccessExclusiveLock on relation 291262 of database 290999; blocked by process 16391. Process 16391 waits for RowShareLock on relation 291431 of database 290999; blocked by process 15815.
Is there a way to isolate the unittest from the cron job (to avoid the dead lock)?
We run PostgreSQL 9.0.10 on x86_64 linux