Regarding the database deadlocks, you might need to look into PostgreSQL tuning. I have written a bit about this in earlier posts, as we were facing the same sort of issues. This was on a Zammad 4.x system though, but PostgreSQL database tuning and best practices don’t change too much in 5.x. We are currently running 5.1.x and will soon be upgrading to 5.2.x with the same tuning in place. Please do read the comments by Zammad Core Team members about not just blindly copying parameters/advice and expecting it will solve your issues, you need to understand what its effects are.
I am hesitant of straight up giving you tips on where to look for tuning, as this is not appreciated by the Zammad Core Team without express warnings in place. Our setup is not yours and our tuning might cause unwanted side-effects in your environment.