• Kirill Smelkov's avatar
    X test that ZBlk objects can be actually removed from ZODB Connection cache... · 69c94fbc
    Kirill Smelkov authored
    X test that ZBlk objects can be actually removed from ZODB Connection cache and cause invalidation to be missed
    
    ____________________________________ test_bigfile_filezodb_vs_cache_invalidation ____________________________________
    
        def test_bigfile_filezodb_vs_cache_invalidation():
            root = dbopen()
            conn = root._p_jar
            db   = conn.db()
            conn.close()
            del root, conn
    
            tm1 = TransactionManager()
            tm2 = TransactionManager()
    
            conn1 = db.open(transaction_manager=tm1)
            root1 = conn1.root()
    
            # setup zfile with fileh view to it
            root1['zfile3'] = f1 = ZBigFile(blksize)
            tm1.commit()
    
            fh1 = f1.fileh_open()
            tm1.commit()
    
            # set zfile initial data
            vma1 = fh1.mmap(0, 1)
            Blk(vma1, 0)[0] = 1
            tm1.commit()
    
            # read zfile and setup fileh for it in conn2
            conn2 = db.open(transaction_manager=tm2)
            root2 = conn2.root()
    
            f2 = root2['zfile3']
            fh2 = f2.fileh_open()
            vma2 = fh2.mmap(0, 1)
    
            assert Blk(vma2, 0)[0] == 1 # read data in conn2 + make sure read correctly
    
            # now zfile content is both in ZODB.Connection cache and in _ZBigFileH
            # cache for each conn1 and conn2. Modify data in conn1 and make sure it
            # fully propagate to conn2.
    
            Blk(vma1, 0)[0] = 2
            tm1.commit()
    
            # still should be read as old value in conn2
            assert Blk(vma2, 0)[0] == 1
            # and even after virtmem pages reclaim
            # ( verifies that _p_invalidate() in ZBlk.loadblkdata() does not lead to
            #   reloading data as updated )
            ram_reclaim_all()
            assert Blk(vma2, 0)[0] == 1
    
            # FIXME: this simulates ZODB Connection cache pressure and currently
            # removes ZBlk corresponding to blk #0 from conn2 cache.
            # In turn this leads to conn2 missing that block invalidation on follow-up
            # transaction boundary.
            #
            # See FIXME notes on ZBlkBase._p_invalidate() for detailed description.
            conn2._cache.minimize()
    
            tm2.commit()                # transaction boundary for t2
    
            # data from tm1 should propagate -> ZODB -> ram pages for _ZBigFileH in conn2
    >       assert Blk(vma2, 0)[0] == 2
    E       assert 1 == 2
    
    tests/test_filezodb.py:615: AssertionError
    69c94fbc
test_filezodb.py 21.5 KB