|
Oracle Internals page 57
Consider an airline seat reservation application. Two different customers may
simultaneously ask two different operators whether a seat is available on a
particular flight. What should the application do?
The application can use SELECT FOR UPDATE NOWAIT to retrieve the
information. This guarantees that if a seat appears to be available, then it has
already been locked, and a booking for that seat will be able to be successfully
taken. This is called early locking, or pessimistic locking.
The alternative is to defer the taking of a lock until the customer resolves to make
a booking. This is called late locking, or optimistic locking.
The choice of either pessimistic or optimistic locking affects the design of both
business and application processes. So careful thought is needed. Pessimistic
locking should be avoided where possible, despite being slightly easier to
implement, because it increases the risk of blocking locks. |
|