Commit b44816f6 authored by Vincent Pelletier's avatar Vincent Pelletier

Lower log priority from PANIC to ERROR for message status handling definitive...

Lower log priority from PANIC to ERROR for message status handling definitive errors (reserve PANIC priority to permanent data inconsistency).
When a PANIC level error happens, re-raise after logging instead of simply returning.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@19090 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 629a8f39
...@@ -294,7 +294,7 @@ class SQLDict(RAMDict, SQLBase): ...@@ -294,7 +294,7 @@ class SQLDict(RAMDict, SQLBase):
try: try:
makeMessageListAvailable(to_free_uid_list) makeMessageListAvailable(to_free_uid_list)
except: except:
LOG('SQLDict', PANIC, 'Failed to free messages: %r' % (to_free_uid_list, ), error=sys.exc_info()) LOG('SQLDict', ERROR, 'Failed to free messages: %r' % (to_free_uid_list, ), error=sys.exc_info())
else: else:
if len(to_free_uid_list): if len(to_free_uid_list):
LOG('SQLDict', TRACE, 'Freed messages %r' % (to_free_uid_list, )) LOG('SQLDict', TRACE, 'Freed messages %r' % (to_free_uid_list, ))
...@@ -350,7 +350,7 @@ class SQLDict(RAMDict, SQLBase): ...@@ -350,7 +350,7 @@ class SQLDict(RAMDict, SQLBase):
try: try:
activity_tool.SQLDict_delMessage(uid=deletable_uid_list) activity_tool.SQLDict_delMessage(uid=deletable_uid_list)
except: except:
LOG('SQLDict', PANIC, 'Failed to delete messages %r' % (deletable_uid_list, ), error=sys.exc_info()) LOG('SQLDict', ERROR, 'Failed to delete messages %r' % (deletable_uid_list, ), error=sys.exc_info())
else: else:
LOG('SQLDict', TRACE, 'Deleted messages %r' % (deletable_uid_list, )) LOG('SQLDict', TRACE, 'Deleted messages %r' % (deletable_uid_list, ))
if len(delay_uid_list): if len(delay_uid_list):
...@@ -358,19 +358,19 @@ class SQLDict(RAMDict, SQLBase): ...@@ -358,19 +358,19 @@ class SQLDict(RAMDict, SQLBase):
# If this is a conflict error, do not lower the priority but only delay. # If this is a conflict error, do not lower the priority but only delay.
activity_tool.SQLDict_setPriority(uid=delay_uid_list, delay=VALIDATION_ERROR_DELAY) activity_tool.SQLDict_setPriority(uid=delay_uid_list, delay=VALIDATION_ERROR_DELAY)
except: except:
LOG('SQLDict', PANIC, 'Failed to delay %r' % (delay_uid_list, ), error=sys.exc_info()) LOG('SQLDict', ERROR, 'Failed to delay %r' % (delay_uid_list, ), error=sys.exc_info())
make_available_uid_list += delay_uid_list make_available_uid_list += delay_uid_list
if len(final_error_uid_list): if len(final_error_uid_list):
try: try:
activity_tool.SQLDict_assignMessage(uid=final_error_uid_list, activity_tool.SQLDict_assignMessage(uid=final_error_uid_list,
processing_node=INVOKE_ERROR_STATE) processing_node=INVOKE_ERROR_STATE)
except: except:
LOG('SQLDict', PANIC, 'Failed to set message to error state for %r' % (final_error_uid_list, ), error=sys.exc_info()) LOG('SQLDict', ERROR, 'Failed to set message to error state for %r' % (final_error_uid_list, ), error=sys.exc_info())
if len(make_available_uid_list): if len(make_available_uid_list):
try: try:
makeMessageListAvailable(make_available_uid_list) makeMessageListAvailable(make_available_uid_list)
except: except:
LOG('SQLDict', PANIC, 'Failed to unreserve %r' % (make_available_uid_list, ), error=sys.exc_info()) LOG('SQLDict', ERROR, 'Failed to unreserve %r' % (make_available_uid_list, ), error=sys.exc_info())
else: else:
LOG('SQLDict', TRACE, 'Freed messages %r' % (make_available_uid_list, )) LOG('SQLDict', TRACE, 'Freed messages %r' % (make_available_uid_list, ))
try: try:
...@@ -421,12 +421,12 @@ class SQLDict(RAMDict, SQLBase): ...@@ -421,12 +421,12 @@ class SQLDict(RAMDict, SQLBase):
# Unfortunately, database adapters may raise an exception against abort. # Unfortunately, database adapters may raise an exception against abort.
LOG('SQLDict', PANIC, LOG('SQLDict', PANIC,
'abort failed, thus some objects may be modified accidentally') 'abort failed, thus some objects may be modified accidentally')
return True # Stop processing messages for this tic call for this queue. raise
to_free_uid_list = [x[0] for x in message_uid_priority_list] to_free_uid_list = [x[0] for x in message_uid_priority_list]
try: try:
makeMessageListAvailable(to_free_uid_list) makeMessageListAvailable(to_free_uid_list)
except: except:
LOG('SQLDict', PANIC, 'Failed to free messages: %r' % (to_free_uid_list, ), error=sys.exc_info()) LOG('SQLDict', ERROR, 'Failed to free messages: %r' % (to_free_uid_list, ), error=sys.exc_info())
else: else:
LOG('SQLDict', TRACE, 'Freed messages %r' % (to_free_uid_list)) LOG('SQLDict', TRACE, 'Freed messages %r' % (to_free_uid_list))
# Abort if something failed. # Abort if something failed.
...@@ -445,12 +445,12 @@ class SQLDict(RAMDict, SQLBase): ...@@ -445,12 +445,12 @@ class SQLDict(RAMDict, SQLBase):
abortTransactionSynchronously() abortTransactionSynchronously()
except: except:
LOG('SQLDict', PANIC, 'Failed to abort executed messages which also failed to commit. Some objects may be modified accidentally.') LOG('SQLDict', PANIC, 'Failed to abort executed messages which also failed to commit. Some objects may be modified accidentally.')
return True # Stop processing messages for this tic call for this queue. raise
failed_message_uid_list = [x[0] for x in message_uid_priority_list] failed_message_uid_list = [x[0] for x in message_uid_priority_list]
try: try:
makeMessageListAvailable(failed_message_uid_list) makeMessageListAvailable(failed_message_uid_list)
except: except:
LOG('SQLDict', PANIC, 'Failed to free remaining messages: %r' % (failed_message_uid_list, ), error=sys.exc_info()) LOG('SQLDict', ERROR, 'Failed to free remaining messages: %r' % (failed_message_uid_list, ), error=sys.exc_info())
else: else:
LOG('SQLDict', TRACE, 'Freed messages %r' % (failed_message_uid_list, )) LOG('SQLDict', TRACE, 'Freed messages %r' % (failed_message_uid_list, ))
self.finalizeMessageExecution(activity_tool, message_uid_priority_list) self.finalizeMessageExecution(activity_tool, message_uid_priority_list)
......
...@@ -176,7 +176,7 @@ class SQLQueue(RAMQueue, SQLBase): ...@@ -176,7 +176,7 @@ class SQLQueue(RAMQueue, SQLBase):
try: try:
makeMessageListAvailable(to_free_uid_list) makeMessageListAvailable(to_free_uid_list)
except: except:
LOG('SQLQueue', PANIC, 'Failed to free messages: %r' % (to_free_uid_list, ), error=sys.exc_info()) LOG('SQLQueue', ERROR, 'Failed to free messages: %r' % (to_free_uid_list, ), error=sys.exc_info())
else: else:
if len(to_free_uid_list): if len(to_free_uid_list):
LOG('SQLQueue', TRACE, 'Freed messages %r' % (to_free_uid_list, )) LOG('SQLQueue', TRACE, 'Freed messages %r' % (to_free_uid_list, ))
...@@ -216,14 +216,14 @@ class SQLQueue(RAMQueue, SQLBase): ...@@ -216,14 +216,14 @@ class SQLQueue(RAMQueue, SQLBase):
try: try:
makeMessageListAvailable(delay_uid_list) makeMessageListAvailable(delay_uid_list)
except: except:
LOG('SQLQueue', PANIC, 'Failed to unreserve %r' % (uid, ), error=sys.exc_info()) LOG('SQLQueue', ERROR, 'Failed to unreserve %r' % (uid, ), error=sys.exc_info())
else: else:
LOG('SQLQueue', TRACE, 'Freed message %r' % (uid, )) LOG('SQLQueue', TRACE, 'Freed message %r' % (uid, ))
if len(deletable_uid_list): if len(deletable_uid_list):
try: try:
activity_tool.SQLQueue_delMessage(uid=deletable_uid_list) activity_tool.SQLQueue_delMessage(uid=deletable_uid_list)
except: except:
LOG('SQLQueue', PANIC, 'Failed to delete messages %r' % (deletable_uid_list, ), error=sys.exc_info()) LOG('SQLQueue', ERROR, 'Failed to delete messages %r' % (deletable_uid_list, ), error=sys.exc_info())
else: else:
LOG('SQLQueue', TRACE, 'Deleted messages %r' % (deletable_uid_list, )) LOG('SQLQueue', TRACE, 'Deleted messages %r' % (deletable_uid_list, ))
if len(delay_uid_list): if len(delay_uid_list):
...@@ -231,11 +231,11 @@ class SQLQueue(RAMQueue, SQLBase): ...@@ -231,11 +231,11 @@ class SQLQueue(RAMQueue, SQLBase):
# If this is a conflict error, do not lower the priority but only delay. # If this is a conflict error, do not lower the priority but only delay.
activity_tool.SQLQueue_setPriority(uid=delay_uid_list, delay=VALIDATION_ERROR_DELAY) activity_tool.SQLQueue_setPriority(uid=delay_uid_list, delay=VALIDATION_ERROR_DELAY)
except: except:
LOG('SQLQueue', PANIC, 'Failed to delay %r' % (delay_uid_list, ), error=sys.exc_info()) LOG('SQLQueue', ERROR, 'Failed to delay %r' % (delay_uid_list, ), error=sys.exc_info())
try: try:
makeMessageListAvailable(delay_uid_list) makeMessageListAvailable(delay_uid_list)
except: except:
LOG('SQLQueue', PANIC, 'Failed to unreserve %r' % (delay_uid_list, ), error=sys.exc_info()) LOG('SQLQueue', ERROR, 'Failed to unreserve %r' % (delay_uid_list, ), error=sys.exc_info())
else: else:
LOG('SQLQueue', TRACE, 'Freed messages %r' % (delay_uid_list, )) LOG('SQLQueue', TRACE, 'Freed messages %r' % (delay_uid_list, ))
if len(final_error_uid_list): if len(final_error_uid_list):
...@@ -243,7 +243,7 @@ class SQLQueue(RAMQueue, SQLBase): ...@@ -243,7 +243,7 @@ class SQLQueue(RAMQueue, SQLBase):
activity_tool.SQLQueue_assignMessage(uid=final_error_uid_list, activity_tool.SQLQueue_assignMessage(uid=final_error_uid_list,
processing_node=INVOKE_ERROR_STATE) processing_node=INVOKE_ERROR_STATE)
except: except:
LOG('SQLQueue', PANIC, 'Failed to set message to error state for %r' % (final_error_uid_list, ), error=sys.exc_info()) LOG('SQLQueue', ERROR, 'Failed to set message to error state for %r' % (final_error_uid_list, ), error=sys.exc_info())
try: try:
for m in notify_user_list: for m in notify_user_list:
m.notifyUser(activity_tool) m.notifyUser(activity_tool)
...@@ -293,7 +293,7 @@ class SQLQueue(RAMQueue, SQLBase): ...@@ -293,7 +293,7 @@ class SQLQueue(RAMQueue, SQLBase):
except: except:
# Unfortunately, database adapters may raise an exception against abort. # Unfortunately, database adapters may raise an exception against abort.
LOG('SQLQueue', PANIC, 'abort failed, thus some objects may be modified accidentally') LOG('SQLQueue', PANIC, 'abort failed, thus some objects may be modified accidentally')
return True # Stop processing messages for this tic call for this queue. raise
# 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
# of the transaction fails # of the transaction fails
...@@ -301,7 +301,7 @@ class SQLQueue(RAMQueue, SQLBase): ...@@ -301,7 +301,7 @@ class SQLQueue(RAMQueue, SQLBase):
try: try:
makeMessageListAvailable([value[0]]) makeMessageListAvailable([value[0]])
except: except:
LOG('SQLQueue', PANIC, 'Failed to free message: %r' % (value, ), error=sys.exc_info()) LOG('SQLQueue', ERROR, 'Failed to free message: %r' % (value, ), error=sys.exc_info())
else: else:
LOG('SQLQueue', TRACE, 'Freed message %r' % (value, )) LOG('SQLQueue', TRACE, 'Freed message %r' % (value, ))
if time() > processing_stop_time: if time() > processing_stop_time:
...@@ -314,7 +314,7 @@ class SQLQueue(RAMQueue, SQLBase): ...@@ -314,7 +314,7 @@ class SQLQueue(RAMQueue, SQLBase):
try: try:
makeMessageListAvailable(to_free_uid_list) makeMessageListAvailable(to_free_uid_list)
except: except:
LOG('SQLQueue', PANIC, 'Failed to free remaining messages: %r' % (to_free_uid_list, ), error=sys.exc_info()) LOG('SQLQueue', ERROR, 'Failed to free remaining messages: %r' % (to_free_uid_list, ), error=sys.exc_info())
else: else:
LOG('SQLQueue', TRACE, 'Freed messages %r' % (to_free_uid_list, )) LOG('SQLQueue', TRACE, 'Freed messages %r' % (to_free_uid_list, ))
self.finalizeMessageExecution(activity_tool, processed_message_uid_list) self.finalizeMessageExecution(activity_tool, processed_message_uid_list)
......
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