Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
ZODB
Commits
84fe7245
Commit
84fe7245
authored
Sep 09, 2010
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed a test bug that caused checkCurrentSerialInTransaction to be
tested incorrectly for ZEO.
parent
4f4e2bd0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
15 deletions
+45
-15
src/ZEO/tests/testZEO.py
src/ZEO/tests/testZEO.py
+24
-0
src/ZODB/tests/BasicStorage.py
src/ZODB/tests/BasicStorage.py
+21
-15
No files found.
src/ZEO/tests/testZEO.py
View file @
84fe7245
...
...
@@ -249,6 +249,30 @@ class GenericTests(
key
=
'%s:%s'
%
(
self
.
_storage
.
_storage
,
self
.
_storage
.
_server_addr
)
self
.
assertEqual
(
self
.
_storage
.
sortKey
(),
key
)
def
_do_store_in_separate_thread
(
self
,
oid
,
revid
):
def
do_store
():
store
=
ZEO
.
ClientStorage
.
ClientStorage
(
self
.
_storage
.
_addr
)
try
:
t
=
transaction
.
get
()
store
.
tpc_begin
(
t
)
store
.
store
(
oid
,
revid
,
'x'
,
''
,
t
)
store
.
tpc_vote
(
t
)
store
.
tpc_finish
(
t
)
except
Exception
,
v
:
import
traceback
print
'E'
*
70
print
v
traceback
.
print_exception
(
*
sys
.
exc_info
())
finally
:
store
.
close
()
thread
=
threading
.
Thread
(
name
=
'T2'
,
target
=
do_store
)
thread
.
setDaemon
(
True
)
thread
.
start
()
thread
.
join
(.
2
)
return
thread
class
FullGenericTests
(
GenericTests
,
Cache
.
TransUndoStorageWithCache
,
...
...
src/ZODB/tests/BasicStorage.py
View file @
84fe7245
...
...
@@ -24,6 +24,8 @@ from ZODB.tests.MinPO import MinPO
from
ZODB.tests.StorageTestBase
import
zodb_unpickle
,
zodb_pickle
from
ZODB.tests.StorageTestBase
import
handle_serials
import
threading
import
time
import
transaction
import
zope.interface
import
zope.interface.verify
...
...
@@ -200,12 +202,21 @@ class BasicStorage:
self
.
_storage
.
tpc_finish
(
t
)
t
.
commit
()
def
_do_store_in_separate_thread
(
self
,
oid
,
revid
):
# We'll run the competing trans in a separate thread:
thread
=
threading
.
Thread
(
name
=
'T2'
,
target
=
self
.
_dostore
,
args
=
(
oid
,),
kwargs
=
dict
(
revid
=
revid
))
thread
.
setDaemon
(
True
)
thread
.
start
()
thread
.
join
(.
2
)
return
thread
def
check_checkCurrentSerialInTransaction
(
self
):
oid
=
'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
xf0
'
tid
=
self
.
_dostore
(
oid
)
tid2
=
self
.
_dostore
(
oid
,
revid
=
tid
)
#----------------------------------------------------------------------
# stale read
transaction
.
begin
()
t
=
transaction
.
get
()
...
...
@@ -219,11 +230,12 @@ class BasicStorage:
self
.
assert_
(
v
.
oid
)
==
oid
self
.
assert_
(
v
.
serials
==
(
tid2
,
tid
))
else
:
self
.
assert_
(
False
,
"No conflict error"
)
if
0
:
self
.
assert_
(
False
,
"No conflict error"
)
self
.
_storage
.
tpc_abort
(
t
)
#----------------------------------------------------------------------
# non-stale read, no stress. :)
transaction
.
begin
()
t
=
transaction
.
get
()
...
...
@@ -234,8 +246,9 @@ class BasicStorage:
self
.
_storage
.
tpc_vote
(
t
)
self
.
_storage
.
tpc_finish
(
t
)
#----------------------------------------------------------------------
# non-stale read, competition after vote. The competing
# transaction m
o
st produce a tid > this transaction's tid
# transaction m
u
st produce a tid > this transaction's tid
transaction
.
begin
()
t
=
transaction
.
get
()
self
.
_storage
.
tpc_begin
(
t
)
...
...
@@ -245,17 +258,14 @@ class BasicStorage:
self
.
_storage
.
tpc_vote
(
t
)
# We'll run the competing trans in a separate thread:
import
threading
,
time
thread
=
threading
.
Thread
(
name
=
'T1'
,
target
=
self
.
_dostore
,
args
=
(
oid
,),
kwargs
=
dict
(
revid
=
tid2
))
thread
.
start
()
time
.
sleep
(.
1
)
thread
=
self
.
_do_store_in_separate_thread
(
oid
,
tid2
)
self
.
_storage
.
tpc_finish
(
t
)
thread
.
join
()
thread
.
join
(
1
)
tid3
=
self
.
_storage
.
load
(
oid
)[
1
]
self
.
assert_
(
tid3
>
self
.
_storage
.
load
(
'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
xf3
'
)[
1
])
#----------------------------------------------------------------------
# non-stale competing trans after checkCurrentSerialInTransaction
transaction
.
begin
()
t
=
transaction
.
get
()
...
...
@@ -264,11 +274,7 @@ class BasicStorage:
'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
0
'
,
'x'
,
''
,
t
)
self
.
_storage
.
checkCurrentSerialInTransaction
(
oid
,
tid3
,
t
)
# We'll run the competing trans in a separate thread:
thread
=
threading
.
Thread
(
name
=
'T2'
,
target
=
self
.
_dostore
,
args
=
(
oid
,),
kwargs
=
dict
(
revid
=
tid3
))
thread
.
start
()
time
.
sleep
(.
1
)
thread
=
self
.
_do_store_in_separate_thread
(
oid
,
tid3
)
# There are 2 possibilities:
# 1. The store happens before this transaction completes,
...
...
@@ -277,7 +283,7 @@ class BasicStorage:
# tid of the object is greater than this transaction's tid.
try
:
self
.
_storage
.
tpc_vote
(
t
)
except
ReadConflictError
:
except
POSException
.
ReadConflictError
:
thread
.
join
()
# OK :)
else
:
self
.
_storage
.
tpc_finish
(
t
)
...
...
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