Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
More logging for the linearizer and for get_events
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Haines committed Jan 5, 2017
1 parent e1c5463 commit dd3df11
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions synapse/storage/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1084,8 +1084,10 @@ def _enqueue_events(self, events, check_redacted=True, allow_rejected=False):
self._do_fetch
)

logger.info("Loading %d events", len(events))
with PreserveLoggingContext():
rows = yield events_d
logger.info("Loaded %d events (%d rows)", len(events), len(rows))

if not allow_rejected:
rows[:] = [r for r in rows if not r["rejects"]]
Expand Down
13 changes: 11 additions & 2 deletions synapse/util/async.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,11 @@ class Linearizer(object):
# do some work.
"""
def __init__(self):
def __init__(self, name=None):
if name is None:
self.name = id(self)
else:
self.name = name
self.key_to_defer = {}

@defer.inlineCallbacks
Expand All @@ -185,15 +189,20 @@ def queue(self, key):
self.key_to_defer[key] = new_defer

if current_defer:
logger.info("Waiting to acquire linearizer lock for key %r", key)
logger.info(
"Waiting to acquire linearizer lock %r for key %r", self.name, key
)
with PreserveLoggingContext():
yield current_defer

logger.info("Acquired linearizer lock %r for key %r", self.name, key)

@contextmanager
def _ctx_manager():
try:
yield
finally:
logger.info("Releasing linearizer lock %r for key %r", self.name, key)
new_defer.callback(None)
current_d = self.key_to_defer.get(key)
if current_d is new_defer:
Expand Down

0 comments on commit dd3df11

Please sign in to comment.