Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wendelin.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Kirill Smelkov
wendelin.core
Commits
754c3f5a
Commit
754c3f5a
authored
Dec 10, 2019
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
20098507
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
6 deletions
+85
-6
lib/testing.py
lib/testing.py
+6
-1
zloadrace.py
zloadrace.py
+51
-0
zopenrace.py
zopenrace.py
+28
-5
No files found.
lib/testing.py
View file @
754c3f5a
...
...
@@ -259,9 +259,12 @@ class TestDB_ZEO(TestDB_Base):
def
setup
(
self
):
self
.
tmpd
=
mkdtemp
(
''
,
'testdb_zeo.'
)
port
=
self
.
zeo_forker
.
get_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
:
self
.
addr
,
self
.
stop
=
_
else
:
...
...
@@ -274,6 +277,8 @@ class TestDB_ZEO(TestDB_Base):
self
.
zeo_forker
.
shutdown_zeo_server
(
self
.
adminaddr
)
os
.
waitpid
(
self
.
pid
,
0
)
rmtree
(
self
.
tmpd
)
def
getZODBStorage
(
self
):
from
ZEO.ClientStorage
import
ClientStorage
return
ClientStorage
(
self
.
addr
)
...
...
zloadrace.py
0 → 100644
View file @
754c3f5a
#!/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
zopenrace.py
View file @
754c3f5a
...
...
@@ -110,14 +110,33 @@ class PInt(Persistent):
def
main
():
zstor
=
MappingStorage
()
db
=
DB
(
zstor
)
# for ZODB5: open vs invalidation race
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.
def
init
():
transaction
.
begin
()
zconn
=
db
.
open
()
zconn
=
db
1
.
open
()
root
=
zconn
.
root
()
root
[
'obj1'
]
=
PInt
(
0
)
...
...
@@ -136,7 +155,7 @@ def main():
def
T1
(
N
):
def
t1
():
transaction
.
begin
()
zconn
=
db
.
open
()
zconn
=
db
1
.
open
()
root
=
zconn
.
root
()
obj1
=
root
[
'obj1'
]
...
...
@@ -156,7 +175,10 @@ def main():
zconn
.
close
()
for
i
in
range
(
N
):
print
(
'T1.%d'
%
i
)
t1
()
#import time
#time.sleep(1)
okv
[
0
]
=
True
...
...
@@ -166,7 +188,7 @@ def main():
def
T2
(
N
):
def
t2
():
transaction
.
begin
()
zconn
=
db
.
open
()
zconn
=
db
2
.
open
()
root
=
zconn
.
root
()
obj1
=
root
[
'obj1'
]
...
...
@@ -179,6 +201,7 @@ def main():
zconn
.
close
()
for
i
in
range
(
N
):
print
(
'T2.%d'
%
i
)
t2
()
okv
[
1
]
=
True
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment