Commit e69ff3a5 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Rescue the situation where a conflict error happens after executing an active object.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@8244 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5fa35e8d
...@@ -291,22 +291,6 @@ class SQLDict(RAMDict): ...@@ -291,22 +291,6 @@ class SQLDict(RAMDict):
# Release locks before starting a potentially long calculation # Release locks before starting a potentially long calculation
get_transaction().commit() get_transaction().commit()
except ConflictError:
# If a conflict occurs, abort the transaction to minimize the impact,
# then simply delay the operations.
get_transaction().abort()
for uid_list in uid_list_list:
activity_tool.SQLDict_setPriority(uid = uid_list, delay = VALIDATION_ERROR_DELAY,
retry = 1)
get_transaction().commit()
return 0
except:
# For other exceptions, put the messages to an invalid state immediately.
get_transaction().abort()
for uid_list in uid_list_list:
activity_tool.SQLDict_assignMessage(uid = uid_list, processing_node = INVOKE_ERROR_STATE)
get_transaction().commit()
return 0
# Try to invoke # Try to invoke
if group_method_id is not None: if group_method_id is not None:
...@@ -326,9 +310,28 @@ class SQLDict(RAMDict): ...@@ -326,9 +310,28 @@ class SQLDict(RAMDict):
# has no side effect. # has no side effect.
for m in message_list: for m in message_list:
if m.is_executed: if m.is_executed:
get_transaction().commit()
break break
else: else:
get_transaction().abort() get_transaction().abort()
except ConflictError:
# If a conflict occurs, abort the transaction to minimize the impact,
# then simply delay the operations.
get_transaction().abort()
for uid_list in uid_list_list:
if len(uid_list):
activity_tool.SQLDict_setPriority(uid = uid_list, delay = VALIDATION_ERROR_DELAY,
retry = 1)
get_transaction().commit()
return 0
except:
# For other exceptions, put the messages to an invalid state immediately.
get_transaction().abort()
for uid_list in uid_list_list:
if len(uid_list):
activity_tool.SQLDict_assignMessage(uid = uid_list, processing_node = INVOKE_ERROR_STATE)
get_transaction().commit()
return 0
for i in xrange(len(message_list)): for i in xrange(len(message_list)):
m = message_list[i] m = message_list[i]
......
...@@ -119,6 +119,11 @@ class SQLQueue(RAMQueue): ...@@ -119,6 +119,11 @@ class SQLQueue(RAMQueue):
priority = line.priority) priority = line.priority)
get_transaction().commit() # Release locks before starting a potentially long calculation get_transaction().commit() # Release locks before starting a potentially long calculation
return 0 return 0
# Try to invoke
activity_tool.invoke(m) # Try to invoke the message - what happens if read conflict error restarts transaction ?
if m.is_executed: # Make sure message could be invoked
get_transaction().commit() # If successful, commit
except ConflictError: except ConflictError:
# If a conflict occurs, catch it and delay the operation. # If a conflict occurs, catch it and delay the operation.
get_transaction().abort() get_transaction().abort()
...@@ -134,11 +139,8 @@ class SQLQueue(RAMQueue): ...@@ -134,11 +139,8 @@ class SQLQueue(RAMQueue):
return 0 return 0
# Try to invoke if m.is_executed:
activity_tool.invoke(m) # Try to invoke the message - what happens if read conflict error restarts transaction ?
if m.is_executed: # Make sure message could be invoked
activity_tool.SQLQueue_delMessage(uid=line.uid) # Delete it activity_tool.SQLQueue_delMessage(uid=line.uid) # Delete it
get_transaction().commit() # If successful, commit
else: else:
get_transaction().abort() # If not, abort transaction and start a new one get_transaction().abort() # If not, abort transaction and start a new one
if line.priority > MAX_PRIORITY: if line.priority > MAX_PRIORITY:
...@@ -146,12 +148,11 @@ class SQLQueue(RAMQueue): ...@@ -146,12 +148,11 @@ class SQLQueue(RAMQueue):
activity_tool.SQLQueue_assignMessage(uid=line.uid, processing_node = INVOKE_ERROR_STATE) activity_tool.SQLQueue_assignMessage(uid=line.uid, processing_node = INVOKE_ERROR_STATE)
# Assign message back to 'error' state # Assign message back to 'error' state
m.notifyUser(activity_tool) # Notify Error m.notifyUser(activity_tool) # Notify Error
get_transaction().commit() # and commit
else: else:
# Lower priority # Lower priority
activity_tool.SQLQueue_setPriority(uid=line.uid, date = next_processing_date, activity_tool.SQLQueue_setPriority(uid=line.uid, date = next_processing_date,
priority = line.priority + 1) priority = line.priority + 1)
get_transaction().commit() # Release locks before starting a potentially long calculation get_transaction().commit()
return 0 return 0
get_transaction().commit() # Release locks before starting a potentially long calculation get_transaction().commit() # Release locks before starting a potentially long calculation
return 1 return 1
......
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