[ZODB-Dev] [ zodb-Bugs-225011 ] ZODB Cache Invalidation

noreply@sourceforge.net noreply@sourceforge.net
Sat, 09 Nov 2002 14:30:00 -0800


Bugs item #225011, was opened at 2000-12-08 12:21
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=115628&aid=225011&group_id=15628

Category: None
Group: None
>Status: Closed
Resolution: None
Priority: 5
Submitted By: John D. Heintz (jheintz)
Assigned to: Nobody/Anonymous (nobody)
Summary: ZODB Cache Invalidation

Initial Comment:
The following test file should work, but the Cache invalidation isn't doing what I expect.  Transaction.begin() doesn't refresh from the DB.

This is the same behavior that I think Andrew Kuchling was talking about wrt ZEO here: http://lists.zope.org/pipermail/zope-zeo/2000-October/000167.html

Python test file:
import Persistence
import ZODB
from ZODB.POSException import ConflictError
import threading

ROOT_KEY = 'key'

class P(Persistence.Persistent):
    pass

def runTest(storage=None):
    if not storage:
        from ZODB import DemoStorage
        storage = DemoStorage.DemoStorage()
    
    db = ZODB.DB(storage)

    testObj = setupRoot(db)

    assert testObj.test == 1

    modThread = threading.Thread(target=modifyRoot, args=(db,))
    modThread.start() # start the thread
    modThread.join() # block until it finishes running

    testThread = threading.Thread(target=assertRootTestValue, args=(db,2))
    testThread.start()
    testThread.join()

    assert testObj.test == 1

    get_transaction().begin() # Should refresh cached objects...

    try:
        assert testObj.test == 2
    except:
        #try doing a dummy commit
        try:
            testObj.foo = 'bar'
            get_transaction().commit()
        except ConflictError:
            pass

        assert testObj.test == 2, \
               "Cache not reset even after ConflictError"

        assert 0, "Cache reset only after ConflictError"


def assertRootTestValue(db, val):
    """This makes a new connection and check to make
    sure the test value == val"""
    
    conn = db.open()
    root = conn.root()

    testObj = root[ROOT_KEY]
    #print testObj, testObj.test  
    
    assert testObj.test == val
    
def setupRoot(db):
    conn = db.open()
    root = conn.root()

    result = P()
    result.test = 1
    root[ROOT_KEY] = result
    
    get_transaction().commit()
    
    return result
    
def modifyRoot(db):
    conn = db.open()
    root = conn.root()

    result = root[ROOT_KEY]

    result.test = result.test + 1

    get_transaction().commit()
    
    return result

if __name__ == '__main__':
    #from ZODB import FileStorage
    #storage = FileStorage.FileStorage('data.fs', 1)

    from ZODB import DemoStorage
    storage = DemoStorage.DemoStorage()
    runTest(storage)


----------------------------------------------------------------------

>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-11-09 17:29

Message:
Logged In: YES 
user_id=6380

Closing this. Please open a new bug report if this is still
a problem with ZODB 3.1.

----------------------------------------------------------------------

Comment By: John D. Heintz (jheintz)
Date: 2000-12-08 12:21

Message:
Doh! My tabbing is gone.  Email me for the file.  Sorry.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=115628&aid=225011&group_id=15628