[Erp5-report] r8244 - in /erp5/trunk/products/CMFActivity/Activity: SQLDict.py SQLQueue.py

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Jun 30 13:48:21 CEST 2006


Author: yo
Date: Fri Jun 30 13:48:18 2006
New Revision: 8244

URL: http://svn.erp5.org?rev=8244&view=rev
Log:
Rescue the situation where a conflict error happens after executing an active object.

Modified:
    erp5/trunk/products/CMFActivity/Activity/SQLDict.py
    erp5/trunk/products/CMFActivity/Activity/SQLQueue.py

Modified: erp5/trunk/products/CMFActivity/Activity/SQLDict.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/Activity/SQLDict.py?rev=8244&r1=8243&r2=8244&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/Activity/SQLDict.py (original)
+++ erp5/trunk/products/CMFActivity/Activity/SQLDict.py Fri Jun 30 13:48:18 2006
@@ -291,44 +291,47 @@
 
           # Release locks before starting a potentially long calculation
           get_transaction().commit()
+
+        # Try to invoke
+        if group_method_id is not None:
+          LOG('SQLDict', TRACE,
+              'invoking a group method %s with %d objects '\
+              ' (%d objects in expanded form)' % (
+              group_method_id, len(message_list), count))
+          activity_tool.invokeGroup(group_method_id, message_list)
+        else:
+          activity_tool.invoke(message_list[0])
+
+        # Check if messages are executed successfully.
+        # When some of them are executed successfully, it may not be acceptable to
+        # abort the transaction, because these remain pending, only due to other
+        # invalid messages. This means that a group method should not be used if
+        # it has a side effect. For now, only indexing uses a group method, and this
+        # has no side effect.
+        for m in message_list:
+          if m.is_executed:
+            get_transaction().commit()
+            break
+        else:
+          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:
-          activity_tool.SQLDict_setPriority(uid = uid_list, delay = VALIDATION_ERROR_DELAY,
-                                            retry = 1)
+          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:
-          activity_tool.SQLDict_assignMessage(uid = uid_list, processing_node = INVOKE_ERROR_STATE)
+          if len(uid_list):
+            activity_tool.SQLDict_assignMessage(uid = uid_list, processing_node = INVOKE_ERROR_STATE)
         get_transaction().commit()
         return 0
-
-      # Try to invoke
-      if group_method_id is not None:
-        LOG('SQLDict', TRACE,
-            'invoking a group method %s with %d objects '\
-            ' (%d objects in expanded form)' % (
-            group_method_id, len(message_list), count))
-        activity_tool.invokeGroup(group_method_id, message_list)
-      else:
-        activity_tool.invoke(message_list[0])
-
-      # Check if messages are executed successfully.
-      # When some of them are executed successfully, it may not be acceptable to
-      # abort the transaction, because these remain pending, only due to other
-      # invalid messages. This means that a group method should not be used if
-      # it has a side effect. For now, only indexing uses a group method, and this
-      # has no side effect.
-      for m in message_list:
-        if m.is_executed:
-          break
-      else:
-        get_transaction().abort()
 
       for i in xrange(len(message_list)):
         m = message_list[i]

Modified: erp5/trunk/products/CMFActivity/Activity/SQLQueue.py
URL: http://svn.erp5.org/erp5/trunk/products/CMFActivity/Activity/SQLQueue.py?rev=8244&r1=8243&r2=8244&view=diff
==============================================================================
--- erp5/trunk/products/CMFActivity/Activity/SQLQueue.py (original)
+++ erp5/trunk/products/CMFActivity/Activity/SQLQueue.py Fri Jun 30 13:48:18 2006
@@ -119,6 +119,11 @@
                                                 priority = line.priority)
             get_transaction().commit() # Release locks before starting a potentially long calculation
           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:
         # If a conflict occurs, catch it and delay the operation.
         get_transaction().abort()
@@ -134,11 +139,8 @@
         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
+      if m.is_executed:
         activity_tool.SQLQueue_delMessage(uid=line.uid)  # Delete it
-        get_transaction().commit()                                        # If successful, commit
       else:
         get_transaction().abort()                                         # If not, abort transaction and start a new one
         if line.priority > MAX_PRIORITY:
@@ -146,12 +148,11 @@
           activity_tool.SQLQueue_assignMessage(uid=line.uid, 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
           activity_tool.SQLQueue_setPriority(uid=line.uid, date = next_processing_date,
                                               priority = line.priority + 1)
-          get_transaction().commit() # Release locks before starting a potentially long calculation
+      get_transaction().commit()
       return 0
     get_transaction().commit() # Release locks before starting a potentially long calculation
     return 1




More information about the Erp5-report mailing list