Commit 1c2e2768 authored by Jim Fulton's avatar Jim Fulton

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.
parent 6d750a4c
......@@ -92,8 +92,6 @@ class FileStorage(BaseStorage.BaseStorage,
# 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 @@ class FileStorage(BaseStorage.BaseStorage,
)
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 @@ class FileStorage(BaseStorage.BaseStorage,
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:
......@@ -835,15 +828,6 @@ class FileStorage(BaseStorage.BaseStorage,
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
def _abort(self):
......
......@@ -221,26 +221,6 @@ class FileStorageTests(
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
......
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