I have a stored procedure (called from Appian’s Execute Stored Procedure smart service) that reads from a view and then creates, updates, or deletes rows in a materialized table that is also sourced from that same view.
The view is heavily used by multiple applications, so I created the stored procedure smart service to read the updated values from the view and reflect them in the materialized table. This process is triggered by various create or update forms across different applications.
Most of the time the stored procedure works, but sometimes it fails with the following error:
Deadlock found when trying to get lock; try restarting transaction
How can I reduce or avoid these deadlocks?
Discussion posts and replies are publicly visible
I want to help you with few points to avoid this :Always SELECT/UPDATE rows sorted by primary key.Add indexes on view's join/filter columns and copy table keys.Queue concurrent Appian process triggers.Add retry logic in process model for deadlock errors.