-
Notifications
You must be signed in to change notification settings - Fork 49
update internal cached mapping upon graph version change #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
1d3b241
update internal cached mapping upon graph version change
swilly22 aa9c89d
test cache sync
swilly22 10c69cb
maintain graph version
swilly22 535524f
print require version on arity exception
swilly22 07e677f
Merge branch 'master' into graph-version
swilly22 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class VersionMismatchException(Exception): | ||
def __init__(self, version): | ||
self.version = version | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -228,5 +228,75 @@ def test_query_timeout(self): | |
# Expecting an error. | ||
pass | ||
|
||
def test_cache_sync(self): | ||
# This test verifies that client internal graph schema cache stays | ||
# in sync with the graph schema | ||
# | ||
# Client B will try to get Client A out of sync by: | ||
# 1. deleting the graph | ||
# 2. reconstructing the graph in a different order, this will casuse | ||
# a differance in the current mapping between string IDs and the | ||
# mapping Client A is aware of | ||
# | ||
# Client A should pick up on the changes by comparing graph versions | ||
# and resyncing its cache. | ||
|
||
A = Graph('cache-sync', self.r) | ||
B = Graph('cache-sync', self.r) | ||
|
||
# Build order: | ||
# 1. introduce label 'L' and 'K' | ||
# 2. introduce attribute 'x' and 'q' | ||
# 3. introduce relationship-type 'R' and 'S' | ||
|
||
A.query("CREATE (:L)") | ||
B.query("CREATE (:K)") | ||
A.query("MATCH (n) SET n.x = 1") | ||
B.query("MATCH (n) SET n.q = 1") | ||
A.query("MATCH (n) CREATE (n)-[:R]->()") | ||
B.query("MATCH (n) CREATE (n)-[:S]->()") | ||
|
||
# Cause client A to populate its cache | ||
A.query("MATCH (n)-[e]->() RETURN n, e") | ||
|
||
assert(len(A._labels) == 2) | ||
assert(len(A._properties) == 2) | ||
assert(len(A._relationshipTypes) == 2) | ||
assert(A._labels[0] == 'L') | ||
assert(A._labels[1] == 'K') | ||
assert(A._properties[0] == 'x') | ||
assert(A._properties[1] == 'q') | ||
assert(A._relationshipTypes[0] == 'R') | ||
assert(A._relationshipTypes[1] == 'S') | ||
|
||
# Have client B reconstruct the graph in a different order. | ||
B.delete() | ||
|
||
# Build order: | ||
# 1. introduce relationship-type 'R' | ||
# 2. introduce label 'L' | ||
# 3. introduce attribute 'x' | ||
Comment on lines
+276
to
+278
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see logic below |
||
B.query("CREATE ()-[:S]->()") | ||
B.query("CREATE ()-[:R]->()") | ||
B.query("CREATE (:K)") | ||
B.query("CREATE (:L)") | ||
B.query("MATCH (n) SET n.q = 1") | ||
B.query("MATCH (n) SET n.x = 1") | ||
|
||
# A's internal cached mapping is now out of sync | ||
# issue a query and make sure A's cache is synced. | ||
A.query("MATCH (n)-[e]->() RETURN n, e") | ||
|
||
assert(len(A._labels) == 2) | ||
assert(len(A._properties) == 2) | ||
assert(len(A._relationshipTypes) == 2) | ||
assert(A._labels[0] == 'K') | ||
assert(A._labels[1] == 'L') | ||
assert(A._properties[0] == 'q') | ||
assert(A._properties[1] == 'x') | ||
assert(A._relationshipTypes[0] == 'S') | ||
assert(A._relationshipTypes[1] == 'R') | ||
|
||
if __name__ == '__main__': | ||
unittest.main() | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use
version
only when server supports this feature, for older version of RedisGraph this will trigger arity error