Commit c8c37b27 authored by Vincent Pelletier's avatar Vincent Pelletier

Fix commit being issued inconditionaly between activites: "regular" activity...

Fix commit being issued inconditionaly between activites: "regular" activity failure do *not* cause "invoke" to raise, but cause is_executed to be false.
Fix SQLQueue_rollback acquisition context.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18508 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 2d0a1323
...@@ -262,11 +262,15 @@ class SQLQueue(RAMQueue, SQLBase): ...@@ -262,11 +262,15 @@ class SQLQueue(RAMQueue, SQLBase):
# Try to invoke # Try to invoke
try: try:
activity_tool.invoke(value[1]) activity_tool.invoke(value[1])
# Commit so that if a message raises it doesn't causes previous if value[1].is_executed:
# successfull messages to be rolled back. This commit might fail, # Commit so that if a message raises it doesn't causes previous
# so it is protected the same way as activity execution by the # successfull messages to be rolled back. This commit might fail,
# same "try" block. # so it is protected the same way as activity execution by the
get_transaction().commit() # same "try" block.
get_transaction().commit()
else:
# This message failed, revert.
abortTransactionSynchronously()
except: except:
# We must make sure that the message is not set as executed. # We must make sure that the message is not set as executed.
# It is possible that the message is executed but the commit # It is possible that the message is executed but the commit
...@@ -280,7 +284,7 @@ class SQLQueue(RAMQueue, SQLBase): ...@@ -280,7 +284,7 @@ class SQLQueue(RAMQueue, SQLBase):
# connection. As the transaction failed, we must rollback these # connection. As the transaction failed, we must rollback these
# potential changes before being allowed to commit in # potential changes before being allowed to commit in
# makeMessageListAvailable. # makeMessageListAvailable.
self.SQLQueue_rollback() activity_tool.SQLQueue_rollback()
makeMessageListAvailable([value[0]]) makeMessageListAvailable([value[0]])
except: except:
LOG('SQQueue', PANIC, 'Failed to free message: %r' % (value, ), error=sys.exc_info()) LOG('SQQueue', PANIC, 'Failed to free message: %r' % (value, ), error=sys.exc_info())
......
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