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
caea03ca
Commit
caea03ca
authored
Jun 19, 2016
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
IStorage: simplify the API of store/tpc_finish to notify of resolved conflicts
parent
cf02e50a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
15 deletions
+24
-15
src/ZODB/ConflictResolution.py
src/ZODB/ConflictResolution.py
+1
-1
src/ZODB/Connection.py
src/ZODB/Connection.py
+13
-5
src/ZODB/interfaces.py
src/ZODB/interfaces.py
+8
-7
src/ZODB/tests/testDemoStorage.py
src/ZODB/tests/testDemoStorage.py
+2
-2
No files found.
src/ZODB/ConflictResolution.py
View file @
caea03ca
...
@@ -28,7 +28,7 @@ from pickle import PicklingError
...
@@ -28,7 +28,7 @@ from pickle import PicklingError
logger
=
logging
.
getLogger
(
'ZODB.ConflictResolution'
)
logger
=
logging
.
getLogger
(
'ZODB.ConflictResolution'
)
ResolvedSerial
=
b'rs'
ResolvedSerial
=
b'rs'
# deprecated: store/tpc_finish should just use True
class
BadClassName
(
Exception
):
class
BadClassName
(
Exception
):
pass
pass
...
...
src/ZODB/Connection.py
View file @
caea03ca
...
@@ -705,7 +705,7 @@ class Connection(ExportImport, object):
...
@@ -705,7 +705,7 @@ class Connection(ExportImport, object):
self
.
_handle_serial
(
oid
,
s
)
self
.
_handle_serial
(
oid
,
s
)
def
_handle_serial
(
self
,
oid
,
serial
,
change
=
True
):
def
_handle_serial
(
self
,
oid
,
serial
=
True
,
change
=
True
):
# if we write an object, we don't want to check if it was read
# if we write an object, we don't want to check if it was read
# while current. This is a convenient choke point to do this.
# while current. This is a convenient choke point to do this.
...
@@ -713,7 +713,9 @@ class Connection(ExportImport, object):
...
@@ -713,7 +713,9 @@ class Connection(ExportImport, object):
if
not
serial
:
if
not
serial
:
return
return
if
not
isinstance
(
serial
,
bytes
):
if
serial
is
True
:
serial
=
ResolvedSerial
elif
not
isinstance
(
serial
,
bytes
):
raise
serial
raise
serial
obj
=
self
.
_cache
.
get
(
oid
,
None
)
obj
=
self
.
_cache
.
get
(
oid
,
None
)
if
obj
is
None
:
if
obj
is
None
:
...
@@ -721,6 +723,7 @@ class Connection(ExportImport, object):
...
@@ -721,6 +723,7 @@ class Connection(ExportImport, object):
if
serial
==
ResolvedSerial
:
if
serial
==
ResolvedSerial
:
del
obj
.
_p_changed
# transition from changed to ghost
del
obj
.
_p_changed
# transition from changed to ghost
else
:
else
:
self
.
_warn_about_returned_serial
()
if
change
:
if
change
:
obj
.
_p_changed
=
0
# transition from changed to up-to-date
obj
.
_p_changed
=
0
# transition from changed to up-to-date
obj
.
_p_serial
=
serial
obj
.
_p_serial
=
serial
...
@@ -790,6 +793,11 @@ class Connection(ExportImport, object):
...
@@ -790,6 +793,11 @@ class Connection(ExportImport, object):
raise
raise
if
s
:
if
s
:
if
type
(
s
[
0
])
is
bytes
:
for
oid
in
s
:
self
.
_handle_serial
(
oid
)
return
self
.
_warn_about_returned_serial
()
for
oid
,
serial
in
s
:
for
oid
,
serial
in
s
:
self
.
_handle_serial
(
oid
,
serial
)
self
.
_handle_serial
(
oid
,
serial
)
...
@@ -829,9 +837,9 @@ class Connection(ExportImport, object):
...
@@ -829,9 +837,9 @@ class Connection(ExportImport, object):
self
.
_warn_about_returned_serial
=
lambda
:
None
self
.
_warn_about_returned_serial
=
lambda
:
None
else
:
else
:
warnings
.
warn
(
warnings
.
warn
(
"In ZODB 5+,
it will be required for tpc_finish to return the
"
"In ZODB 5+,
the new API for the returned value of
"
"
committed tid. store/tpc_vote will only have to notify about
"
"
store/tpc_vote/tpc_finish will be mandatory.
"
"
resolved conflicts
."
,
"
See IStorage for more information
."
,
DeprecationWarning
,
2
)
DeprecationWarning
,
2
)
Connection
.
_warn_about_returned_serial
=
lambda
self
:
None
Connection
.
_warn_about_returned_serial
=
lambda
self
:
None
...
...
src/ZODB/interfaces.py
View file @
caea03ca
...
@@ -797,13 +797,14 @@ class IStorage(Interface):
...
@@ -797,13 +797,14 @@ class IStorage(Interface):
without an error, then there must not be an error if
without an error, then there must not be an error if
tpc_finish or tpc_abort is called subsequently.
tpc_finish or tpc_abort is called subsequently.
The return value can be either None or a sequence of object-id
The return value can be either None or a sequence of oids for which
and serial pairs giving new serials for objects who's ids were
a conflict was resolved.
passed to previous store calls in the same transaction.
For compatibility, the return value can also be a sequence of object-id
A serial returned in a sequence of oid/serial pairs, may be
and serial pairs giving new serials for objects whose ids were
the special value ZODB.ConflictResolution.ResolvedSerial to
passed to previous store calls in the same transaction. The serial
indicate that a conflict occured and that the object should be
can be the special value ZODB.ConflictResolution.ResolvedSerial to
indicate that a conflict occurred and that the object should be
invalidated.
invalidated.
After the tpc_vote call, all solved conflicts must have been notified,
After the tpc_vote call, all solved conflicts must have been notified,
...
...
src/ZODB/tests/testDemoStorage.py
View file @
caea03ca
...
@@ -58,8 +58,8 @@ class DemoStorage(ZODB.DemoStorage.DemoStorage):
...
@@ -58,8 +58,8 @@ class DemoStorage(ZODB.DemoStorage.DemoStorage):
assert
type
(
s
)
is
bytes
,
s
assert
type
(
s
)
is
bytes
,
s
return
return
if
not
self
.
delayed_store
:
if
not
self
.
delayed_store
:
return
s
return
True
self
.
__stored
.
append
(
(
oid
,
s
)
)
self
.
__stored
.
append
(
oid
)
tpc_vote
=
property
(
lambda
self
:
self
.
_tpc_vote
,
lambda
*
_
:
None
)
tpc_vote
=
property
(
lambda
self
:
self
.
_tpc_vote
,
lambda
*
_
:
None
)
...
...
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