Commit 27712881 authored by Julien Muchembled's avatar Julien Muchembled

CMFActivity: fix possible over-reservation of messages

This often happens during reindexation of many objects:
the number of processable grouped messages often exceeds 100
and 1 extra message is reserved for nothing.

This fixes a regression caused by f02bc341
("CMFActivity: automatically reselect messages in 'processing=1' state").
parent a0f639a7
......@@ -146,11 +146,15 @@ class SQLBase(Queue):
If None (or not given) no limit apply.
"""
select = activity_tool.SQLBase_selectReservedMessageList
result = not group_method_id and select(table=self.sql_table, count=limit,
processing_node=processing_node)
if not result:
if group_method_id:
reserve = limit - 1
else:
result = select(table=self.sql_table, count=limit,
processing_node=processing_node)
reserve = limit - len(result)
if reserve:
activity_tool.SQLBase_reserveMessageList(table=self.sql_table,
count=limit, processing_node=processing_node, to_date=date,
count=reserve, processing_node=processing_node, to_date=date,
group_method_id=group_method_id)
result = select(table=self.sql_table,
processing_node=processing_node, count=limit)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment