Commit 966fb6a0 authored by Vincent Pelletier's avatar Vincent Pelletier

Products.CMFActivity.SQLBase: Always commit before returning

Committing serves two purposes:
- obviously: it makes any transactional data change persistent
- less obviously: it releases the database transactional snapshot taken by
  any previously issued query, allowing that snapshot and all snapshots
  after it to be also freed (ex: garbage collecting the data records that
  no other transaction can see)
In the current state of the code flow, this does not change much: after
this method returns the code flow should quickly hit a commit anyway,
either in dequeueMessage or before handing control back to timerserver,
thereby ending the Zope-initiated transaction.
But this will not be true in a future version of the code.
parent 02791ba1
...@@ -683,8 +683,8 @@ CREATE TABLE %s ( ...@@ -683,8 +683,8 @@ CREATE TABLE %s (
while 1: while 1:
result = self._getMessageList(db, **where_kw) result = self._getMessageList(db, **where_kw)
if not result: if not result:
transaction.commit()
return return
transaction.commit()
message_list = [Message.load(line.message, uid=line.uid, line=line) message_list = [Message.load(line.message, uid=line.uid, line=line)
for line in result] for line in result]
message_set = self._getExecutableMessageSet(activity_tool, db, message_list) message_set = self._getExecutableMessageSet(activity_tool, db, message_list)
...@@ -714,6 +714,7 @@ CREATE TABLE %s ( ...@@ -714,6 +714,7 @@ CREATE TABLE %s (
self.assignMessageList(db, 0, distributable_uid_set) self.assignMessageList(db, 0, distributable_uid_set)
validated_count += distributable_count validated_count += distributable_count
if validated_count >= MAX_VALIDATED_LIMIT: if validated_count >= MAX_VALIDATED_LIMIT:
transaction.commit()
return return
line = result[-1] line = result[-1]
where_kw['above_priority_date_uid'] = (line.priority, line.date, line.uid) where_kw['above_priority_date_uid'] = (line.priority, line.date, line.uid)
......
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