Skip to content

Commit

Permalink
Finally fix race condition in diag dashboard showing OK users as orph…
Browse files Browse the repository at this point in the history
…aned
  • Loading branch information
cpfair committed Oct 24, 2014
1 parent 66c0d69 commit ce21f6c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tapiriik/web/templates/diag/dashboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ <h3>Sync</h3>
<td><a href="{% url 'diagnostics_user' user=userId %}">{{ userId|slice:":7" }}</a></td>
<td>{{ userId }}</td>
<td>{{ lockedUser.SynchronizationProgress|percentage }}</td>
<td>{% if lockedUser.SynchronizationWorker not in allWorkerPIDs %} <span style="color:red">(orphaned)</span>{% endif %}{% if lockedUser.SynchronizationWorker in stalledWorkerPIDs %} <span style="color:orange;">(stalled)</span>{% endif %}</td>
<td>{% if lockedUser.SynchronizationWorker not in allWorkerPIDs and lockedUser.SynchronizationWorker not in allWorkerPIDsPre %} <span style="color:red">(orphaned)</span>{% endif %}{% if lockedUser.SynchronizationWorker in stalledWorkerPIDs %} <span style="color:orange;">(stalled)</span>{% endif %}</td>
</tr>
{% endwith %}
{% endfor %}
Expand Down
3 changes: 3 additions & 0 deletions tapiriik/web/views/diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand Down

0 comments on commit ce21f6c

Please sign in to comment.