Commit 7c104297 authored by Jim Fulton's avatar Jim Fulton Committed by Kirill Smelkov

[ZEO4] Fixed: were sending out of date size info on commit

This is ZEO4 backport of commit 8d7b1ceb ("Fixed: were sending out of
date size info on commit", 2016-06-21) needed to get tests passing after
previous patch.

It is needed because BasicStorage.checkLen was previously passing just
by luck because transactions in that test only create objects, and the
test is tolerating storages that do not update their len at all.

Before previous patch, if ZEOStorage.invalidated was == [], neither
invalidateTransaction, _nor_ info messages were sent (which is incorrect
since when object is created len has to be adjusted too). After previous
patch we always delve into sending invalidateTransaction and info, but,
since ZEOStorage._invalidate is called from under tpc_finish, storage
sizes are not yet updated and get_info retrieves len from previous - not
for committed - transaction, leading to errors like:

    Failure in test checkLen (ZEO.tests.testZEO.DemoStorageTests)
    Traceback (most recent call last):
      File "/usr/lib/python2.7/unittest/case.py", line 329, in run
        testMethod()
      File "/home/kirr/src/wendelin/z/ZODB4/src/ZODB/tests/BasicStorage.py", line 175, in checkLen
        self.assertIn(len(self._storage), [0,2])
      File "/usr/lib/python2.7/unittest/case.py", line 804, in assertIn
        self.fail(self._formatMessage(msg, standardMsg))
      File "/usr/lib/python2.7/unittest/case.py", line 410, in fail
        raise self.failureException(msg)
    AssertionError: 1 not found in [0, 2]

Original description follows:

---- 8< ---- (original description)

Because we were computing the size info in the commit callback, which
might be before before the inderlying data were committed.  This caused the computation to be wrong in some cases.

Instead we get and send the size information after committing.
parent f2fae122
......@@ -406,6 +406,7 @@ class ZEOStorage:
self.stats.commits += 1
self.storage.tpc_finish(self.transaction, self._invalidate)
self.client.info(self.get_size_info())
# Note that the tid is still current because we still hold the
# commit lock. We'll relinquish it in _clear_transaction.
tid = self.storage.lastTransaction()
......@@ -414,8 +415,7 @@ class ZEOStorage:
def _invalidate(self, tid):
if self.invalidated:
self.server.invalidate(self, self.storage_id, tid,
self.invalidated, self.get_size_info())
self.server.invalidate(self, self.storage_id, tid, self.invalidated)
def tpc_abort(self, tid):
if not self._check_tid(tid):
......
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