In article <dZmdnTADM7ehJmvfRVn->,
Wibble <> wrote:
> John B. Matthews wrote:
> > In article <ELOdnQcnb4A-qmvfRVn->,
> > "Dilton McGowan II" <> wrote:
> > [...]
> >
> >>So it is not possible to write a deadlock free database application
> >>using Java technologies?
> >
> >
> > In general, it is not possible to write a deadlock free database
> > application using _any_ technology that permits more than one user to
> > update data. The avoidance of deadlocks is isomorphic to the halting
> > problem.
> >
> > In practice, high-quality database servers can attempt to detect
> > deadlock, and careful locking schemes can help limit resource
> > contention. But the problem is persistent. There's an informative
> > article here:
> >
> > http://en.wikipedia.org/wiki/Deadlock
> >
> Resource contention and deadlock are not the same thing.
True, but mutual exclusion is a necessary condition for deadlock. I
meant to suggest that the OP might look at judicious locking as a
possible solution.
> Contention means you have to wait for a lock, deadlock means you'll
> never get it because of mutual dependencies.
And you don't know if you'll be waiting a long time or forever
> Its impossible to build a database that can't deadlock, but not
> impossible to build a database application which avoids deadlock.
Indeed, the application is the best place to avoid deadlock because it
knows the most about what resources will be put in play.
> As you're link points out...
> http://en.wikipedia.org/wiki/Deadloc...ock_prevention.
After avoidance and prevention, the article goes on to deadlock
detection, offered by many database vendors as an artificial preemption
mechanism. An attempt may be made to degrade gracefully.
In one puzzling scenario, a remote replication operation that worked
fine at night was failing at random times when run (ad hoc) during the
day. The database declared a deadlock and periodically retried the
transaction. It turns out the network vendor was dropping packets during
busy times, and the retries just made the problem worse until nightfall!
--
John
jmatthews at wright dot edu
www dot wright dot edu/~john.matthews/