def __init__(self, db_conn, hs): super(RoomMemberWorkerStore, self).__init__(db_conn, hs) # Is the current_state_events.membership up to date? Or is the # background update still running? self._current_state_events_membership_up_to_date = False txn = LoggingTransaction( db_conn.cursor(), name="_check_safe_current_state_events_membership_updated", database_engine=self.database_engine, ) self._check_safe_current_state_events_membership_updated_txn(txn) txn.close() if self.hs.config.metrics_flags.known_servers: self._known_servers_count = 1 self.hs.get_clock().looping_call( run_as_background_process, 60 * 1000, "_count_known_servers", self._count_known_servers, ) self.hs.get_clock().call_later( 1000, run_as_background_process, "_count_known_servers", self._count_known_servers, ) LaterGauge( "synapse_federation_known_servers", "", [], lambda: self._known_servers_count, )
def __init__(self, db_conn, hs): super(RoomMemberWorkerStore, self).__init__(db_conn, hs) # Is the current_state_events.membership up to date? Or is the # background update still running? self._current_state_events_membership_up_to_date = False txn = LoggingTransaction( db_conn.cursor(), name="_check_safe_current_state_events_membership_updated", database_engine=self.database_engine, ) self._check_safe_current_state_events_membership_updated_txn(txn) txn.close()
def __init__(self, db_conn, hs): super(EventPushActionsWorkerStore, self).__init__(db_conn, hs) # These get correctly set by _find_stream_orderings_for_times_txn self.stream_ordering_month_ago = None self.stream_ordering_day_ago = None cur = LoggingTransaction( db_conn.cursor(), name="_find_stream_orderings_for_times_txn", database_engine=self.database_engine, ) self._find_stream_orderings_for_times_txn(cur) cur.close() self.find_stream_orderings_looping_call = self._clock.looping_call( self._find_stream_orderings_for_times, 10 * 60 * 1000) self._rotate_delay = 3 self._rotate_count = 10000
def __init__(self, db_conn, hs): super(EventPushActionsWorkerStore, self).__init__(db_conn, hs) # These get correctly set by _find_stream_orderings_for_times_txn self.stream_ordering_month_ago = None self.stream_ordering_day_ago = None cur = LoggingTransaction( db_conn.cursor(), name="_find_stream_orderings_for_times_txn", database_engine=self.database_engine, after_callbacks=[], exception_callbacks=[], ) self._find_stream_orderings_for_times_txn(cur) cur.close() self.find_stream_orderings_looping_call = self._clock.looping_call( self._find_stream_orderings_for_times, 10 * 60 * 1000 )
def r(conn): try: i = 0 N = 5 while True: try: txn = conn.cursor() return func( LoggingTransaction(txn, desc, self.database_engine, []), *args, **kwargs ) except self.database_engine.module.DatabaseError as e: if self.database_engine.is_deadlock(e): logger.warn("[TXN DEADLOCK] {%s} %d/%d", desc, i, N) if i < N: i += 1 conn.rollback() continue raise except Exception as e: logger.debug("[TXN FAIL] {%s} %s", desc, e) raise