When multiple external resources are trying to access the DB locks and runs into cyclic wait, it may make the DB unresponsive.
Avoid Database deadlock
1. Can make a queue wherein we can verify and order the request to DB (To run the operations in FIFO order).
2. Less use of cursors as they lock the tables for long time (slow down the DML executions).
3. Keeping the transaction smaller (process query relation operation before start the transactions).