Fixed race condition in fetching task activities

Since MongoDB stores timestamps with a resolution of a millisecond, it was
possible for a task to be created and updated on the same timestamp, which
could cause an impossible ordering of the activities (edit before creation).
Sorting by ID instead of creation timestamp fixes this.
This commit is contained in:
2019-05-14 14:23:13 +02:00
parent 14530d76a9
commit 1e1420d92b
2 changed files with 2 additions and 2 deletions

View File

@@ -218,7 +218,7 @@ class AttractExtension(PillarExtension):
'context_object': node_id},
],
},
'sort': [('_created', -1)],
'sort': [('_id', 1)], # Sort by creation, _id is incremental.
'max_results': max_results,
'page': page,
}, api=api)

View File

@@ -51,7 +51,7 @@ def index():
'where': {
'project': {'$in': list(id_to_proj.keys())},
},
'sort': [('_created', -1)],
'sort': [('_id', 1)], # Sort by creation, _id is incremental.
'max_results': 20,
}, api=api)