Vikky wrote:
Writer/Reader senario:
~~~~~~~~~~~~~~~~~~~~~~~
When the WRITER first gets its plan approved, it acquires 'IS' lock on
tablespace and 'IX' lock on table. Now when READER comes just to read
some other rows of the same table it tries to acqurie 'IS' lock on the
tablespace and gets it (since 2 'IS' locks dont conflict). It then
tries to acquire 'IS' lock on the table for reading which again should
acquire, since an 'IS' lock does not conflict with 'IX' lock. This
implies that both processes should proceed without being blocked.
Can anyone please reason as to why DB2 behaves like this. Am I missing
something here ?
You're probably missing what happens after the writer updates one of the
rows. At this point the writer gets an X lock on that row until commit
time. Now when the reader attempts to access that locked row it can't,
therefore a lock wait.
If your business scenario allows it you can run the reader with UR
isolation lever; this should solve your problem. Alternatively, make
writer commit changes immediately.
Hope this helps.