Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
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
Jérome Perrin
neoppod
Commits
896900f1
Commit
896900f1
authored
Jul 23, 2012
by
Julien Muchembled
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup! client: fix cache invalidation during a load from a storage for the same oid
parent
20628341
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
18 deletions
+17
-18
neo/client/cache.py
neo/client/cache.py
+9
-6
neo/client/handlers/master.py
neo/client/handlers/master.py
+5
-10
neo/tests/threaded/test.py
neo/tests/threaded/test.py
+3
-2
No files found.
neo/client/cache.py
View file @
896900f1
...
@@ -225,7 +225,11 @@ class ClientCache(object):
...
@@ -225,7 +225,11 @@ class ClientCache(object):
def
invalidate
(
self
,
oid
,
tid
):
def
invalidate
(
self
,
oid
,
tid
):
"""Mark data record as being valid only up to given tid"""
"""Mark data record as being valid only up to given tid"""
try
:
item
=
self
.
_oid_dict
[
oid
][
-
1
]
item
=
self
.
_oid_dict
[
oid
][
-
1
]
except
KeyError
:
pass
else
:
if
item
.
next_tid
is
None
:
if
item
.
next_tid
is
None
:
item
.
next_tid
=
tid
item
.
next_tid
=
tid
else
:
else
:
...
@@ -236,10 +240,9 @@ def test(self):
...
@@ -236,10 +240,9 @@ def test(self):
cache
=
ClientCache
()
cache
=
ClientCache
()
self
.
assertEqual
(
cache
.
load
(
1
,
10
),
None
)
self
.
assertEqual
(
cache
.
load
(
1
,
10
),
None
)
self
.
assertEqual
(
cache
.
load
(
1
,
None
),
None
)
self
.
assertEqual
(
cache
.
load
(
1
,
None
),
None
)
self
.
assertRaises
(
KeyError
,
cache
.
invalidate
,
1
,
10
)
cache
.
invalidate
(
1
,
10
)
data
=
'5'
,
5
,
10
data
=
'5'
,
5
,
10
# 2 identical stores happens if 2 threads got a cache miss at the same time
# 2 identical stores happens if 2 threads got a cache miss at the same time
# (which currently never happens in NEO, due to a lock)
cache
.
store
(
1
,
*
data
)
cache
.
store
(
1
,
*
data
)
cache
.
store
(
1
,
*
data
)
cache
.
store
(
1
,
*
data
)
self
.
assertEqual
(
cache
.
load
(
1
,
10
),
data
)
self
.
assertEqual
(
cache
.
load
(
1
,
10
),
data
)
...
...
neo/client/handlers/master.py
View file @
896900f1
...
@@ -110,10 +110,7 @@ class PrimaryNotificationsHandler(BaseHandler):
...
@@ -110,10 +110,7 @@ class PrimaryNotificationsHandler(BaseHandler):
# was modified).
# was modified).
continue
continue
# Update ex-latest value in cache
# Update ex-latest value in cache
try
:
cache
.
invalidate
(
oid
,
tid
)
cache
.
invalidate
(
oid
,
tid
)
except
KeyError
:
pass
if
data
is
not
None
:
if
data
is
not
None
:
# Store in cache with no next_tid
# Store in cache with no next_tid
cache
.
store
(
oid
,
data
,
tid
,
None
)
cache
.
store
(
oid
,
data
,
tid
,
None
)
...
@@ -142,9 +139,7 @@ class PrimaryNotificationsHandler(BaseHandler):
...
@@ -142,9 +139,7 @@ class PrimaryNotificationsHandler(BaseHandler):
invalidate
=
app
.
_cache
.
invalidate
invalidate
=
app
.
_cache
.
invalidate
loading
=
app
.
_loading_oid
loading
=
app
.
_loading_oid
for
oid
in
oid_list
:
for
oid
in
oid_list
:
try
:
invalidate
(
oid
,
tid
)
invalidate
(
oid
,
tid
)
except
KeyError
:
if
oid
==
loading
:
if
oid
==
loading
:
app
.
_loading_oid
=
None
app
.
_loading_oid
=
None
app
.
_loading_invalidated
=
tid
app
.
_loading_invalidated
=
tid
...
...
neo/tests/threaded/test.py
View file @
896900f1
...
@@ -538,6 +538,7 @@ class Test(NEOThreadedTest):
...
@@ -538,6 +538,7 @@ class Test(NEOThreadedTest):
cluster
=
NEOCluster
()
cluster
=
NEOCluster
()
try
:
try
:
cluster
.
start
()
cluster
.
start
()
cache
=
cluster
.
client
.
_cache
# Initialize objects
# Initialize objects
t1
,
c1
=
cluster
.
getTransaction
()
t1
,
c1
=
cluster
.
getTransaction
()
c1
.
root
()[
'x'
]
=
x1
=
PCounter
()
c1
.
root
()[
'x'
]
=
x1
=
PCounter
()
...
@@ -571,7 +572,7 @@ class Test(NEOThreadedTest):
...
@@ -571,7 +572,7 @@ class Test(NEOThreadedTest):
# storage node to return original value of x, even if we
# storage node to return original value of x, even if we
# haven't processed yet any invalidation for x.
# haven't processed yet any invalidation for x.
x2
=
c2
.
root
()[
'x'
]
x2
=
c2
.
root
()[
'x'
]
c
luster
.
client
.
_c
ache
.
clear
()
# bypass cache
cache
.
clear
()
# bypass cache
self
.
assertEqual
(
x2
.
value
,
0
)
self
.
assertEqual
(
x2
.
value
,
0
)
finally
:
finally
:
master_client
()
master_client
()
...
@@ -592,7 +593,7 @@ class Test(NEOThreadedTest):
...
@@ -592,7 +593,7 @@ class Test(NEOThreadedTest):
l1
.
release
()
l1
.
release
()
l2
.
acquire
()
l2
.
acquire
()
x2
.
_p_deactivate
()
x2
.
_p_deactivate
()
c
luster
.
client
.
_cache
.
clear
(
)
c
ache
.
_remove
(
cache
.
_oid_dict
[
x2
.
_p_oid
].
pop
()
)
p
=
Patch
(
cluster
.
client
,
_loadFromStorage
=
_loadFromStorage
)
p
=
Patch
(
cluster
.
client
,
_loadFromStorage
=
_loadFromStorage
)
try
:
try
:
t
=
self
.
newThread
(
x2
.
_p_activate
)
t
=
self
.
newThread
(
x2
.
_p_activate
)
...
...
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