[Zodb-checkins] SVN: ZODB/branches/3.8/src/ZODB/ Removed the feature to try to save the index periodically because:

Jim Fulton jim at zope.com
Thu Sep 18 10:55:14 EDT 2008


Log message for revision 91235:
  Removed the feature to try to save the index periodically because:
  
  1. The saving was performed in (tpc)_finish.  It is important that this
     method do as little as possible because it cannot fail!
  
  2. The algorithm for deciding how often to save was broken. For large
     databases, for which saving periodically is desireable, the period
     was set so high that the index was effectively never saved.
  
  It might be nice to save periodically, but doing so is tricky, since
  we really don't want to do it during commit.  Until we figure out how
  to do this right, it is better not to try.
  
  In the mean time, we save on close and on pack, which is proably often
  enough in most cases.
  

Changed:
  U   ZODB/branches/3.8/src/ZODB/FileStorage/FileStorage.py
  U   ZODB/branches/3.8/src/ZODB/tests/testFileStorage.py

-=-
Modified: ZODB/branches/3.8/src/ZODB/FileStorage/FileStorage.py
===================================================================
--- ZODB/branches/3.8/src/ZODB/FileStorage/FileStorage.py	2008-09-18 11:17:58 UTC (rev 91234)
+++ ZODB/branches/3.8/src/ZODB/FileStorage/FileStorage.py	2008-09-18 14:55:12 UTC (rev 91235)
@@ -92,8 +92,6 @@
     # Set True while a pack is in progress; undo is blocked for the duration.
     _pack_is_in_progress = False
 
-    _records_before_save = 10000
-
     def __init__(self, file_name, create=False, read_only=False, stop=None,
                  quota=None):
 
@@ -168,8 +166,6 @@
                 )
             self._save_index()
 
-        self._records_before_save = max(self._records_before_save,
-                                        len(self._index))
         self._ltid = tid
 
         # self._pos should always point just past the last
@@ -815,9 +811,6 @@
         finally:
             self._lock_release()
 
-    # Keep track of the number of records that we've written
-    _records_written = 0
-
     def _finish(self, tid, u, d, e):
         nextpos=self._nextpos
         if nextpos:
@@ -834,15 +827,6 @@
 
             self._index.update(self._tindex)
             self._vindex.update(self._tvindex)
-            
-            # Update the number of records that we've written
-            # +1 for the transaction record
-            self._records_written += len(self._tindex) + 1
-            if self._records_written >= self._records_before_save:
-                self._save_index()
-                self._records_written = 0
-                self._records_before_save = max(self._records_before_save,
-                                                len(self._index))
 
         self._ltid = tid
 

Modified: ZODB/branches/3.8/src/ZODB/tests/testFileStorage.py
===================================================================
--- ZODB/branches/3.8/src/ZODB/tests/testFileStorage.py	2008-09-18 11:17:58 UTC (rev 91234)
+++ ZODB/branches/3.8/src/ZODB/tests/testFileStorage.py	2008-09-18 14:55:12 UTC (rev 91235)
@@ -221,26 +221,6 @@
         self.open()
         self.assertEqual(self._storage._oid, true_max_oid)
 
-    # This would make the unit tests too slow
-    # check_save_after_load_that_worked_hard(self)
-
-    def check_periodic_save_index(self):
-
-        # Check the basic algorithm
-        oldsaved = self._storage._saved
-        self._storage._records_before_save = 10
-        for i in range(4):
-            self._dostore()
-        self.assertEqual(self._storage._saved, oldsaved)
-        self._dostore()
-        self.assertEqual(self._storage._saved, oldsaved+1)
-
-        # Now make sure the parameter changes as we get bigger
-        for i in range(20):
-            self._dostore()
-
-        self.failUnless(self._storage._records_before_save > 20)
-
     def checkStoreBumpsOid(self):
         # If .store() is handed an oid bigger than the storage knows
         # about already, it's crucial that the storage bump its notion



More information about the Zodb-checkins mailing list