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
Kirill Smelkov
ZODB
Commits
daf82646
Commit
daf82646
authored
Nov 11, 2021
by
Kirill Smelkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make lint happy
Sorry, but some of flake8 complaints are really stupid...
parent
e8010aa6
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
54 additions
and
37 deletions
+54
-37
src/ZODB/DemoStorage.py
src/ZODB/DemoStorage.py
+0
-1
src/ZODB/FileStorage/FileStorage.py
src/ZODB/FileStorage/FileStorage.py
+1
-1
src/ZODB/interfaces.py
src/ZODB/interfaces.py
+10
-7
src/ZODB/mvccadapter.py
src/ZODB/mvccadapter.py
+7
-5
src/ZODB/tests/hexstorage.py
src/ZODB/tests/hexstorage.py
+2
-1
src/ZODB/tests/testDemoStorage.py
src/ZODB/tests/testDemoStorage.py
+18
-13
src/ZODB/utils.py
src/ZODB/utils.py
+16
-9
No files found.
src/ZODB/DemoStorage.py
View file @
daf82646
...
@@ -256,7 +256,6 @@ class DemoStorage(ConflictResolvingStorage):
...
@@ -256,7 +256,6 @@ class DemoStorage(ConflictResolvingStorage):
# regular data record
# regular data record
return
data
,
serial
,
next_serial
return
data
,
serial
,
next_serial
def
loadBlob
(
self
,
oid
,
serial
):
def
loadBlob
(
self
,
oid
,
serial
):
try
:
try
:
return
self
.
changes
.
loadBlob
(
oid
,
serial
)
return
self
.
changes
.
loadBlob
(
oid
,
serial
)
...
...
src/ZODB/FileStorage/FileStorage.py
View file @
daf82646
src/ZODB/interfaces.py
View file @
daf82646
...
@@ -889,25 +889,28 @@ class IPrefetchStorage(IStorage):
...
@@ -889,25 +889,28 @@ class IPrefetchStorage(IStorage):
more than once.
more than once.
"""
"""
class
IStorageLoadBeforeEx
(
Interface
):
class
IStorageLoadBeforeEx
(
Interface
):
def
loadBeforeEx
(
oid
,
before
):
# -> (data, serial)
def
loadBeforeEx
(
oid
,
before
):
# -> (data, serial)
"""Load object data as observed before given database state.
"""Load object data as observed before given database state.
loadBeforeEx returns data for object with given object ID as observed by
loadBeforeEx returns data for object with given object ID as observed
most recent database transaction with ID < before. Two values are returned:
by most recent database transaction with ID < before. Two values are
returned:
- The data record,
- The data record,
- The transaction ID of the data record.
- The transaction ID of the data record.
If the object does not exist, or is deleted as of requested database
state,
If the object does not exist, or is deleted as of requested database
loadBeforeEx returns data=None, and serial indicates transaction ID of the
state, loadBeforeEx returns data=None, and serial indicates transaction
most recent deletion done in transaction with ID < before, or null tid if
ID of the most recent deletion done in transaction with ID < before, or
there is no such deletion.
null tid if
there is no such deletion.
Note: no POSKeyError is raised even if object id is not in the storage.
Note: no POSKeyError is raised even if object id is not in the storage.
"""
"""
class
IMultiCommitStorage
(
IStorage
):
class
IMultiCommitStorage
(
IStorage
):
"""A multi-commit storage can commit multiple transactions at once.
"""A multi-commit storage can commit multiple transactions at once.
...
...
src/ZODB/mvccadapter.py
View file @
daf82646
...
@@ -10,7 +10,8 @@ also simplifies the implementation of the DB and Connection classes.
...
@@ -10,7 +10,8 @@ also simplifies the implementation of the DB and Connection classes.
import
zope.interface
import
zope.interface
from
.
import
interfaces
,
serialize
,
POSException
from
.
import
interfaces
,
serialize
,
POSException
from
.utils
import
p64
,
u64
,
z64
,
maxtid
,
Lock
,
loadBeforeEx
,
oid_repr
,
tid_repr
from
.utils
import
p64
,
u64
,
z64
,
maxtid
,
Lock
,
loadBeforeEx
,
oid_repr
,
\
tid_repr
class
Base
(
object
):
class
Base
(
object
):
...
@@ -158,11 +159,12 @@ class MVCCAdapterInstance(Base):
...
@@ -158,11 +159,12 @@ class MVCCAdapterInstance(Base):
data
,
serial
=
loadBeforeEx
(
self
.
_storage
,
oid
,
self
.
_start
)
data
,
serial
=
loadBeforeEx
(
self
.
_storage
,
oid
,
self
.
_start
)
if
data
is
None
:
if
data
is
None
:
# raise POSKeyError if object does not exist at all
# raise POSKeyError if object does not exist at all
# TODO raise POSKeyError always and switch to raising ReadOnlyError only when
# TODO raise POSKeyError always and switch to raising ReadOnlyError
# actually detecting that load is being affected by simultaneous pack (see below).
# only when actually detecting that load is being affected by
# simultaneous pack (see below).
if
serial
==
z64
:
if
serial
==
z64
:
# XXX second call to loadBeforeEx - it will become unneeded
once we
# XXX second call to loadBeforeEx - it will become unneeded
# switch to raising POSKeyError.
#
once we
switch to raising POSKeyError.
_
,
serial_exists
=
loadBeforeEx
(
self
.
_storage
,
oid
,
maxtid
)
_
,
serial_exists
=
loadBeforeEx
(
self
.
_storage
,
oid
,
maxtid
)
if
serial_exists
==
z64
:
if
serial_exists
==
z64
:
# object does not exist at all
# object does not exist at all
...
...
src/ZODB/tests/hexstorage.py
View file @
daf82646
...
@@ -39,7 +39,8 @@ class HexStorage(object):
...
@@ -39,7 +39,8 @@ class HexStorage(object):
setattr
(
self
,
name
,
v
)
setattr
(
self
,
name
,
v
)
zope
.
interface
.
directlyProvides
(
self
,
zope
.
interface
.
providedBy
(
base
))
zope
.
interface
.
directlyProvides
(
self
,
zope
.
interface
.
providedBy
(
base
))
if
hasattr
(
base
,
'loadBeforeEx'
)
and
'loadBeforeEx'
not
in
self
.
copied_methods
:
if
hasattr
(
base
,
'loadBeforeEx'
)
and
\
'loadBeforeEx'
not
in
self
.
copied_methods
:
def
loadBeforeEx
(
oid
,
before
):
def
loadBeforeEx
(
oid
,
before
):
data
,
serial
=
self
.
base
.
loadBeforeEx
(
oid
,
before
)
data
,
serial
=
self
.
base
.
loadBeforeEx
(
oid
,
before
)
if
data
is
not
None
:
if
data
is
not
None
:
...
...
src/ZODB/tests/testDemoStorage.py
View file @
daf82646
...
@@ -270,7 +270,10 @@ def load_before_base_storage_current():
...
@@ -270,7 +270,10 @@ def load_before_base_storage_current():
>>> base.close()
>>> base.close()
"""
"""
# additional DemoStorage tests that do not fit into common DemoStorageTests setup.
# additional DemoStorage tests that do not fit into common DemoStorageTests
# setup.
class
DemoStorageTests2
(
ZODB
.
tests
.
util
.
TestCase
):
class
DemoStorageTests2
(
ZODB
.
tests
.
util
.
TestCase
):
def
checkLoadAfterDelete
(
self
):
def
checkLoadAfterDelete
(
self
):
"""Verify that DemoStorage correctly handles load requests for objects
"""Verify that DemoStorage correctly handles load requests for objects
...
@@ -314,7 +317,8 @@ class DemoStorageTests2(ZODB.tests.util.TestCase):
...
@@ -314,7 +317,8 @@ class DemoStorageTests2(ZODB.tests.util.TestCase):
obj
=
root
[
'obj'
]
obj
=
root
[
'obj'
]
oid
=
obj
.
_p_oid
oid
=
obj
.
_p_oid
obj
.
value
+=
1
obj
.
value
+=
1
# modify root as well so that there is root revision saved in overlay that points to obj
# modify root as well so that there is root revision saved in overlay
# that points to obj
root
[
'x'
]
=
1
root
[
'x'
]
=
1
transaction
.
commit
()
transaction
.
commit
()
atLive
=
obj
.
_p_serial
atLive
=
obj
.
_p_serial
...
@@ -333,7 +337,8 @@ class DemoStorageTests2(ZODB.tests.util.TestCase):
...
@@ -333,7 +337,8 @@ class DemoStorageTests2(ZODB.tests.util.TestCase):
# simulate GC on base+overlay
# simulate GC on base+overlay
zoverlay
=
FileStorage
(
"overlay.fs"
)
zoverlay
=
FileStorage
(
"overlay.fs"
)
txn
=
transaction
.
get
()
txn
=
transaction
.
get
()
txn_meta
=
TransactionMetaData
(
txn
.
user
,
txn
.
description
,
txn
.
extension
)
txn_meta
=
TransactionMetaData
(
txn
.
user
,
txn
.
description
,
txn
.
extension
)
zoverlay
.
tpc_begin
(
txn_meta
)
zoverlay
.
tpc_begin
(
txn_meta
)
zoverlay
.
deleteObject
(
oid
,
atLive
,
txn_meta
)
zoverlay
.
deleteObject
(
oid
,
atLive
,
txn_meta
)
zoverlay
.
tpc_vote
(
txn_meta
)
zoverlay
.
tpc_vote
(
txn_meta
)
...
...
src/ZODB/utils.py
View file @
daf82646
...
@@ -406,6 +406,8 @@ def load_current(storage, oid, version=''):
...
@@ -406,6 +406,8 @@ def load_current(storage, oid, version=''):
_loadBeforeExWarned
=
set
()
# of storage class
_loadBeforeExWarned
=
set
()
# of storage class
def
loadBeforeEx
(
storage
,
oid
,
before
):
def
loadBeforeEx
(
storage
,
oid
,
before
):
"""loadBeforeEx provides IStorageLoadBeforeEx semantic for all storages.
"""loadBeforeEx provides IStorageLoadBeforeEx semantic for all storages.
...
@@ -430,16 +432,21 @@ def loadBeforeEx(storage, oid, before):
...
@@ -430,16 +432,21 @@ def loadBeforeEx(storage, oid, before):
# DemoStorage (https://github.com/zopefoundation/ZODB/issues/318), so
# DemoStorage (https://github.com/zopefoundation/ZODB/issues/318), so
# emit corresponding warning.
# emit corresponding warning.
if
type
(
storage
)
not
in
_loadBeforeExWarned
:
if
type
(
storage
)
not
in
_loadBeforeExWarned
:
# there is potential race around _loadBeforeExWarned access, but
due to the
# there is potential race around _loadBeforeExWarned access, but
#
GIL this race cannot result in that set corruption, and can only lead
#
due to the GIL this race cannot result in that set corruption,
#
to us emitting the warning twice instead of just once.
#
and can only lead to us emitting the warning twice instead of
# -> do not spend CPU on lock and just ignore it.
#
just once.
-> do not spend CPU on lock and just ignore it.
warnings
.
warn
(
warnings
.
warn
(
"FIXME %s does not provide loadBeforeEx - emulating it via loadBefore, but ...
\
n
"
"FIXME %s does not provide loadBeforeEx - emulating it via "
"loadBefore, but ...
\
n
"
"
\
t
... 1) access is be potentially slower, and
\
n
"
"
\
t
... 1) access is be potentially slower, and
\
n
"
"
\
t
... 2) not full semantic of loadBeforeEx could be provided.
\
n
"
"
\
t
... 2) not full semantic of loadBeforeEx could be "
"
\
t
... this can lead to data corruption in the presence of delete records.
\
n
"
"provided.
\
n
"
"
\
t
... -> please see https://github.com/zopefoundation/ZODB/issues/318 for details."
%
"
\
t
... this can lead to data corruption in the presence "
"of delete records.
\
n
"
"
\
t
... -> please see "
"https://github.com/zopefoundation/ZODB/issues/318 for "
"details."
%
type
(
storage
),
PendingDeprecationWarning
)
type
(
storage
),
PendingDeprecationWarning
)
_loadBeforeExWarned
.
add
(
type
(
storage
))
_loadBeforeExWarned
.
add
(
type
(
storage
))
return
(
None
,
z64
)
return
(
None
,
z64
)
...
...
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