1. 11 Nov, 2021 1 commit
  2. 09 Nov, 2021 2 commits
  3. 05 Nov, 2021 2 commits
  4. 29 Oct, 2021 3 commits
    • Kirill Smelkov's avatar
      Merge remote-tracking branch 'origin/master' into y/loadAt.7 · 133ebeb3
      Kirill Smelkov authored
      to resolve trivial conflict on CHANGES.rst
      
      * origin/master: (22 commits)
        Fix TypeError for fsoids (#351)
        Fix deprecation warnings occurring on Python 3.10.
        fix more PY3 incompatibilities in `fsstats`
        fix Python 3 incompatibility for `fsstats`
        add `fsdump/fsstats` test
        fsdump/fsstats improvements
        - add coverage combine step
        - first cut moving tests from Travis CI to GitHub Actions
        - ignore virtualenv artifacts [ci skip]
        tests: Run race-related tests with high frequency of switches between threads
        tests: Add test for load vs external invalidation race
        tests: Add test for open vs invalidation race
        fixup! doc/requirements: Require pygments < 2.6 on py2
        doc/requirements: Require pygments < 2.6 on py2
        fixup! buildout: Fix Sphinx install on Python2
        buildout: Fix Sphinx install on Python2
        Update README.rst
        Security fix documentation dependencies (#342)
        changes: Correct link to UnboundLocalError fsoids.py fix
        fsrefs: Optimize IO  (take 2) (#340)
        ...
      133ebeb3
    • Michael Howitz's avatar
      Lint the code. · 6e5baffd
      Michael Howitz authored
      Add support for Python 3.9 and 3.10.
      6e5baffd
    • Michael Howitz's avatar
      Configuring for pure-python · 1f3a0d62
      Michael Howitz authored
      1f3a0d62
  5. 28 Oct, 2021 1 commit
  6. 27 Oct, 2021 1 commit
  7. 06 Oct, 2021 1 commit
  8. 05 Oct, 2021 3 commits
  9. 03 Oct, 2021 1 commit
  10. 06 Jun, 2021 1 commit
  11. 11 May, 2021 1 commit
  12. 06 May, 2021 2 commits
  13. 04 May, 2021 3 commits
  14. 03 May, 2021 1 commit
  15. 23 Apr, 2021 4 commits
  16. 21 Apr, 2021 3 commits
    • Kirill Smelkov's avatar
    • Kirill Smelkov's avatar
      tests: Add test for load vs external invalidation race · e923c9a8
      Kirill Smelkov authored
      For ZEO this data corruption bug was reported at
      https://github.com/zopefoundation/ZEO/issues/155 and fixed at
      https://github.com/zopefoundation/ZEO/pull/169.
      
      Without that fix the failure shows e.g. as follows when running ZEO test
      suite:
      
          Failure in test check_race_load_vs_external_invalidate (ZEO.tests.testZEO.BlobAdaptedFileStorageTests)
          Traceback (most recent call last):
            File "/usr/lib/python2.7/unittest/case.py", line 329, in run
              testMethod()
            File "/home/kirr/src/wendelin/z/ZODB/src/ZODB/tests/BasicStorage.py", line 621, in check_race_load_vs_external_invalidate
              self.fail([_ for _ in failure if _])
            File "/usr/lib/python2.7/unittest/case.py", line 410, in fail
              raise self.failureException(msg)
          AssertionError: ['T1: obj1.value (7)  !=  obj2.value (8)']
      
      Even if added test is somewhat similar to
      check_race_loadopen_vs_local_invalidate, it is added anew without trying
      to unify code. The reason here is that the probability to catch load vs
      external invalidation race is significantly reduced when there are only
      1 modify and 1 verify workers. The unification with preserving both
      tests semantic would make test for "load vs local invalidate" harder to
      follow. Sometimes a little copying is better than trying to unify too
      much.
      
      For the test to work, test infrastructure is amended with
      ._new_storage_client() method that complements ._storage attribute:
      client-server storages like ZEO, NEO and RelStorage allow several
      storage clients to be connected to single storage server. For
      client-server storages test subclasses should implement
      _new_storage_client to return new storage client that is connected to
      the same storage server self._storage is connected to.
      
      For ZEO ._new_storage_client() is added by https://github.com/zopefoundation/ZEO/pull/170
      
      Other client-server storages can follow to implement ._new_storage_client()
      and this way automatically activate this "load vs external invalidation"
      test when their testsuite is run.
      
      Contrary to test for "load vs local invalidate" N is set to lower value (100),
      because with 8 workers the bug is usually reproduced at not-so-high iteration
      number (5-10-20).
      
      /cc @d-maurer, @jamadden, @jmuchemb
      /reviewed-on https://github.com/zopefoundation/ZODB/pull/345
      e923c9a8
    • Kirill Smelkov's avatar
      tests: Add test for open vs invalidation race · 5b4dd5f7
      Kirill Smelkov authored
      Add test that exercises open vs invalidation race condition that, if
      happen, leads to data corruption. We are seeing such race happening on
      storage level in ZEO (https://github.com/zopefoundation/ZEO/issues/166),
      and previously we've seen it also to happen on Connection level
      (https://github.com/zopefoundation/ZODB/issues/290). By adding this test
      to be exercised wrt all storages we make sure that all storages stay
      free from this race.
      
      And it payed out. Besides catching original problems from
      https://github.com/zopefoundation/ZODB/issues/290 and
      https://github.com/zopefoundation/ZEO/issues/166 , this test also
      discovered a concurrency bug in MVCCMappingStorage:
      
          Failure in test check_race_open_vs_invalidate (ZODB.tests.testMVCCMappingStorage.MVCCMappingStorageTests)
          Traceback (most recent call last):
            File "/usr/lib/python2.7/unittest/case.py", line 329, in run
              testMethod()
            File "/home/kirr/src/wendelin/z/ZODB/src/ZODB/tests/BasicStorage.py", line 492, in check_race_open_vs_invalidate
              self.fail(failure[0])
            File "/usr/lib/python2.7/unittest/case.py", line 410, in fail
              raise self.failureException(msg)
          AssertionError: T1: obj1.value (24)  !=  obj2.value (23)
      
      The problem with MVCCMappingStorage was that instance.poll_invalidations
      was correctly taking main_lock with intention to make sure main data is
      not mutated during analysis, but instance.tpc_finish and
      instance.tpc_abort did _not_ taken main lock, which was leading to
      committed data to be propagating into main storage in non-atomic way.
      
      This bug was also observable if both obj1 and obj2 in the added test
      were always loaded from the storage (added obj2._p_invalidate after
      obj1._p_invalidate).
      
      -> Fix MVCCMappingStorage by correctly locking main MVCCMappingStorage
      instance when processing transaction completion.
      
      /cc @d-maurer, @jamadden, @jmuchemb
      /reviewed-on https://github.com/zopefoundation/ZODB/pull/345
      5b4dd5f7
  17. 20 Apr, 2021 5 commits
  18. 01 Apr, 2021 1 commit
    • Claudius Ellsel's avatar
      Update README.rst · dad77801
      Claudius Ellsel authored
      Fix tiny issue with a remaining colon that was probably not deleted during updates of the README.
      dad77801
  19. 31 Mar, 2021 1 commit
  20. 29 Mar, 2021 2 commits
    • Kirill Smelkov's avatar
      changes: Correct link to UnboundLocalError fsoids.py fix · 2798502e
      Kirill Smelkov authored
      Commit fc4c86e6 (Fix unbound local error when using the fsoids.py script
      (#295)) wanted to refer to "issue 285", but put it as "issue 268" into
      visible text.
      2798502e
    • Kirill Smelkov's avatar
      fsrefs: Optimize IO (take 2) (#340) · 79078049
      Kirill Smelkov authored
      * fsrefs: Optimize IO  (take 2)
      
      Access objects in the order of their position in file instead of in the order
      of their OID. This should give dramatical speedup when data are on HDD.
      
      For example @perrinjerome reports that on a 73Go database it takes
      almost 8h to run fsrefs (where on the same database, fstest takes 15
      minutes) [1,2]. After the patch fsrefs took ~80 minutes to run on the same
      database. In other words this is ~ 6x improvement.
      
      Fsrefs has no tests. I tested it only lightly via generating a bit
      corrupt database with deleted referred object(*), and it gives the same
      output as unmodified fsrefs.
      
          oid 0x0 __main__.Object
          last updated: 1979-01-03 21:00:42.900001, tid=0x285cbacb70a3db3
          refers to invalid objects:
                  oid 0x07 missing: '<unknown>'
                  oid 0x07 object creation was undone: '<unknown>'
      
      This "take 2" version is derived from https://github.com/zopefoundation/ZODB/pull/338
      and only iterates objects in the order of their in-file position without
      building complete references graph in-RAM, because that in-RAM graph would
      consume ~12GB of memory.
      
      Added pos2oid in-RAM index also consumes memory: for the 73GB database in
      question fs._index takes ~700MB, while pos2oid takes ~2GB. In theory it could be less,
      because we need only array of oid sorted by key(oid)=fs._index[oid]. However
      array.array does not support sorting, and if we use plain list to keep just
      []oid, the memory consumption just for that list is ~5GB. Also because
      list.sort(key=...) internally allocates memory for key array (and
      list.sort(cmp=...) was removed from Python3), total memory consumption just to
      produce list of []oid ordered by pos is ~10GB.
      So without delving into C/Cython and/or manually sorting the array in Python (=
      slow), using QQBTree seems to be the best out-of-the-box option for oid-by-pos index.
      
      [1] nexedi/zodbtools!19 (comment 129480)
      [2] nexedi/zodbtools!19 (comment 129551)
      
      (*) test database generated via a bit modified gen_testdata.py from
      zodbtools:
      
      https://lab.nexedi.com/nexedi/zodbtools/blob/v0.0.0.dev8-28-g129afa6/zodbtools/test/gen_testdata.py
      
      +
      
      ```diff
      --- a/zodbtools/test/gen_testdata.py
      +++ b/zodbtools/test/gen_testdata.py
      @@ -229,7 +229,7 @@ def ext(subj): return {}
               # delete an object
               name = random.choice(list(root.keys()))
               obj = root[name]
      -        root[name] = Object("%s%i*" % (name, i))
      +#       root[name] = Object("%s%i*" % (name, i))
               # NOTE user/ext are kept empty on purpose - to also test this case
               commit(u"", u"predelete %s" % unpack64(obj._p_oid), {})
      ```
      
      /cc @tim-one, @jeremyhylton, @jamadden
      /reviewed-by @jamadden, @perrinjerome 
      /reviewed-on https://github.com/zopefoundation/ZODB/pull/340
      79078049
  21. 16 Mar, 2021 1 commit
    • Kirill Smelkov's avatar
      loadAt · 55261f31
      Kirill Smelkov authored
      loadAt is new optional storage interface that is intended to replace loadBefore
      with more clean and uniform semantic. Compared to loadBefore, loadAt:
      
      1) returns data=None and serial of the removal, when loaded object was found to
         be deleted. loadBefore is returning only data=None in such case. This loadAt
         property allows to fix DemoStorage data corruption when whiteouts in overlay
         part were not previously correctly taken into account.
      
         https://github.com/zopefoundation/ZODB/issues/318
      
      2) for regular data records, does not require storages to return next_serial,
         in addition to (data, serial). loadBefore requirement to return both
         serial and next_serial is constraining storages unnecessarily, and,
         while for FileStorage it is free to implement, for other storages it is
         not - for example for NEO and RelStorage, finding out next_serial, after
         looking up oid@at data record, costs one more SQL query:
      
         https://lab.nexedi.com/nexedi/neoppod/blob/fb746e6b/neo/storage/database/mysqldb.py#L484-508
         https://lab.nexedi.com/nexedi/neoppod/blob/fb746e6b/neo/storage/database/mysqldb.py#L477-482
      
         https://github.com/zodb/relstorage/blob/3.1.1-1-ge7628f9/src/relstorage/storage/load.py#L259-L264
         https://github.com/zodb/relstorage/blob/3.1.1-1-ge7628f9/src/relstorage/adapters/mover.py#L177-L199
      
         next_serial is not only about execution overhead - it is semantically
         redundant to be there and can be removed from load return. The reason
         I say that next_serial can be removed is that in ZODB/py the only place,
         that I could find, where next_serial is used on client side is in client
         cache (e.g. in NEO client cache), and that cache can be remade to
         work without using that next_serial at all. In simple words whenever
         after
      
           loadAt(oid, at)  ->  (data, serial)
      
         query, the cache can remember data for oid in [serial, at] range.
      
         Next, when invalidation message from server is received, cache entries,
         that had at == client_head, are extended (at -> new_head) for oids that
         are not present in invalidation message, while for oids that are present
         in invalidation message no such extension is done. This allows to
         maintain cache in correct state, invalidate it when there is a need to
         invalidate, and not to throw away cache entries that should remain live.
         This of course requires ZODB server to include both modified and
         just-created objects into invalidation messages
      
           ( https://github.com/zopefoundation/ZEO/pull/160 ,
             https://github.com/zopefoundation/ZODB/pull/319 ).
      
         Switching to loadAt should thus allow storages like NEO and, maybe,
         RelStorage, to do 2x less SQL queries on every object access.
      
         https://github.com/zopefoundation/ZODB/issues/318#issuecomment-657685745
      
      In other words loadAt unifies return signature to always be
      
         (data, serial)
      
      instead of
      
         POSKeyError				object does not exist at all
         None					object was removed
         (data, serial, next_serial)		regular data record
      
      used by loadBefore.
      
      This patch:
      
      - introduces new interface.
      - introduces ZODB.utils.loadAt helper, that uses either storage.loadAt,
        or, if the storage does not implement loadAt interface, tries to mimic
        loadAt semantic via storage.loadBefore to possible extent + emits
        corresponding warning.
      - converts MVCCAdapter to use loadAt instead of loadBefore.
      - changes DemoStorage to use loadAt, and this way fixes above-mentioned
        data corruption issue; adds corresponding test; converts
        DemoStorage.loadBefore to be a wrapper around DemoStorage.loadAt.
      - adds loadAt implementation to FileStorage and MappingStorage.
      - adapts other tests/code correspondingly.
      
      /cc @jimfulton, @jamadden, @vpelletier, @jmuchemb, @arnaud-fontaine, @gidzit, @klawlf82, @hannosch
      55261f31