デッドロックの公式見解


DB2のインフォセンターで見つけました。

http://www-3.ibm.com/cgi-bin/db2www/data/db2/udb/winos2unix/support/v8document.d2w/report?fn=c0005271.htm

A different problem occurs when an application with more than one independent process 
that accesses the database is structured to make deadlocks likely. 
An example is an application in which several processes access the same table for reads and then writes. 
If the processes do read-only SQL queries at first and then do SQL updates on the same table, 
the chance of deadlocks increases because of potential contention between the processes for the same data. 
For instance, if two processes read the table, and then update the table, 
process A might try to get an X lock on a row on which process B has an S lock, and vice versa. 
To avoid such deadlocks, applications that access data with the intention of modifying 
it should use the FOR UPDATE OF clause when performing a select. 
This clause ensures that a U lock is imposed when process A attempts to read the data. 



2003/07/02 ugya@lycos.com