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
Joshua
zodb
Commits
151bdb3f
Commit
151bdb3f
authored
Jul 12, 2010
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Conflict errors didn't invalidate ZEO cache entries.
parent
58af1258
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
1 deletion
+76
-1
src/CHANGES.txt
src/CHANGES.txt
+3
-0
src/ZEO/ClientStorage.py
src/ZEO/ClientStorage.py
+1
-0
src/ZEO/tests/testZEO.py
src/ZEO/tests/testZEO.py
+72
-1
No files found.
src/CHANGES.txt
View file @
151bdb3f
...
...
@@ -45,6 +45,9 @@ Bugs fixed
invalidation transaction ids matched the cached transaction ids
should have been ignored.
- Conflict errors didn't invalidate ZEO cache entries.
3.10.0b1 (2010-05-18)
=====================
...
...
src/ZEO/ClientStorage.py
View file @
151bdb3f
...
...
@@ -917,6 +917,7 @@ class ClientStorage(object):
del
self
.
_serials
[:
l
]
for
oid
,
s
in
r
:
if
isinstance
(
s
,
Exception
):
self
.
_cache
.
invalidate
(
oid
,
None
)
raise
s
self
.
_seriald
[
oid
]
=
s
return
r
...
...
src/ZEO/tests/testZEO.py
View file @
151bdb3f
...
...
@@ -24,7 +24,7 @@ from ZODB.tests import StorageTestBase, BasicStorage, \
MTStorage
,
ReadOnlyStorage
,
IteratorStorage
,
RecoveryStorage
from
ZODB.tests.MinPO
import
MinPO
from
ZODB.tests.StorageTestBase
import
zodb_unpickle
from
ZODB.utils
import
p64
,
u64
from
zope.testing
import
renormalizing
import
doctest
...
...
@@ -1377,6 +1377,77 @@ You can specify the client label via a configuration file as well:
"""
def
invalidate_client_cache_entry_on_server_commit_error
():
"""
When the serials returned during commit includes an error, typically a
conflict error, invalidate the cache entry. This is important when
the cache is messed up.
>>> addr, _ = start_server()
>>> conn1 = ZEO.connection(addr)
>>> conn1.root.x = conn1.root().__class__()
>>> transaction.commit()
>>> conn1.root.x
{}
>>> cs = ZEO.ClientStorage.ClientStorage(addr, client='cache')
>>> conn2 = ZODB.connection(cs)
>>> conn2.root.x
{}
>>> conn2.close()
>>> cs.close()
>>> conn1.root.x['x'] = 1
>>> transaction.commit()
>>> conn1.root.x
{'x': 1}
Now, let's screw up the cache by making it have a last tid that is later than
the root serial.
>>> import ZEO.cache
>>> cache = ZEO.cache.ClientCache('cache-1.zec')
>>> cache.setLastTid(p64(u64(conn1.root.x._p_serial)+1))
>>> cache.close()
We'll also update the server so that it's last tid is newer than the cache's:
>>> conn1.root.y = 1
>>> transaction.commit()
>>> conn1.root.y = 2
>>> transaction.commit()
Now, if we reopen the client storage, we'll get the wrong root:
>>> cs = ZEO.ClientStorage.ClientStorage(addr, client='cache')
>>> conn2 = ZODB.connection(cs)
>>> conn2.root.x
{}
And, we'll get a conflict error if we try to modify it:
>>> conn2.root.x['y'] = 1
>>> transaction.commit() # doctest: +ELLIPSIS
Traceback (most recent call last):
...
ConflictError: ...
But, if we abort, we'll get up to date data and we'll see the changes.
>>> transaction.abort()
>>> conn2.root.x
{'x': 1}
>>> conn2.root.x['y'] = 1
>>> transaction.commit()
>>> sorted(conn2.root.x.items())
[('x', 1), ('y', 1)]
>>> cs.close()
>>> conn1.close()
"""
if
sys
.
version_info
>=
(
2
,
6
):
import
multiprocessing
...
...
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