Commit 9821696f authored by Julien Muchembled's avatar Julien Muchembled

Fix deadlock with storages that "sync" on a new transaction

This backports a change from commit 227953b9.

NEO, as well as ZEO+server_sync (ERP5 backports this feature with a
monkey-patch), pings the server (primary master node in the case of NEO) on
new transactions. However, this round-trip is actually performed by the thread
that also does tasks requiring to lock the DB, like processing of invalidations.

Since transaction 1.6.1 (more precisely commit e581a120a6), IStorage.sync()
is called indirectly by DB.open() when a transaction has already begun,
and the DB must not be locked when this happens.
parent 465b3502
...@@ -753,19 +753,16 @@ class DB(object): ...@@ -753,19 +753,16 @@ class DB(object):
result = self.pool.pop() result = self.pool.pop()
assert result is not None assert result is not None
# open the connection.
result.open(transaction_manager)
# A good time to do some cache cleanup. # A good time to do some cache cleanup.
# (note we already have the lock) # (note we already have the lock)
self.pool.availableGC() self.pool.availableGC()
self.historical_pool.availableGC() self.historical_pool.availableGC()
return result
finally: finally:
self._r() self._r()
result.open(transaction_manager)
return result
def connectionDebugInfo(self): def connectionDebugInfo(self):
result = [] result = []
t = time.time() t = time.time()
......
...@@ -151,7 +151,7 @@ def connectionDebugInfo(): ...@@ -151,7 +151,7 @@ def connectionDebugInfo():
>>> before >>> before
[None, '\x03zY\xd8\xc0m9\xdd', None] [None, '\x03zY\xd8\xc0m9\xdd', None]
>>> opened >>> opened
['2008-12-04T20:40:44Z (1.40s)', '2008-12-04T20:40:45Z (0.30s)', None] ['2008-12-04T20:40:44Z (1.30s)', '2008-12-04T20:40:46Z (0.10s)', None]
>>> infos >>> infos
['test info (2)', ' (0)', ' (0)'] ['test info (2)', ' (0)', ' (0)']
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment