[Neo-report] r2597 vincent - in /trunk/neo: client/ storage/database/ tests/storage/

nobody at svn.erp5.org nobody at svn.erp5.org
Thu Jan 6 15:09:02 CET 2011


Author: vincent
Date: Thu Jan  6 15:09:02 2011
New Revision: 2597

Log:
After undoing an object, its current serial goes back in time.

This is important for chaining "undo" for a given object in a single
transaction, to allow checking for conflicts.
Also, this means that get_baseTID return value cannot be used to update
cache when undoing, so only update cache when storing a new revision.
Actually, cache was never updated when undoing anyway, as current snapshot
TID was unlikely to exist as a serial for any object, so it would not be
found in cache and update would be a no-op.

Modified:
    trunk/neo/client/app.py
    trunk/neo/storage/database/manager.py
    trunk/neo/tests/storage/testStorageDBTests.py

Modified: trunk/neo/client/app.py
==============================================================================
--- trunk/neo/client/app.py [iso-8859-1] (original)
+++ trunk/neo/client/app.py [iso-8859-1] Thu Jan  6 15:09:02 2011
@@ -102,6 +102,7 @@ class ThreadContext(object):
             'txn': None,
             'data_dict': {},
             'data_list': [],
+            'object_base_serial_dict': {},
             'object_serial_dict': {},
             'object_stored_counter_dict': {},
             'conflict_serial_dict': {},
@@ -727,6 +728,9 @@ class Application(object):
         data_dict[oid] = data
         # Store data on each node
         self.local_var.object_stored_counter_dict[oid] = {}
+        object_base_serial_dict = local_var.object_base_serial_dict
+        if oid not in object_base_serial_dict:
+            object_base_serial_dict[oid] = serial
         self.local_var.object_serial_dict[oid] = serial
         queue = self.local_var.queue
         add_involved_nodes = self.local_var.involved_nodes.add
@@ -760,6 +764,7 @@ class Application(object):
         local_var = self.local_var
         # Check for conflicts
         data_dict = local_var.data_dict
+        object_base_serial_dict = local_var.object_base_serial_dict
         object_serial_dict = local_var.object_serial_dict
         conflict_serial_dict = local_var.conflict_serial_dict.copy()
         local_var.conflict_serial_dict.clear()
@@ -815,6 +820,8 @@ class Application(object):
                         dump(conflict_serial))
                     # Mark this conflict as resolved
                     resolved_serial_set.update(conflict_serial_set)
+                    # Base serial changes too, as we resolved a conflict
+                    object_base_serial_dict[oid] = conflict_serial
                     # Try to store again
                     self._store(oid, conflict_serial, new_data)
                     append(oid)
@@ -983,7 +990,7 @@ class Application(object):
                     assert next_tid is None, (dump(oid), dump(base_tid),
                         dump(next_tid))
                     return (data, tid)
-                get_baseTID = local_var.object_serial_dict.get
+                get_baseTID = local_var.object_base_serial_dict.get
                 for oid, data in local_var.data_dict.iteritems():
                     if data is None:
                         # this is just a remain of

Modified: trunk/neo/storage/database/manager.py
==============================================================================
--- trunk/neo/storage/database/manager.py [iso-8859-1] (original)
+++ trunk/neo/storage/database/manager.py [iso-8859-1] Thu Jan  6 15:09:02 2011
@@ -362,11 +362,8 @@ class DatabaseManager(object):
         undone_tid = u64(undone_tid)
         _getDataTID = self._getDataTID
         if transaction_object is not None:
-            toid, tcompression, tchecksum, tdata, tvalue_serial = \
-                transaction_object
-            current_tid, current_data_tid = self._getDataTIDFromData(oid,
-                (ltid, None, tcompression, tchecksum, tdata,
-                u64(tvalue_serial)))
+            _, _, _, _, tvalue_serial = transaction_object
+            current_tid = current_data_tid = u64(tvalue_serial)
         else:
             current_tid, current_data_tid = _getDataTID(oid, before_tid=ltid)
         if current_tid is None:

Modified: trunk/neo/tests/storage/testStorageDBTests.py
==============================================================================
--- trunk/neo/tests/storage/testStorageDBTests.py [iso-8859-1] (original)
+++ trunk/neo/tests/storage/testStorageDBTests.py [iso-8859-1] Thu Jan  6 15:09:02 2011
@@ -729,14 +729,14 @@ class StorageDBTests(NeoUnitTestBase):
 
         # Undoing oid1 tid1 with tid2 being undone in same transaction,
         # OK: tid1 is latest
-        # Result: current tid is tid2, data_tid is None (undoing object
+        # Result: current tid is tid1, data_tid is None (undoing object
         # creation)
         # Explanation of transaction_object: oid1, no data but a data serial
         # to tid1
         self.assertEqual(
             db.findUndoTID(oid1, tid5, tid4, tid1,
                 (u64(oid1), None, None, None, tid1)),
-            (tid4, None, True))
+            (tid1, None, True))
 
         # Store a new transaction
         db.storeTransaction(




More information about the Neo-report mailing list