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
99b88cac
Commit
99b88cac
authored
Jun 05, 2003
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Merge atomic cache invalidation code from the 3.1 release branch.
parent
c6e799ae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
21 deletions
+52
-21
src/ZEO/ClientStorage.py
src/ZEO/ClientStorage.py
+52
-21
No files found.
src/ZEO/ClientStorage.py
View file @
99b88cac
...
@@ -268,6 +268,12 @@ class ClientStorage:
...
@@ -268,6 +268,12 @@ class ClientStorage:
self
.
_oid_lock
=
threading
.
Lock
()
self
.
_oid_lock
=
threading
.
Lock
()
self
.
_oids
=
[]
# Object ids retrieved from new_oids()
self
.
_oids
=
[]
# Object ids retrieved from new_oids()
# Can't read data in one thread while writing data
# (tpc_finish) in another thread. In general, the lock
# must prevent access to the cache while _update_cache
# is executing.
self
.
_lock
=
threading
.
Lock
()
t
=
self
.
_ts
=
get_timestamp
()
t
=
self
.
_ts
=
get_timestamp
()
self
.
_serial
=
`t`
self
.
_serial
=
`t`
self
.
_oid
=
'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
0
'
self
.
_oid
=
'
\
0
\
0
\
0
\
0
\
0
\
0
\
0
\
0
'
...
@@ -688,11 +694,19 @@ class ClientStorage:
...
@@ -688,11 +694,19 @@ class ClientStorage:
specified by the given object id and version, if they exist;
specified by the given object id and version, if they exist;
otherwise a KeyError is raised.
otherwise a KeyError is raised.
"""
"""
p
=
self
.
_cache
.
load
(
oid
,
version
)
self
.
_lock
.
acquire
()
# for atomic processing of invalidations
if
p
:
try
:
return
p
p
=
self
.
_cache
.
load
(
oid
,
version
)
if
p
:
return
p
finally
:
self
.
_lock
.
release
()
if
self
.
_server
is
None
:
if
self
.
_server
is
None
:
raise
ClientDisconnected
()
raise
ClientDisconnected
()
# If an invalidation for oid comes in during zeoLoad, that's OK
# because we'll get oid's new state.
p
,
s
,
v
,
pv
,
sv
=
self
.
_server
.
zeoLoad
(
oid
)
p
,
s
,
v
,
pv
,
sv
=
self
.
_server
.
zeoLoad
(
oid
)
self
.
_cache
.
checkSize
(
0
)
self
.
_cache
.
checkSize
(
0
)
self
.
_cache
.
store
(
oid
,
p
,
s
,
v
,
pv
,
sv
)
self
.
_cache
.
store
(
oid
,
p
,
s
,
v
,
pv
,
sv
)
...
@@ -708,9 +722,13 @@ class ClientStorage:
...
@@ -708,9 +722,13 @@ class ClientStorage:
If no version modified the object, return an empty string.
If no version modified the object, return an empty string.
"""
"""
v
=
self
.
_cache
.
modifiedInVersion
(
oid
)
self
.
_lock
.
acquire
()
if
v
is
not
None
:
try
:
return
v
v
=
self
.
_cache
.
modifiedInVersion
(
oid
)
if
v
is
not
None
:
return
v
finally
:
self
.
_lock
.
release
()
return
self
.
_server
.
modifiedInVersion
(
oid
)
return
self
.
_server
.
modifiedInVersion
(
oid
)
def
new_oid
(
self
):
def
new_oid
(
self
):
...
@@ -847,16 +865,20 @@ class ClientStorage:
...
@@ -847,16 +865,20 @@ class ClientStorage:
if
transaction
is
not
self
.
_transaction
:
if
transaction
is
not
self
.
_transaction
:
return
return
try
:
try
:
self
.
_lock
.
acquire
()
# for atomic processing of invalidations
try
:
self
.
_update_cache
()
finally
:
self
.
_lock
.
release
()
if
f
is
not
None
:
if
f
is
not
None
:
f
()
f
()
tid
=
self
.
_server
.
tpc_finish
(
self
.
_serial
)
tid
=
self
.
_server
.
tpc_finish
(
self
.
_serial
)
self
.
_cache
.
setLastTid
(
tid
)
r
=
self
.
_check_serials
()
r
=
self
.
_check_serials
()
assert
r
is
None
or
len
(
r
)
==
0
,
"unhandled serialnos: %s"
%
r
assert
r
is
None
or
len
(
r
)
==
0
,
"unhandled serialnos: %s"
%
r
self
.
_update_cache
()
self
.
_cache
.
setLastTid
(
tid
)
finally
:
finally
:
self
.
end_transaction
()
self
.
end_transaction
()
...
@@ -866,6 +888,8 @@ class ClientStorage:
...
@@ -866,6 +888,8 @@ class ClientStorage:
This iterates over the objects in the transaction buffer and
This iterates over the objects in the transaction buffer and
update or invalidate the cache.
update or invalidate the cache.
"""
"""
# Must be called with _lock already acquired.
self
.
_cache
.
checkSize
(
self
.
_tbuf
.
get_size
())
self
.
_cache
.
checkSize
(
self
.
_tbuf
.
get_size
())
try
:
try
:
self
.
_tbuf
.
begin_iterate
()
self
.
_tbuf
.
begin_iterate
()
...
@@ -912,10 +936,13 @@ class ClientStorage:
...
@@ -912,10 +936,13 @@ class ClientStorage:
"""Storage API: undo a transaction, writing directly to the storage."""
"""Storage API: undo a transaction, writing directly to the storage."""
if
self
.
_is_read_only
:
if
self
.
_is_read_only
:
raise
POSException
.
ReadOnlyError
()
raise
POSException
.
ReadOnlyError
()
# XXX what are the sync issues here?
oids
=
self
.
_server
.
undo
(
transaction_id
)
oids
=
self
.
_server
.
undo
(
transaction_id
)
for
oid
in
oids
:
self
.
_lock
.
acquire
()
self
.
_cache
.
invalidate
(
oid
,
''
)
try
:
for
oid
in
oids
:
self
.
_cache
.
invalidate
(
oid
,
''
)
finally
:
self
.
_lock
.
release
()
return
oids
return
oids
def
undoInfo
(
self
,
first
=
0
,
last
=-
20
,
specification
=
None
):
def
undoInfo
(
self
,
first
=
0
,
last
=-
20
,
specification
=
None
):
...
@@ -969,15 +996,19 @@ class ClientStorage:
...
@@ -969,15 +996,19 @@ class ClientStorage:
# oid, version pairs. The DB's invalidate() method expects a
# oid, version pairs. The DB's invalidate() method expects a
# dictionary of oids.
# dictionary of oids.
# versions maps version names to dictionary of invalidations
self
.
_lock
.
acquire
()
versions
=
{}
try
:
for
oid
,
version
in
invs
:
# versions maps version names to dictionary of invalidations
d
=
versions
.
setdefault
(
version
,
{})
versions
=
{}
self
.
_cache
.
invalidate
(
oid
,
version
=
version
)
for
oid
,
version
in
invs
:
d
[
oid
]
=
1
d
=
versions
.
setdefault
(
version
,
{})
if
self
.
_db
is
not
None
:
self
.
_cache
.
invalidate
(
oid
,
version
=
version
)
for
v
,
d
in
versions
.
items
():
d
[
oid
]
=
1
self
.
_db
.
invalidate
(
d
,
version
=
v
)
if
self
.
_db
is
not
None
:
for
v
,
d
in
versions
.
items
():
self
.
_db
.
invalidate
(
d
,
version
=
v
)
finally
:
self
.
_lock
.
release
()
def
endVerify
(
self
):
def
endVerify
(
self
):
"""Server callback to signal end of cache validation."""
"""Server callback to signal end of cache validation."""
...
...
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