From f16b3cf2fde877106dcbf11947da1946f18f0aa9 Mon Sep 17 00:00:00 2001 From: mlbonhomme <bonhomme@teklia.com> Date: Mon, 30 Oct 2023 15:55:06 +0100 Subject: [PATCH] Use default db when retrieving active agents in Agent.next_tasks --- arkindex/ponos/models.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/arkindex/ponos/models.py b/arkindex/ponos/models.py index e85e87c254..733bec3979 100644 --- a/arkindex/ponos/models.py +++ b/arkindex/ponos/models.py @@ -212,9 +212,10 @@ class Agent(models.Model): if not pending_tasks.exists(): return [] - # Retrieve active agents within the same farm + # Retrieve active agents within the same farm, using the default database to avoid a stale-read if there are + # no active agents, then an agent becomes active and asks for its actions active_agents = ( - Agent.objects + Agent.objects.using('default') .filter( last_ping__gte=timezone.now() - AGENT_TIMEOUT, farm_id=self.farm_id, -- GitLab