Commit 4b588f69 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e5600597
......@@ -5,8 +5,10 @@
from __future__ import print_function
from ZODB import DB
from ZODB.MappingStorage import MappingStorage
from ZODB.POSException import ConflictError
import transaction
from persistent import Persistent
from random import randint
from golang import func, defer, select, default
from golang import sync, context
......@@ -67,6 +69,8 @@ def main():
#
# access to obj1 is organized to always trigger loading from zstor.
# access to obj2 goes through zconn cache and so verifies whether the cache is not stale.
#
# XXX + commit
@func
def T1(ctx, name, N):
db = dbopen()
......@@ -88,18 +92,33 @@ def main():
i1 = obj1.i
i2 = obj2.i
if i1 != i2:
raise AssertionError("T1: obj1.i (%d) != obj2.i (%d)" % (i1, i2))
print('FAIL')
raise AssertionError("T%s: obj1.i (%d) != obj2.i (%d)" % (name, i1, i2))
# change objects once in a while
if randint(0,4) == 0:
obj1.i += 1
obj2.i += 1
#transaction.abort() # we did not changed anything; also fails with commit
try:
transaction.commit()
except ConflictError:
#print('conflict -> ignore')
transaction.abort()
transaction.abort() # we did not changed anything; also fails with commit
zconn.close()
for i in range(N):
#print('T1%s.%d' % (name, i))
if ready(ctx.done()):
break
print('T1%s.%d' % (name, i))
t1()
raise RuntimeError("T1: done")
"""
# T2 changes obj1/obj2 in a loop by doing `objX.i += 1`.
#
# Since both objects start from 0, the invariant that `obj1.i == obj2.i` is always preserved.
......@@ -127,6 +146,7 @@ def main():
break
#print('T2.%d' % i)
t2()
"""
# run T1 and T2 concurrently. As of 20191210, due to race condition in
......@@ -135,9 +155,9 @@ def main():
N = 100000
wg = sync.WorkGroup(context.background())
for x in 'a':
for x in 'ab':
wg.go(T1, x, N)
wg.go(T2, N)
#wg.go(T2, N)
wg.wait()
print('OK')
......
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