Commit 030278df authored by Yoshinori Okuji's avatar Yoshinori Okuji

Add paranoid logging.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13673 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 273eeefc
...@@ -43,7 +43,7 @@ try: ...@@ -43,7 +43,7 @@ try:
except ImportError: except ImportError:
pass pass
from zLOG import LOG, TRACE, WARNING from zLOG import LOG, TRACE, WARNING, ERROR
MAX_PRIORITY = 5 MAX_PRIORITY = 5
MAX_GROUPED_OBJECTS = 500 MAX_GROUPED_OBJECTS = 500
...@@ -206,7 +206,7 @@ class SQLDict(RAMDict): ...@@ -206,7 +206,7 @@ class SQLDict(RAMDict):
# If the result is still empty, shift the dates so that SQLDict can dispatch pending active # If the result is still empty, shift the dates so that SQLDict can dispatch pending active
# objects quickly. # objects quickly.
self.timeShift(activity_tool, VALIDATION_ERROR_DELAY, processing_node,retry=1) self.timeShift(activity_tool, VALIDATION_ERROR_DELAY, processing_node,retry=1)
elif len(result) > 0: else:
#LOG('SQLDict dequeueMessage', 100, 'result = %r' % (list(result))) #LOG('SQLDict dequeueMessage', 100, 'result = %r' % (list(result)))
line = result[0] line = result[0]
path = line.path path = line.path
...@@ -321,57 +321,71 @@ class SQLDict(RAMDict): ...@@ -321,57 +321,71 @@ class SQLDict(RAMDict):
# Unfortunately, database adapters may raise an exception against abort. # Unfortunately, database adapters may raise an exception against abort.
LOG('SQLDict', WARNING, 'abort failed, thus some objects may be modified accidentally') LOG('SQLDict', WARNING, 'abort failed, thus some objects may be modified accidentally')
pass pass
if isinstance(exc, ConflictError): try:
# For a conflict error, simply delay the operations. if isinstance(exc, ConflictError):
for uid_list in uid_list_list: # For a conflict error, simply delay the operations.
if len(uid_list): for uid_list in uid_list_list:
activity_tool.SQLDict_setPriority(uid = uid_list, if len(uid_list):
delay = VALIDATION_ERROR_DELAY, activity_tool.SQLDict_setPriority(uid = uid_list,
retry = 1) delay = VALIDATION_ERROR_DELAY,
else: retry = 1)
# For other exceptions, put the messages to an invalid state immediately. else:
for uid_list in uid_list_list: # For other exceptions, put the messages to an invalid state immediately.
if len(uid_list): for uid_list in uid_list_list:
activity_tool.SQLDict_assignMessage(uid = uid_list, if len(uid_list):
processing_node = INVOKE_ERROR_STATE) activity_tool.SQLDict_assignMessage(uid = uid_list,
LOG('SQLDict', WARNING, processing_node = INVOKE_ERROR_STATE)
'Error in ActivityTool.invoke', error=sys.exc_info()) LOG('SQLDict', WARNING,
'Error in ActivityTool.invoke', error=sys.exc_info())
get_transaction().commit()
get_transaction().commit()
except:
LOG('SQLDict', ERROR, 'SQLDict.dequeueMessage raised, and cannot even set processing to zero due to an exception',
error=sys.exc_info())
raise
return 0 return 0
except:
LOG('SQLDict', ERROR, 'SQLDict.dequeueMessage raised an exception which is not a subclass of Exception',
error=sys.exc_info())
raise
for i in xrange(len(message_list)): try:
m = message_list[i] for i in xrange(len(message_list)):
uid_list = uid_list_list[i] m = message_list[i]
priority = priority_list[i] uid_list = uid_list_list[i]
if m.is_executed: priority = priority_list[i]
if len(uid_list) > 0: if m.is_executed:
activity_tool.SQLDict_delMessage(uid = uid_list) # Delete it
get_transaction().commit() # If successful, commit
if m.active_process:
active_process = activity_tool.unrestrictedTraverse(m.active_process)
if not active_process.hasActivity():
# No more activity
m.notifyUser(activity_tool, message="Process Finished") # XXX commit bas ???
else:
if type(m.exc_type) is ClassType and 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
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_delMessage(uid = uid_list) # Delete it
# Assign message back to 'error' state get_transaction().commit() # If successful, commit
m.notifyUser(activity_tool) # Notify Error if m.active_process:
get_transaction().commit() # and commit active_process = activity_tool.unrestrictedTraverse(m.active_process)
if not active_process.hasActivity():
# No more activity
m.notifyUser(activity_tool, message="Process Finished") # XXX commit bas ???
else: else:
# Lower priority if type(m.exc_type) is ClassType and issubclass(m.exc_type, ConflictError):
if len(uid_list) > 0: # 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, activity_tool.SQLDict_setPriority(uid = uid_list, delay = VALIDATION_ERROR_DELAY,
priority = priority + 1, retry = 1) retry = 1)
get_transaction().commit() # Release locks before starting a potentially long calculation get_transaction().commit() # Release locks before starting a potentially long calculation
elif priority > MAX_PRIORITY:
# This is an error
if len(uid_list) > 0:
activity_tool.SQLDict_assignMessage(uid = uid_list, processing_node = INVOKE_ERROR_STATE)
# Assign message back to 'error' state
m.notifyUser(activity_tool) # Notify Error
get_transaction().commit() # and commit
else:
# Lower priority
if len(uid_list) > 0:
activity_tool.SQLDict_setPriority(uid = uid_list, delay = VALIDATION_ERROR_DELAY,
priority = priority + 1, retry = 1)
get_transaction().commit() # Release locks before starting a potentially long calculation
except:
LOG('SQLDict', ERROR, 'SQLDict.dequeueMessage raised an exception during checking for the results of processed messages',
error=sys.exc_info())
raise
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
......
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