Re: Writable lock nested in read-only lock
Martin Matula <[email protected]> Mon, 30 Sep 2002 21:13:40 +0200
| Newsgroups | gmane.comp.java.netbeans.modules.mdr.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi Brian, Brian Smith wrote: > Isn't this a problem no matter what, even if I start the outer > transaction as a read-write transaction? No without introducing an external lock. Then of course you can have deadlock even without using MDR and transactions at all :). Usually when you introduce an external lock and use it by two different threads the threads know of each other. This is not the case with threads using MDR. There can be different independent modules working on the same instance of MDR. Now when one thread of one module decides to read and the thread of another module decides to read, they both are granted the read access. Now one of the modules decides to start writing inside of the read. And the other module decides to do that too - now you come to a deadlock, because the first module is waiting for the second module to leave the read transaction and vice versa. It is not feasible to allow that, because it is practically impossible to prevent such a deadlock. It could be solved by releasing the read lock when waiting for write lock, but that would lead to unexpected results. > For my application, having READ_ONLY_PROMOTABLE would be perfect but > READ_WRITE_DEMOTABLE (which should never cause any deadlock problems, > right?) would be "good enough". OK, I will think about adding the DEMOTABLE transactions when I will revisit the transactions API. Martin