Auto-update: Mon Aug 12 20:47:35 PDT 2024

This commit is contained in:
sanj 2024-08-12 20:47:35 -07:00
parent 26d0fb763e
commit bf6518c80e

View file

@ -149,7 +149,7 @@ class Database:
result_checksum = hashlib.md5(result_str.encode()).hexdigest() result_checksum = hashlib.md5(result_str.encode()).hexdigest()
# Add the write query to the query_tracking table # Add the write query to the query_tracking table
await self.add_query_to_tracking(query, kwargs, result_checksum) await self.add_query_to_tracking(query, serialized_kwargs, result_checksum)
# Initiate async operations # Initiate async operations
asyncio.create_task(self._async_sync_operations()) asyncio.create_task(self._async_sync_operations())
@ -173,18 +173,21 @@ class Database:
l.error(f"Error in async sync operations: {str(e)}") l.error(f"Error in async sync operations: {str(e)}")
l.error(f"Traceback: {traceback.format_exc()}") l.error(f"Traceback: {traceback.format_exc()}")
async def add_query_to_tracking(self, query: str, kwargs: dict):
async def add_query_to_tracking(self, query: str, kwargs: dict, result_checksum: str):
async with self.sessions[self.local_ts_id]() as session: async with self.sessions[self.local_ts_id]() as session:
new_query = QueryTracking( new_query = QueryTracking(
ts_id=self.local_ts_id, ts_id=self.local_ts_id,
query=query, query=query,
args=json_dumps(kwargs), args=json_dumps(kwargs),
completed_by={self.local_ts_id: True} completed_by={self.local_ts_id: True},
result_checksum=result_checksum
) )
session.add(new_query) session.add(new_query)
await session.commit() await session.commit()
async def pull_query_tracking_from_primary(self): async def pull_query_tracking_from_primary(self):
primary_ts_id = await self.get_primary_server() primary_ts_id = await self.get_primary_server()
if not primary_ts_id: if not primary_ts_id: