Commit 754c3f5a authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent 20098507
...@@ -259,9 +259,12 @@ class TestDB_ZEO(TestDB_Base): ...@@ -259,9 +259,12 @@ class TestDB_ZEO(TestDB_Base):
def setup(self): def setup(self):
self.tmpd = mkdtemp('', 'testdb_zeo.')
port = self.zeo_forker.get_port() port = self.zeo_forker.get_port()
zconf = self.zeo_forker.ZEOConfig(('', port)) zconf = self.zeo_forker.ZEOConfig(('', port))
_ = self.zeo_forker.start_zeo_server(zeo_conf=zconf, port=port) # XXX path - on tmpfs
_ = self.zeo_forker.start_zeo_server(path='%s/1.fs' % self.tmpd, zeo_conf=zconf, port=port)
if self.z5: if self.z5:
self.addr, self.stop = _ self.addr, self.stop = _
else: else:
...@@ -274,6 +277,8 @@ class TestDB_ZEO(TestDB_Base): ...@@ -274,6 +277,8 @@ class TestDB_ZEO(TestDB_Base):
self.zeo_forker.shutdown_zeo_server(self.adminaddr) self.zeo_forker.shutdown_zeo_server(self.adminaddr)
os.waitpid(self.pid, 0) os.waitpid(self.pid, 0)
rmtree(self.tmpd)
def getZODBStorage(self): def getZODBStorage(self):
from ZEO.ClientStorage import ClientStorage from ZEO.ClientStorage import ClientStorage
return ClientStorage(self.addr) return ClientStorage(self.addr)
......
#!/usr/bin/env python
"""Program zloadrace.py demonstrates concurrency bug in ZODB Connection.setstate()
that leads to XXX
XXX
XXX load vs invalidation race is there on ZODB4 and ZODB3, but on ZODB5 there is
another open vs invalidation race.
"""
from ZODB import DB
import transaction
from persistent import Persistent
from wendelin.lib.testing import TestDB_ZEO, TestDB_NEO
from golang import sync, context
# PInt is persistent integer.
class PInt(Persistent):
def __init__(self, i):
self.i = i
@func
def main():
tdb = TestDB_ZEO('<zeo>')
#tdb = TestDB_NEO('<neo>')
defer(tdb.teardown)
# two ZODB client storage connections to the same server
zstor1 = tdb.getZODBStorage() ; defer(zstor1.close)
zstor2 = tdb.getZODBStorage() ; defer(zstor2.close)
db1 = DB(zstor1)
db2 = DB(zstor2)
def init():
# XXX
def C1():
# XXX
def C2():
# XXX
...@@ -110,14 +110,33 @@ class PInt(Persistent): ...@@ -110,14 +110,33 @@ class PInt(Persistent):
def main(): def main():
zstor = MappingStorage() # for ZODB5: open vs invalidation race
db = DB(zstor) if 0:
zstor1 = zstor2 = MappingStorage()
db1 = db2 = DB(zstor1)
# for ZODB3/ZODB5: load vs invalidation race
if 1:
from wendelin.lib.testing import TestDB_ZEO, TestDB_NEO
tdb = TestDB_ZEO('<zeo>')
#tdb = TestDB_NEO('<neo>')
tdb.setup()
# XXX defer(tdb.teardown)
# two ZODB client storage connections to the same server
zstor1 = tdb.getZODBStorage() # ; defer(zstor1.close)
zstor2 = tdb.getZODBStorage() # ; defer(zstor2.close)
db1 = DB(zstor1)
db2 = DB(zstor2)
# init initializes the database with two integer objects - obj1/obj2 that are set to 0. # init initializes the database with two integer objects - obj1/obj2 that are set to 0.
def init(): def init():
transaction.begin() transaction.begin()
zconn = db.open() zconn = db1.open()
root = zconn.root() root = zconn.root()
root['obj1'] = PInt(0) root['obj1'] = PInt(0)
...@@ -136,7 +155,7 @@ def main(): ...@@ -136,7 +155,7 @@ def main():
def T1(N): def T1(N):
def t1(): def t1():
transaction.begin() transaction.begin()
zconn = db.open() zconn = db1.open()
root = zconn.root() root = zconn.root()
obj1 = root['obj1'] obj1 = root['obj1']
...@@ -156,7 +175,10 @@ def main(): ...@@ -156,7 +175,10 @@ def main():
zconn.close() zconn.close()
for i in range(N): for i in range(N):
print('T1.%d' % i)
t1() t1()
#import time
#time.sleep(1)
okv[0] = True okv[0] = True
...@@ -166,7 +188,7 @@ def main(): ...@@ -166,7 +188,7 @@ def main():
def T2(N): def T2(N):
def t2(): def t2():
transaction.begin() transaction.begin()
zconn = db.open() zconn = db2.open()
root = zconn.root() root = zconn.root()
obj1 = root['obj1'] obj1 = root['obj1']
...@@ -179,6 +201,7 @@ def main(): ...@@ -179,6 +201,7 @@ def main():
zconn.close() zconn.close()
for i in range(N): for i in range(N):
print('T2.%d' % i)
t2() t2()
okv[1] = True okv[1] = True
......
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