home contents changes options help subscribe edit (external edit)

Preventing Deadlock with Multiple Storages

A database that mounts multiple storages can deadlock if a transaction involves objects from multiple connections (storages). The transaction manager can call tpc_begin() in arbitrary order. If two transactions are committed simulatenously, either by different threads in a single database or by different clients using the same ZEO server, it is possible for clients to deadlock trying to acquire all necessary locks.

The solution to this problem is to impose a global order on storages and have all clients acquire locks in this order. ZODB uses strict two-phase locking. All locks are acquired during the commit phase of a transaction, when all the transaction participants are known.

The storage API will change to define a sortKey() method that is used to order storages. All data managers, like Connection, must also define a sortKey() method that delegates to the storage.

We can work around old storage implementations that do no define sortKey() but they run the risk of deadlock.



subject:
  ( 11 subscribers )