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:
@@ -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)
|
||||
|
@@ -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)
|
||||
|
||||
|
Reference in New Issue
Block a user