From 4e1eb888e580719ce27fb6f45a77c58fc07f054f Mon Sep 17 00:00:00 2001 From: Lloyd Date: Thu, 18 Dec 2025 22:12:25 +0000 Subject: [PATCH] Refactor database connection handling in StorageCollector and reduce log verbosity in RoomServer to minimize spam during idle periods --- repeater/data_acquisition/storage_collector.py | 3 ++- repeater/handler_helpers/room_server.py | 14 ++------------ 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/repeater/data_acquisition/storage_collector.py b/repeater/data_acquisition/storage_collector.py index fbce9a3..9e49d4e 100644 --- a/repeater/data_acquisition/storage_collector.py +++ b/repeater/data_acquisition/storage_collector.py @@ -198,7 +198,8 @@ class StorageCollector: Node name if found, None otherwise """ try: - with self.sqlite_handler.get_connection() as conn: + import sqlite3 + with sqlite3.connect(self.sqlite_handler.sqlite_path) as conn: result = conn.execute( "SELECT node_name FROM adverts WHERE pubkey = ? AND node_name IS NOT NULL ORDER BY last_seen DESC LIMIT 1", (pubkey,) diff --git a/repeater/handler_helpers/room_server.py b/repeater/handler_helpers/room_server.py index 6f6ecdf..178ba15 100644 --- a/repeater/handler_helpers/room_server.py +++ b/repeater/handler_helpers/room_server.py @@ -500,15 +500,11 @@ class RoomServer: # Get all clients for this room all_clients = self.acl.get_all_clients() if not all_clients: - logger.debug(f"Room '{self.room_name}': No authenticated clients found") + # Only log once when transitioning from clients to no clients + # to avoid log spam when room is idle self.next_push_time = time.time() + 1.0 # Check again in 1 second continue - logger.debug( - f"Room '{self.room_name}': Found {len(all_clients)} authenticated client(s), " - f"checking for unsynced messages" - ) - # SAFETY: Limit number of clients if len(all_clients) > MAX_CLIENTS_PER_ROOM: logger.warning( @@ -573,12 +569,6 @@ class RoomServer: last_activity=time.time() ) - # Log the sync check for debugging - logger.debug( - f"Room '{self.room_name}': Checking client 0x{client.id.get_public_key()[0]:02X} " - f"for messages newer than sync_since={sync_since:.1f}" - ) - # Find next unsynced message for this client unsynced = self.db.get_unsynced_messages( room_hash=f"0x{self.room_hash:02X}",