I have a process A that starts every 5 minutes and needs to write something in the "EventLog" table. This works all day, but at night there is another process B that should remove a lot of old data from this table. The table contains millions of rows (including blobs) and many related tables (cascading), so process B runs up to ~ 45 minutes. While process B is running, I get many lock warnings for process A, and I want to get rid of them.
The easy option would be "Do not start process A when starting process B," but there should be a better approach. I use EntityFramework 6 and TransactionScope in both processes. I did not learn how to set priority or something similar in my processes. Is it possible?
EDIT:
I forgot to say that I already use one delete transaction per record, and not one transaction for all records. Inside the loop, I create a new DBContext and TransactionScope, so each record has its own transaction. My problem is that deleting a record still takes some time due to related BLOB data and data in other related tables (say, about 5 seconds per row). I still get deadlocks when the delete process (B) crosses the insert process (A).
source
share