From ce21f6c7f7cf16f6769eceb872d17a77dd1ff4ad Mon Sep 17 00:00:00 2001 From: Collin Fair Date: Thu, 23 Oct 2014 21:26:57 -0700 Subject: [PATCH] Finally fix race condition in diag dashboard showing OK users as orphaned --- tapiriik/web/templates/diag/dashboard.html | 2 +- tapiriik/web/views/diagnostics.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/tapiriik/web/templates/diag/dashboard.html b/tapiriik/web/templates/diag/dashboard.html index d97ee7a43..9ab2f02c8 100644 --- a/tapiriik/web/templates/diag/dashboard.html +++ b/tapiriik/web/templates/diag/dashboard.html @@ -68,7 +68,7 @@

Sync

{{ userId|slice:":7" }} {{ userId }} {{ lockedUser.SynchronizationProgress|percentage }} - {% if lockedUser.SynchronizationWorker not in allWorkerPIDs %} (orphaned){% endif %}{% if lockedUser.SynchronizationWorker in stalledWorkerPIDs %} (stalled){% endif %} + {% if lockedUser.SynchronizationWorker not in allWorkerPIDs and lockedUser.SynchronizationWorker not in allWorkerPIDsPre %} (orphaned){% endif %}{% if lockedUser.SynchronizationWorker in stalledWorkerPIDs %} (stalled){% endif %} {% endwith %} {% endfor %} diff --git a/tapiriik/web/views/diagnostics.py b/tapiriik/web/views/diagnostics.py index 6c5e07845..2fe1e7a1c 100644 --- a/tapiriik/web/views/diagnostics.py +++ b/tapiriik/web/views/diagnostics.py @@ -22,6 +22,9 @@ def diag_dashboard(req): stall_timeout = timedelta(minutes=1) + # We fetch this twice so the (orphaned) indicators are correct even if there were writes during all these other queries + context["allWorkerPIDsPre"] = [x["Process"] for x in db.sync_workers.find()] + context["lockedSyncUsers"] = list(db.users.find({"SynchronizationWorker": {"$ne": None}})) context["lockedSyncRecords"] = len(context["lockedSyncUsers"])