我有一个表可以跟踪另一个表分区的最后更新时间,因此我们的协调器只需要检查自上次协调以来已更新的分区。有多个线程更新分区表,因此每次更新最新更新时间表的同一行多次。这显然会导致死锁。有没有办法通过只在提交时更新一次来防止这些死锁?
我在考虑可能使用会话本地临时表,但不确定如何在提交时将值传输到全局表。
There is no way to trigger a process on commit so that approach probably won't work.
Potentially, you could have each of the writer processes write to an Oracle Advanced Queue (AQ) and then have another process that de-queues the messages and actually applies them to the current table. That would mean that there would be some lag between the writer session committing and the AQ processor picking up and processing the message but that lag shouldn't be too long. You could do the same thing by having each writer thread insert into a queue-like table and having a separate thread process that table if you don't want to use AQ.
I'm confused, though, by how the process you are describing could cause a deadlock. Are you really talking about a deadlock (i.e. an ORA-00060 error is thrown and a deadlock trace file is generated)? What you are describing should lead to blocking locks, not deadlocks, unless there is more going on than you have told us.