Skip to content

Commit

Permalink
Merge pull request #698 from opengisch/QF-2638-master-node
Browse files Browse the repository at this point in the history
Ensure connection to the master node as soon as we have the DB session
  • Loading branch information
suricactus authored and m-kuhn committed Jun 22, 2023
1 parent add9467 commit 125f433
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions docker-app/qfieldcloud/core/management/commands/dequeue.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ def handle(self, *args, **options):

cancel_orphaned_workers()

with connection.cursor() as cursor:
# NOTE `pg_is_in_recovery` returns `FALSE` if connected to the master node
cursor.execute("SELECT pg_is_in_recovery()")
# there is no way `cursor.fetchone()` returns no rows, therefore ignore the type warning
if cursor.fetchone()[0]: # type: ignore
raise Exception(
"Expected `worker_wrapper` to be connected to the master DB node!"
)

queued_job = None

with transaction.atomic():
Expand Down

0 comments on commit 125f433

Please sign in to comment.