1. 09 Jul, 2019 1 commit
    • Kirill Smelkov's avatar
      bigfile: Unstub ram_close · d91ef8fb
      Kirill Smelkov authored
      It should release resources associated with RAM. Make it call .ram_close
      from RAM ops. Add corresponding .ram_close to ram_shmfs. This fixes
      SHMFS_RAM->prefix leak.
      d91ef8fb
  2. 08 Jul, 2019 6 commits
    • Kirill Smelkov's avatar
      bigfile/test/test_ram: Don't forget to free allocated Page structs · e8eca379
      Kirill Smelkov authored
      test_ram is low-level test that tests RAM pages allocation/mmapping.
      As allocated pages are not integrated with virtmem (not added to any
      file mapping and RAM->lru_list) the Page structs have to be explicitly
      freed. Fixes e.g.
      
      	Direct leak of 80 byte(s) in 1 object(s) allocated from:
      	    #0 0x7ff29af46518 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
      	    #1 0x56131dc22289 in zalloc include/wendelin/utils.h:67
      	    #2 0x56131dc225d6 in ramh_alloc_page bigfile/tests/../ram.c:41
      	    #3 0x56131dc2a19e in main bigfile/tests/test_ram.c:130
      	    #4 0x7ff29ac9f09a in __libc_start_main ../csu/libc-start.c:308
      e8eca379
    • Kirill Smelkov's avatar
      bigfile: RAM must be explicitly free'ed after close · f688a31d
      Kirill Smelkov authored
      Else on-heap allocated RAM object is leaked. Fixes e.g. the following
      error on ASAN:
      
      	Direct leak of 56 byte(s) in 1 object(s) allocated from:
      	    #0 0x7fc9ef390518 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xe9518)
      	    #1 0x555ca792f309 in zalloc include/wendelin/utils.h:67
      	    #2 0x555ca7935f9a in ram_limited_new bigfile/tests/../../t/t_utils.c:35
      	    #3 0x555ca793a0ba in test_file_access_synthetic bigfile/tests/test_virtmem.c:292
      	    #4 0x555ca7967bc4 in main bigfile/tests/test_virtmem.c:1121
      	    #5 0x7fc9ef0e909a in __libc_start_main ../csu/libc-start.c:308
      f688a31d
    • Kirill Smelkov's avatar
      bigfile/test: Don't forget to close opened RAM · f1931264
      Kirill Smelkov authored
      Only one place that was using ram_new was missing to call ram_close in
      the end.
      f1931264
    • Kirill Smelkov's avatar
      tests: TSAN no longer fails on test_virtmem · e87d6801
      Kirill Smelkov authored
      For failing case compiler-rt support was added in 2014 - 5 years ago
      (see links in removed code).
      e87d6801
    • Kirill Smelkov's avatar
    • Kirill Smelkov's avatar
      3rdparty/ccan: Update · b3636a08
      Kirill Smelkov authored
      Just an update to latest CCAN - there is actually no changes to modules
      that we use (tap, array_size, minmax, bitmap, build_assert)
      b3636a08
  3. 18 Jun, 2019 4 commits
    • Kirill Smelkov's avatar
      wendelin.core v0.13 · b26ba558
      Kirill Smelkov authored
      b26ba558
    • Kirill Smelkov's avatar
      tox -= Python3.5 · 76e8dc34
      Kirill Smelkov authored
      Let's keep on test coverage for last 2 stable Python releases.
      76e8dc34
    • Kirill Smelkov's avatar
      Fix build for Python 3.7 · bca5f79e
      Kirill Smelkov authored
      Starting from Python 3.7 the place to keep exception state was changed:
      https://github.com/python/cpython/commit/ae3087c638
      
      NOTE ZEO4 does not wok with Python3.7, because ZEO4 uses "async" for a
      variable and that breaks because starting from Python3.7 "async" became
      a keyword.
      
      After the fix wendelin.core tests pass under all python2.7, python3.6
      and python3.7.
      bca5f79e
    • Kirill Smelkov's avatar
      tox: ZODB5.test.util needs mock · 6b5384ae
      Kirill Smelkov authored
      Dependency added here:
      
      	https://github.com/zopefoundation/ZODB/commit/e0bc8bd567
      
      If we don't provide mock, e.g. py27-ZODB5-*-zeo-* breaks:
      
      	    def setup_module():
      	        global testdb
      	>       testdb = getTestDB()
      
      	bigarray/tests/test_arrayzodb.py:38:
      	_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
      	.tox/py27-ZODB5-zblk1-zeo-numpy115/lib/python2.7/site-packages/wendelin/lib/testing.py:342: in getTestDB
      	    testdb = testdb_factory(testdb_uri)
      	.tox/py27-ZODB5-zblk1-zeo-numpy115/lib/python2.7/site-packages/wendelin/lib/testing.py:245: in __init__
      	    from ZEO.tests import forker
      	.tox/py27-ZODB5-zblk1-zeo-numpy115/lib/python2.7/site-packages/ZEO/tests/forker.py:29: in <module>
      	    import ZODB.tests.util
      	_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
      
      	    """
      	    from ZODB.MappingStorage import DB
      
      	    import atexit
      	    import os
      	    import persistent
      	    import re
      	    import tempfile
      	    import time
      	    import transaction
      	    import unittest
      	    import warnings
      	    import ZODB.utils
      	    from ZODB.Connection import TransactionMetaData
      	    import zope.testing.setupstack
      	    from zope.testing import renormalizing
      
      	    try:
      	        from unittest import mock
      	    except ImportError:
      	>       import mock
      	E       ImportError: No module named mock
      
      	.tox/py27-ZODB5-zblk1-zeo-numpy115/lib/python2.7/site-packages/ZODB/tests/util.py:35: ImportError
      6b5384ae
  4. 23 May, 2019 2 commits
    • Kirill Smelkov's avatar
      tox: v↑ NumPy to 2 latest releases · 7fd83b61
      Kirill Smelkov authored
      7fd83b61
    • Kirill Smelkov's avatar
      bigfile/zodb: Resync _ZBigFileH to Connection.transaction_manager on every connection reopen · d9d6adec
      Kirill Smelkov authored
      This continues c7c01ce4 (bigfile/zodb: ZODB.Connection can migrate
      between threads on close/open and we have to care): Until now we were
      retrieving zconn.transaction_manager on _ZBigFileH init, and further using
      that transaction manager for every connection reopen. However that is
      not correct because on every reopen connection can be given new
      transaction manager.
      
      We were not practically hitting the bug because until recently ZODB was,
      by default, using the same ThreadTransactionManager manager instance as
      Connection.transaction_manager for all connections, and not doing all
      steps needed to keep _ZBigFileH.transaction_manager in sync to
      Connection was forgiven - a particular transaction manager that was used
      was TransactionManager instance implicitly associated with current
      thread by global threading.Local transaction.manager . However starting
      from ZODB 5.5.0 Connection code was changed to remember as
      .transaction_manager the particular TransactionManager instance without
      any threading.Local games:
      
          https://github.com/zopefoundation/ZODB/commit/b6ac40f153
          https://github.com/zopefoundation/ZODB/issues/208
          https://github.com/zopefoundation/ZODB/pull/226
      
      Given that we were not syncing properly that broke wendelin.core tests, for
      example:
      
          bigfile/tests/test_filezodb.py::test_bigfile_filezodb_vs_conn_migration Exception in thread Thread-1:
          Traceback (most recent call last):
            File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
              self.run()
            File "/usr/lib/python2.7/threading.py", line 754, in run
              self.__target(*self.__args, **self.__kwargs)
            File "/home/kirr/src/wendelin/wendelin.core/bigfile/tests/test_filezodb.py", line 401, in T11
              transaction.commit()    # should be nothing
            File "/home/kirr/src/wendelin/venv/z-dev/local/lib/python2.7/site-packages/transaction/_manager.py", line 252, in commit
              return self.manager.commit()
            File "/home/kirr/src/wendelin/venv/z-dev/local/lib/python2.7/site-packages/transaction/_manager.py", line 131, in commit
              return self.get().commit()
            File "/home/kirr/src/wendelin/venv/z-dev/local/lib/python2.7/site-packages/transaction/_transaction.py", line 298, in commit
              self._synchronizers.map(lambda s: s.beforeCompletion(self))
            File "/home/kirr/src/wendelin/venv/z-dev/local/lib/python2.7/site-packages/transaction/weakset.py", line 61, in map
              f(elt)
            File "/home/kirr/src/wendelin/venv/z-dev/local/lib/python2.7/site-packages/transaction/_transaction.py", line 298, in <lambda>
              self._synchronizers.map(lambda s: s.beforeCompletion(self))
            File "/home/kirr/src/wendelin/wendelin.core/bigfile/file_zodb.py", line 671, in beforeCompletion
              assert txn is zconn.transaction_manager.get()
          AssertionError
      
      What is happening here is that one thread used the connection and
      ZBigFile/_ZBigFileH associated with it, then the connection was closed
      and released to DB pool. Then the connection was reopened but by another
      thread and thus with different TransactionManager instance and oops -
      _ZBigFileH.transaction_manager is different because it is
      TransactionManager instance that was used by the first thread.
      
      Fix it by resyncing _ZBigFileH.transaction_manager on every
      connection reopen. No new test as existing tests already cover the
      problem when run with ZODB >= 5.5.0 .
      d9d6adec
  5. 03 May, 2019 1 commit
    • Kirill Smelkov's avatar
      t/qemu-runlinux: Issue terminal init before running program · 89fb8992
      Kirill Smelkov authored
      This continues 6ab95220 (t/qemu-runlinux: Issue terminal resize before
      running program) and fully initializes terminal before spawning user
      application.
      
      This has practical effect to restore line wrapping for xterm, as kernel,
      initially assuming it has "linux" type terminal, somehow messes xterm
      settings: before the patch lines that were wider than terminal width were
      not wrapped and characters in the last position were printed over each
      other. After the patch printed lines are automatically wrapped and test
      output is not lost.
      
      Tput hint found here:
      
      	https://unix.stackexchange.com/questions/105958
      89fb8992
  6. 17 Mar, 2019 1 commit
    • Kirill Smelkov's avatar
      t/qemu-runlinux: Kernel verbosity control via -v · 208aca62
      Kirill Smelkov authored
      	0: ERROR+ on boot/run
      	1: INFO+  on      run
      	2: INFO+  on boot/run
      	3: DEBUG+ on boot/run
      
      It is convenient not to see large kernel boot log on every test run. "1"
      (single -v) is also convenient: one can skip the boot log but still see
      details of what is going on when test workload is run. -vv and -vvv are
      there to see full picture.
      208aca62
  7. 27 Feb, 2019 3 commits
  8. 13 Feb, 2019 1 commit
    • Kirill Smelkov's avatar
      t/qemu-runlinux: Update · fe541453
      Kirill Smelkov authored
      Continuing 76d8f76d (Script to run compiled linux kernel with root fs
      mounted from host) update the script to run/debug linux inside QEMU:
      
      - teach it to run specified program + args, instead of hardcoded /bin/sh;
      - before tailing to user program, builtin init mounts /proc, /sys, ...
        inside - previously it was /proc, /sys from host seen on those
        mountpoints and it was very misleading - e.g. ps was showing processes
        from host, not inside, etc.
      - builtin init also cares to run specified program with the same current
        directory that was current on host, and environments such as $HOME,
        $PATH, $TERM, ... are also propagated.
      - allow to optionally run QEMU with graphics, instead of stdout only;
      - increase available RAM from 128M to 512M (with 128M running py.test
        inside is failing with fork: not enough memory).
      
      This updated version was useful to debug WCFS(*) & FUSE issues by running
      
      	kirr@deco:~/src/wendelin/wendelin.core/wcfs$ ../t/qemu-runlinux ~/src/linux/linux/arch/x86_64/boot/bzImage py.test -vsx -k test_wcfs
      
      See https://marc.info/?l=linux-fsdevel&m=155000277921155&w=2 for details.
      
      (*) WCFS is still being draft and worked on t branch.
      fe541453
  9. 11 Jan, 2019 1 commit
    • Kirill Smelkov's avatar
      bigfile/py: Properly untrack PyVMA from GC before dealloc · d97641d2
      Kirill Smelkov authored
      On a testing instance we started to see segfaults in pyvma_dealloc()
      with inside calls to vma_unmap but with NULL pyvma->fileh. That was
      strange, becuse before calling vma_unmap(), the code explicitly checks
      whether pyvma->fileh is !NULL.
      
      That was, as it turned out, due to pyvma_dealloc being called twice at the
      same time from two python threads. Here is how that was possible:
      
      T1 decrefs pyvma and finds its reference count drops to zero. It calls
      pyvma_dealloc. From there vma_unmap() is called, which calls virt_lock()
      and that releases GIL first. Another thread T2 was waiting for GIL, it
      acquires it, does some work at python level and somehow triggers GC.
      Since PyVMA supports cyclic GC, it was on GC list and thus GC calls
      dealloc for the same vma again. Here is how it looks in the backtraces:
      
      T1:
      
      	#0  0x00007f6aefc57827 in futex_abstimed_wait_cancelable (private=0, abstime=0x0, expected=0, futex_word=0x1e011d0) at ../sysdeps/unix/sysv/linux/futex-internal.h:205
      	#1  do_futex_wait (sem=sem@entry=0x1e011d0, abstime=0x0) at sem_waitcommon.c:111
      	#2  0x00007f6aefc578d4 in __new_sem_wait_slow (sem=0x1e011d0, abstime=0x0) at sem_waitcommon.c:181
      	#3  0x00007f6aefc5797a in __new_sem_wait (sem=<optimized out>) at sem_wait.c:29
      	#4  0x00000000004ffbc4 in PyThread_acquire_lock ()
      	#5  0x00000000004dbe8a in PyEval_RestoreThread ()
      	#6  0x00007f6ac6d3b8fc in py_gil_retake_if_waslocked (arg=0x4f18f00) at bigfile/_bigfile.c:1048
      	#7  0x00007f6ac6d3dcfc in virt_gil_retake_if_waslocked (gilstate=0x4f18f00) at bigfile/virtmem.c:78
      	#8  0x00007f6ac6d3dd30 in virt_lock () at bigfile/virtmem.c:92
      	#9  0x00007f6ac6d3e724 in vma_unmap (vma=0x7f6a7e0c4100) at bigfile/virtmem.c:271
      	#10 0x00007f6ac6d3a0bc in pyvma_dealloc (pyvma0=0x7f6a7e0c40e0) at bigfile/_bigfile.c:284
      	...
      	#13 0x00000000004d76b0 in PyEval_EvalFrameEx ()
      
      T2:
      
      	#5  0x00007f6ac6d3a081 in pyvma_dealloc (pyvma0=0x7f6a7e0c40e0) at bigfile/_bigfile.c:276
      	#6  0x0000000000500450 in ?? ()
      	#7  0x00000000004ffd82 in _PyObject_GC_New ()
      	#8  0x0000000000485392 in PyList_New ()
      	#9  0x00000000004d3bff in PyEval_EvalFrameEx ()
      
      T2 does the work of vma_unmap and clears C-level vma. Then, when T1 wakes up and
      returns to vma_unmap, it sees vma->file and all other fields cleared -> oops
      segfault.
      
      Fix it by removing pyvma from GC list before going to do actual destruction.
      This way if a concurrent GC triggers, it won't see the vma object on its list,
      and thus won't have a chance to invoke its destructor the second time.
      
      The bug was introduced in 450ad804 (bigarray: ArrayRef support for BigArray)
      when PyVMA was changed to be cyclic-GC aware. However at that time, even Python
      documentation itself was not saying PyObject_GC_UnTrack is needed, as it was
      added only in 2.7.15 after finding that many types in CPython itself are
      vulnerable to similar segfaults:
      
      https://github.com/python/cpython/commit/4cde4bdcc86
      https://bugs.python.org/issue31095
      
      It is pity, that CPython took the approach to force all type authors to
      care to invoke PyObject_GC_UnTrack explicitly, instead of doing that
      automatically in Python runtime before calling tp_dealloc.
      
      /cc @Tyagov, @klaus
      /reviewed-on !11
      d97641d2
  10. 29 Oct, 2018 2 commits
    • Kirill Smelkov's avatar
      lib.xnumpy.structured: New utility to create structured view of an array · 32ca80e2
      Kirill Smelkov authored
      Structured creates view of the array interpreting its minor axis as fully covered by a dtype.
      
      It is similar to arr.view(dtype) + corresponding reshape, but does
      not have limitations of ndarray.view(). For example:
      
        In [1]: a = np.arange(3*3, dtype=np.int32).reshape((3,3))
      
        In [2]: a
        Out[2]:
        array([[0, 1, 2],
               [3, 4, 5],
               [6, 7, 8]], dtype=int32)
      
        In [3]: b = a[:2,:2]
      
        In [4]: b
        Out[4]:
        array([[0, 1],
               [3, 4]], dtype=int32)
      
        In [5]: dtxy = np.dtype([('x', np.int32), ('y', np.int32)])
      
        In [6]: dtxy
        Out[6]: dtype([('x', '<i4'), ('y', '<i4')])
      
        In [7]: b.view(dtxy)
        ---------------------------------------------------------------------------
        ValueError                                Traceback (most recent call last)
        <ipython-input-66-af98529aa150> in <module>()
        ----> 1 b.view(dtxy)
      
        ValueError: To change to a dtype of a different size, the array must be C-contiguous
      
        In [8]: structured(b, dtxy)
        Out[8]: array([(0, 1), (3, 4)], dtype=[('x', '<i4'), ('y', '<i4')])
      
      Structured always creates view and never copies data.
      
      Here is original context where separately playing with .shape and .dtype
      was not enough, since it was creating array copy and OOM'ing the machine:
      
      klaus/wendelin@cbe4938b
      32ca80e2
    • Kirill Smelkov's avatar
      bigarray: Factor-out our custom numpy.lib.stride_tricks.as_strided-alike into lib/xnumpy.py · 6a5dfefa
      Kirill Smelkov authored
      We are going to use this code in another place, so move this out to
      dommon place as a preparatory step first.
      
      On a related note: Since ArrayRef is generic and quite independent from
      BigArray (it only supports it, but equally it supports just other - e.g.
      plain arrays), the proper place for it might be also to be lib/xnumpy.py .
      We might get to this topic a bit later.
      6a5dfefa
  11. 12 Oct, 2018 2 commits
    • Kirill Smelkov's avatar
      RAMArray · 99b91c84
      Kirill Smelkov authored
      RAMArray is compatible to ZBigArray in API and semantic, but stores its
      data in RAM only. It is useful in situations where ZBigArray compatible
      data type is needed, but the amount of data is small and the data itself
      is needed only temporarily - e.g. in a simulation.
      
      Please see details in individual patches.
      
      Original merge request by @klaus (nexedi/wendelin.core!8).
      
      /cc @Tyagov
      /reviewed-on nexedi/wendelin.core!9
      99b91c84
    • Kirill Smelkov's avatar
      bigarray: RAMArray · fc9b69d8
      Kirill Smelkov authored
      RAMArray is compatible to ZBigArray in API and semantic, but stores its
      data in RAM only. It is useful in situations where ZBigArray compatible
      data type is needed, but the amount of data is small and the data itself
      is needed only temporarily - e.g. in a simulation.
      
      Implementation is based on mmapping temporary files from /dev/shm/... and
      passing them as file handles, similarly to how ZBigArray works, to BigArray.
      We don't use just numpy.ndarray because of append - for ZBigArray append
      works in O(1), but more importantly it does not copy data. This way
      mmapings previously created for ZBigArray views, continue to correctly
      alias array data. If we would be using ndarray directly, since
      ndarray.resize copies data, that property would not be preserved.
      
      Original patch by Klaus Wölfel <klaus@nexedi.com>
      (!8)
      fc9b69d8
  12. 11 Oct, 2018 1 commit
    • Kirill Smelkov's avatar
      bigarray/tests: Factor out a way to spcify on which BigFile/BigFileH an array... · 7365979b
      Kirill Smelkov authored
      bigarray/tests: Factor out a way to spcify on which BigFile/BigFileH an array is tested into fixture parameter
      
      Currently we have only one BigFile and its BigFileH handle. However in
      the next patch, for RAMArray, we'll be adding handles for opened RAM
      files, and it would be good to test whole BigArray functionality on
      data served by those handles too.
      
      Prepare for this and first factor out into testbig fixture the way to
      open such handles.
      7365979b
  13. 04 Jul, 2018 1 commit
    • Kirill Smelkov's avatar
      py.bench: Move it to -> pygolang · 318efce0
      Kirill Smelkov authored
      So that it can be available to everyone and in particular B & friends to
      be available from introduced importable golang.testing package. The move
      itself:
      
      	kirr/pygolang@9bf03d9c
      
      While moving the code was restructured / improved a bit and py.bench
      interface reworked to mimic `go test -bench` in defaults.
      318efce0
  14. 26 Jun, 2018 2 commits
  15. 17 Apr, 2018 3 commits
    • Kirill Smelkov's avatar
    • Kirill Smelkov's avatar
      tests: Explicitly close ZODB connections for places with warnings found by previous patch · 01b995a4
      Kirill Smelkov authored
      bigfile/tests/test_filezodb.py ........W: testdb: teardown: <Connection at 7f8fe2b43b90> left not closed by test code; opened by:
        ...
        File "/home/kirr/src/wendelin/wendelin.core/bigfile/tests/test_filezodb.py", line 754, in test_bigfile_zblk1_zdata_reuse
          _test_bigfile_zblk1_zdata_reuse()
        File "/home/kirr/src/wendelin/wendelin.core/bigfile/tests/test_filezodb.py", line 759, in _test_bigfile_zblk1_zdata_reuse
          root = dbopen()
        File "/home/kirr/src/wendelin/wendelin.core/bigfile/tests/test_filezodb.py", line 47, in dbopen
          return testdb.dbopen()
        File "/home/kirr/src/wendelin/wendelin.core/lib/testing.py", line 188, in dbopen
          self.connv.append( (weakref.ref(conn), ''.join(traceback.format_stack())) )
      
      lib/tests/test_zodb.py .W: testdb: teardown: <Connection at 7f8fe26f13d0> left not closed by test code; opened by:
        ...
        File "/home/kirr/src/wendelin/wendelin.core/lib/tests/test_zodb.py", line 49, in test_deactivate_btree
          root = dbopen()
        File "/home/kirr/src/wendelin/wendelin.core/lib/tests/test_zodb.py", line 30, in dbopen
          return testdb.dbopen()
        File "/home/kirr/src/wendelin/wendelin.core/lib/testing.py", line 188, in dbopen
          self.connv.append( (weakref.ref(conn), ''.join(traceback.format_stack())) )
      01b995a4
    • Kirill Smelkov's avatar
      tests: Force-close ZODB connections in teardown, that testing code forgot to explicitly close · 5a5ed2c7
      Kirill Smelkov authored
      If a test forgets to explicitly close ZODB connection it was using, this
      connection stays alive in transaction synchronizers (it is a weakset),
      and continues to be used on e.g. transaction.commit() when all
      synchronizers are invoked. This could lead to crashes like below when
      underlying ZODB storage was closed by test module teardown and testing
      moved on to another test module:
      
          $ WENDELIN_CORE_TEST_DB="<neo>" py.test  bigfile/tests/test_filezodb.py::test_bigfile_zblk1_zdata_reuse lib/tests/test_zodb.py
          ======= test session starts ========
          platform linux2 -- Python 2.7.14+, pytest-3.5.0, py-1.5.3, pluggy-0.6.0
          rootdir: /home/kirr/src/wendelin/wendelin.core, inifile:
          collected 2 items
      
          bigfile/tests/test_filezodb.py .                                     [ 50%]
          lib/tests/test_zodb.py F                                             [100%]
      
          ______ test_deactivate_btree _______
      
              def test_deactivate_btree():
                  root = dbopen()
                  # init btree with many leaf nodes
                  leafv = []
                  root['btree'] = B = IOBTree()
                  for i in range(10000):
                      B[i] = xi = XInt(i)
                      leafv.append(xi)
          >       transaction.commit()
      
          lib/tests/test_zodb.py:56:
          _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
          ../venv/z5/local/lib/python2.7/site-packages/transaction/_manager.py:131: in commit
              return self.get().commit()
          ../venv/z5/local/lib/python2.7/site-packages/transaction/_transaction.py:316: in commit
              self._synchronizers.map(lambda s: s.afterCompletion(self))
          ../venv/z5/local/lib/python2.7/site-packages/transaction/weakset.py:62: in map
              f(elt)
          ../venv/z5/local/lib/python2.7/site-packages/transaction/_transaction.py:316: in <lambda>
              self._synchronizers.map(lambda s: s.afterCompletion(self))
          ../venv/z5/local/lib/python2.7/site-packages/ZODB/Connection.py:757: in afterCompletion
              self.newTransaction(transaction, False)
          ../venv/z5/local/lib/python2.7/site-packages/ZODB/Connection.py:737: in newTransaction
              invalidated = self._storage.poll_invalidations()
          ../venv/z5/local/lib/python2.7/site-packages/ZODB/mvccadapter.py:131: in poll_invalidations
              self._start = p64(u64(self._storage.lastTransaction()) + 1)
          _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
      
          self = <neo.client.Storage.Storage object at 0x7ffa1be8d410>
      
              def lastTransaction(self):
                  # Used in ZODB unit tests
          >       return self.app.last_tid
          E       AttributeError: 'NoneType' object has no attribute 'last_tid'
      
          ../../neo/src/lab.nexedi.com/kirr/neo/neo/client/Storage.py:181: AttributeError
      
      where NEO's Storage.app is None because the storage was closed.
      
      ----
      
      To avoid such kind of failures make sure TestDB.teardown() always closes
      all ZODB connections that were ever opened via TestDB.dbopen().
      
      Add a warning about such force-closing with information about corresponding
      connection and code place that created it, so that it is easy to
      understand which test needs a fix.
      
      /suggested-by @jm
      5a5ed2c7
  16. 16 Apr, 2018 4 commits
    • Kirill Smelkov's avatar
      wendelin.core v0.12 · 72df6eb6
      Kirill Smelkov authored
      72df6eb6
    • Kirill Smelkov's avatar
      tox: v↑ everything · 0dbf3c44
      Kirill Smelkov authored
      - start testing NEO with ZODB4 and ZODB5. ZODB4-*-NEO works while
        ZODB5-*-NEO currently fails [1].
      - update NumPy to latest releases.
      - update Python 3 to latest releases.
      0dbf3c44
    • Kirill Smelkov's avatar
      tests: Teach to run with ZEO5 · 808b59b7
      Kirill Smelkov authored
      Since 7fc4ec66 (tests: Allow to test with ZEO & NEO ZODB storages) we
      can run the tests with either FileStorage, ZEO or NEO. But ZEO test
      adapter started to fail with ZEO5:
      
      	self = <wendelin.lib.testing.TestDB_ZEO object at 0x7f1feb5091d0>
      
      	    def setup(self):
      	        port  = self.zeo_forker.get_port()
      	        zconf = self.zeo_forker.ZEOConfig(('', port))
      	        self.addr, self.adminaddr, self.pid, self.path = \
      	>               self.zeo_forker.start_zeo_server(zeo_conf=zconf, port=port)
      	E       ValueError: need more than 2 values to unpack
      
      This is because in ZEO5 forker.start_zeo_server() was reworked to return only
      addr and stop closure instead of returning all details and relying on caller to
      implement stop itself.
      
      Adapt the test to detect ZEO5 and use new calling convention.
      808b59b7
    • Kirill Smelkov's avatar
      tox/ZODB3: Limit ZConfig < 3.2.0 · c96daa2f
      Kirill Smelkov authored
      With ZConfig==3.2.0 (released 2017-06-22) ZEO started to get file names
      as unicode, which eventually breaks on assert in ZODB3.FileStorage code:
      
          Traceback (most recent call last):
            File "/home/kirr/src/wendelin/r/work/venv/local/lib/python2.7/site-packages/ZEO/tests/zeoserver.py", line 215, in <module>
              main()
            File "/home/kirr/src/wendelin/r/work/venv/local/lib/python2.7/site-packages/ZEO/tests/zeoserver.py", line 188, in main
              server = ZEO.runzeo.create_server({"1": storage}, zo)
            File "/home/kirr/src/wendelin/r/work/venv/local/lib/python2.7/site-packages/ZEO/runzeo.py", line 366, in create_server
              auth_realm = options.auth_realm,
            File "/home/kirr/src/wendelin/r/work/venv/local/lib/python2.7/site-packages/ZEO/StorageServer.py", line 890, in __init__
              self._setup_invq(name, storage)
            File "/home/kirr/src/wendelin/r/work/venv/local/lib/python2.7/site-packages/ZEO/StorageServer.py", line 928, in _setup_invq
              self.invq[name] = list(lastInvalidations(self.invq_bound))
            File "/home/kirr/src/wendelin/r/work/venv/local/lib/python2.7/site-packages/ZODB/FileStorage/FileStorage.py", line 1238, in lastInvalidations
              for trans in FileIterator(self._file_name, pos=pos)]
            File "/home/kirr/src/wendelin/r/work/venv/local/lib/python2.7/site-packages/ZODB/FileStorage/FileStorage.py", line 1640, in __init__
              assert isinstance(filename, str), `filename`
          AssertionError: u'/home/kirr/src/wendelin/r/work/wendelin.core/Data.fs'
      
      -> So for ZODB3 pin ZConfig to ZConfig <3.2.0 which is known to work with ZODB3.
      c96daa2f
  17. 12 Apr, 2018 1 commit
    • Kirill Smelkov's avatar
      bigarray: ArrayRef utility · e9d61a89
      Kirill Smelkov authored
      ArrayRef is a reference to NumPy array.
      
      The reference is represented by root array object and instructions how to
      create original array as some view of the root.
      
      Such reference could be useful in situations where one needs to pass arrays
      between processes and instead of copying array data, leverage the fact that
      top-level array, for example ZBigArray, is already persisted separately, and
      only send small amount of information referencing data in question.
      
      Use `ArrayRef(array)` to create reference to an ndarray.
      
      Use `.deref()` to convert ArrayRef to pointed array object.
      
      NOTE
      
      don't send ArrayRef unconditionally - for example when array object is
      small regular ndarray with also regular, but big, root ndarray, sending
      ArrayRef will send whole data for root object, not for small leaf.
      
      Sending ArrayRef only makes sense when root object is known to be already
      persisted by other means, for example something like below in ZODB context:
      
      ```python
        aref = ArrayRef(a)
        if isinstance(aref.root, Persistent):
            send aref
        else:
            send a 
      ```
      
      Please see individual patches for more details.
      
      /reviewed-on !6
      e9d61a89
  18. 02 Apr, 2018 2 commits
    • Kirill Smelkov's avatar
      bigarray: ArrayRef support for BigArray · 450ad804
      Kirill Smelkov authored
      Rationale
      ---------
      
      Array reference could be useful in situations where one needs to pass arrays
      between processes and instead of copying array data, leverage the fact that
      top-level array, for example ZBigArray, is already persisted separately, and
      only send small amount of information referencing data in question.
      
      Implementation
      --------------
      
      BigArray is not regular NumPy array and so needs explicit support in
      ArrayRef code to find root object and indices. This patch adds such
      support via the following way:
      
      - when BigArray.__getitem__ creates VMA, it remembers in the VMA
        the top-level BigArray object under which this VMA was created.
      
      - when ArrayRef is finding root, it can detect such VMAs, because it will
        be pointed to by the most top regular ndarray's .base, and in turn gets
        top-level BigArray object from the VMA.
      
      - further all indices computations are performed, similarly to complete regular
        ndarrays case, on ndarrays root and a. But in the end .lo and .hi are
        adjusted for the corresponding offset of where root is inside whole
        BigArray.
      
      - there is no need to adjust .deref() at all.
      
      For remembering information into a VMA and also to be able to get
      (readonly) its mapping addresses _bigfile.c extension has to be extended
      a bit. Since we are now storing arbitrary python object attached to
      PyVMA - it can create cycles - and so PyVMA accordingly adjusted to
      support cyclic garbage collector.
      
      Please see the patch itself for more details and comments.
      450ad804
    • Kirill Smelkov's avatar
      bigarray: Add ArrayRef utility · d53371b6
      Kirill Smelkov authored
      ArrayRef is a tool to find out for a NumPy array its top-level root
      parent and remember instructions how to recreate original array from
      the root. For example if
      
      	root = arange(1E7)
      	z = root[1000:2000]
      	a = z[10:20]
      
      `ArrayRef(a)` will find out that the root array for `a` is `root` and
      that `a` occupies 1010:1020 bytes in it. The vice versa operation is
      also possible, for example given
      
      	aref = ArrayRef(a)
      
      it is possible to restore original `a` from `aref`:
      
      	a_ = aref.deref()
      	assert array_equal(a_, a)
      
      the restoration works without copying by creating appropriate view of
      root.
      
      ArrayRef should work reliably for arrays of arbitrary dimensions,
      strides etc - even fancy arrays created via stride tricks such as arrays
      whose elements overlap each other should be supported.
      
      This patch adds ArrayRef with support for regular ndarrays only.
      
      The next patch will add ArrayRef support for BigArray and description
      for ArrayRef rationale.
      d53371b6
  19. 21 Feb, 2018 1 commit
  20. 31 Jan, 2018 1 commit
    • Kirill Smelkov's avatar
      bigfile/virtmem: Fix build with recent glibc · c3cc8a99
      Kirill Smelkov authored
      It was
      
      	bigfile/pagefault.c:45:36: warning: ‘struct ucontext’ declared inside parameter list will not be visible outside of this definition or declaration
      	 static int faulted_by(const struct ucontext *uc);
      	                                    ^~~~~~~~
      	bigfile/pagefault.c: In function ‘on_pagefault’:
      	bigfile/pagefault.c:59:24: warning: passing argument 1 of ‘faulted_by’ from incompatible pointer type [-Wincompatible-pointer-types]
      	     write = faulted_by(uc);
      	                        ^~
      	bigfile/pagefault.c:45:12: note: expected ‘const struct ucontext *’ but argument is of type ‘struct ucontext *’
      	 static int faulted_by(const struct ucontext *uc);
      	            ^~~~~~~~~~
      	bigfile/pagefault.c: At top level:
      	bigfile/pagefault.c:208:36: warning: ‘struct ucontext’ declared inside parameter list will not be visible outside of this definition or declaration
      	 static int faulted_by(const struct ucontext *uc)
      	                                    ^~~~~~~~
      	bigfile/pagefault.c:208:12: error: conflicting types for ‘faulted_by’
      	 static int faulted_by(const struct ucontext *uc)
      	            ^~~~~~~~~~
      	bigfile/pagefault.c:45:12: note: previous declaration of ‘faulted_by’ was here
      	 static int faulted_by(const struct ucontext *uc);
      	            ^~~~~~~~~~
      	bigfile/pagefault.c: In function ‘faulted_by’:
      	bigfile/pagefault.c:217:15: error: dereferencing pointer to incomplete type ‘const struct ucontext’
      	     write = uc->uc_mcontext.gregs[REG_ERR] & 0x2;
      	               ^~
      	bigfile/pagefault.c: At top level:
      	bigfile/pagefault.c:45:12: warning: ‘faulted_by’ used but never defined
      	 static int faulted_by(const struct ucontext *uc);
      	            ^~~~~~~~~~
      	bigfile/pagefault.c:208:12: warning: ‘faulted_by’ defined but not used [-Wunused-function]
      	 static int faulted_by(const struct ucontext *uc)
      	            ^~~~~~~~~~
      
      Change to using ucontext_t because apparently there is no `struct
      ucontext` anymore (and man for sigaction says 3rd parameter to hander is
      of type `ucontext_t *` - not `struct ucontext *` - cast to `void *`)
      
      Explicitly include <ucontext.h> because we are dereferencing ucontext_t,
      even though today it appears to be included by <signal.h>.
      c3cc8a99