Commit ad7efaf9 authored by Yoshinori Okuji's avatar Yoshinori Okuji

Do not reraise ConflictError, but handle it explicitly. When ConflictError...

Do not reraise ConflictError, but handle it explicitly. When ConflictError occurs, delaying the execution of an active object. Also, do not cache the result of getObjectList, because this might lead to an inconsistent state.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@4464 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 1789de85
...@@ -239,8 +239,6 @@ class SQLDict(RAMDict): ...@@ -239,8 +239,6 @@ class SQLDict(RAMDict):
if m.hasExpandMethod(): if m.hasExpandMethod():
try: try:
count = len(m.getObjectList(activity_tool)) count = len(m.getObjectList(activity_tool))
except ConflictError:
raise
except: except:
# Here, simply ignore an exception. The same exception should be handled later. # Here, simply ignore an exception. The same exception should be handled later.
LOG('SQLDict', 0, 'ignoring an exception from getObjectList', error=sys.exc_info()) LOG('SQLDict', 0, 'ignoring an exception from getObjectList', error=sys.exc_info())
...@@ -272,8 +270,6 @@ class SQLDict(RAMDict): ...@@ -272,8 +270,6 @@ class SQLDict(RAMDict):
if m.hasExpandMethod(): if m.hasExpandMethod():
try: try:
count += len(m.getObjectList(activity_tool)) count += len(m.getObjectList(activity_tool))
except ConflictError:
raise
except: except:
# Here, simply ignore an exception. The same exception should be handled later. # Here, simply ignore an exception. The same exception should be handled later.
LOG('SQLDict', 0, 'ignoring an exception from getObjectList', error=sys.exc_info()) LOG('SQLDict', 0, 'ignoring an exception from getObjectList', error=sys.exc_info())
...@@ -322,7 +318,12 @@ class SQLDict(RAMDict): ...@@ -322,7 +318,12 @@ class SQLDict(RAMDict):
# No more activity # No more activity
m.notifyUser(activity_tool, message="Process Finished") # XXX commit bas ??? m.notifyUser(activity_tool, message="Process Finished") # XXX commit bas ???
else: else:
if priority > MAX_PRIORITY: if issubclass(m.exc_type, ConflictError):
# If this is a conflict error, do not lower the priority but only delay.
activity_tool.SQLDict_setPriority(uid = uid_list, delay = VALIDATION_ERROR_DELAY,
retry = 1)
get_transaction().commit() # Release locks before starting a potentially long calculation
elif priority > MAX_PRIORITY:
# This is an error # This is an error
if len(uid_list) > 0: if len(uid_list) > 0:
activity_tool.SQLDict_assignMessage(uid = uid_list, processing_node = INVOKE_ERROR_STATE) activity_tool.SQLDict_assignMessage(uid = uid_list, processing_node = INVOKE_ERROR_STATE)
......
...@@ -93,24 +93,23 @@ class Message: ...@@ -93,24 +93,23 @@ class Message:
self.args = args self.args = args
self.kw = kw self.kw = kw
self.is_executed = 0 self.is_executed = 0
self.exc_type = None
self.user_name = str(_getAuthenticatedUser(self)) self.user_name = str(_getAuthenticatedUser(self))
self.object_list = None
# Store REQUEST Info ? # Store REQUEST Info ?
def getObject(self, activity_tool): def getObject(self, activity_tool):
return activity_tool.unrestrictedTraverse(self.object_path) return activity_tool.unrestrictedTraverse(self.object_path)
def getObjectList(self, activity_tool): def getObjectList(self, activity_tool):
if getattr(self, 'object_list', None) is None: try:
try: expand_method_id = self.activity_kw['expand_method_id']
expand_method_id = self.activity_kw['expand_method_id'] obj = self.getObject(activity_tool)
obj = self.getObject(activity_tool) # FIXME: how to pass parameters?
# FIXME: how to pass parameters? object_list = getattr(obj, expand_method_id)()
self.object_list = getattr(obj, expand_method_id)() except KeyError:
except KeyError: object_list = [self.getObject(activity_tool)]
self.object_list = [self.getObject(activity_tool)]
return self.object_list return object_list
def hasExpandMethod(self): def hasExpandMethod(self):
return self.activity_kw.has_key('expand_method_id') return self.activity_kw.has_key('expand_method_id')
...@@ -148,10 +147,9 @@ class Message: ...@@ -148,10 +147,9 @@ class Message:
self.changeUser(current_user, activity_tool) self.changeUser(current_user, activity_tool)
self.activateResult(activity_tool, result, object) self.activateResult(activity_tool, result, object)
self.is_executed = 1 self.is_executed = 1
except ConflictError:
raise
except: except:
self.is_executed = 0 self.is_executed = 0
self.exc_type = sys.exc_info()[0]
LOG('WARNING ActivityTool', 0, LOG('WARNING ActivityTool', 0,
'Could not call method %s on object %s' % (self.method_id, self.object_path), error=sys.exc_info()) 'Could not call method %s on object %s' % (self.method_id, self.object_path), error=sys.exc_info())
...@@ -593,10 +591,9 @@ class ActivityTool (Folder, UniqueObject): ...@@ -593,10 +591,9 @@ class ActivityTool (Folder, UniqueObject):
expanded_object_list.append(obj) expanded_object_list.append(obj)
object_list.append(obj) object_list.append(obj)
new_message_list.append(m) new_message_list.append(m)
except ConflictError:
raise
except: except:
m.is_executed = 0 m.is_executed = 0
m.exc_type = sys.exc_info()[0]
LOG('WARNING ActivityTool', 0, LOG('WARNING ActivityTool', 0,
'Could not call method %s on object %s' % (m.method_id, m.object_path), error=sys.exc_info()) 'Could not call method %s on object %s' % (m.method_id, m.object_path), error=sys.exc_info())
...@@ -608,12 +605,11 @@ class ActivityTool (Folder, UniqueObject): ...@@ -608,12 +605,11 @@ class ActivityTool (Folder, UniqueObject):
# NOTE: expanded_object_list must be set to failed objects by the callee. # NOTE: expanded_object_list must be set to failed objects by the callee.
# If it fully succeeds, expanded_object_list must be empty when returning. # If it fully succeeds, expanded_object_list must be empty when returning.
result = method(expanded_object_list) result = method(expanded_object_list)
except ConflictError:
raise
except: except:
# In this case, the group method completely failed. # In this case, the group method completely failed.
for m in new_message_list: for m in new_message_list:
m.is_executed = 0 m.is_executed = 0
m.exc_type = sys.exc_info()[0]
LOG('WARNING ActivityTool', 0, LOG('WARNING ActivityTool', 0,
'Could not call method %s on objects %s' % (method_id, expanded_object_list), error=sys.exc_info()) 'Could not call method %s on objects %s' % (method_id, expanded_object_list), error=sys.exc_info())
else: else:
...@@ -636,10 +632,9 @@ class ActivityTool (Folder, UniqueObject): ...@@ -636,10 +632,9 @@ class ActivityTool (Folder, UniqueObject):
try: try:
m.activateResult(self, result, object) m.activateResult(self, result, object)
m.is_executed = 1 m.is_executed = 1
except ConflictError:
raise
except: except:
m.is_executed = 0 m.is_executed = 0
m.exc_type = sys.exc_info()[0]
LOG('WARNING ActivityTool', 0, LOG('WARNING ActivityTool', 0,
'Could not call method %s on object %s' % (m.method_id, m.object_path), error=sys.exc_info()) 'Could not call method %s on object %s' % (m.method_id, m.object_path), 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