-
Notifications
You must be signed in to change notification settings - Fork 14
feat: add replica connection support and fix silent crash on query timeout #281
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
Open
SantoshDhaladhuli
wants to merge
13
commits into
FalkorDB:main
Choose a base branch
from
SantoshDhaladhuli:feat/replica-connections-and-timeout-recovery
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d53154d
fix(schema): refresh GraphSchema cache on query execution to prevent …
SantoshDhaladhuli 8d363ce
Merge branch 'main' into fix/graph-schema-cache-stale-mappings-243
SantoshDhaladhuli 1a0dc3a
perf(schema): optimize hybrid schema refresh to avoid network calls o…
SantoshDhaladhuli 41a6240
test(async): instantiate connection pool in test_async_schema_cache_o…
SantoshDhaladhuli ce0d52d
refactor(schema): remove unreachable try-except IndexError blocks to …
SantoshDhaladhuli 1a7e6a3
feat: add replica connection support and fix silent crash on query ti…
SantoshDhaladhuli 7a6abab
fix: handle sentinel info probe connection errors gracefully
SantoshDhaladhuli 212affd
feat: add get_cluster_shards to deduce FalkorDB Cluster primary and r…
SantoshDhaladhuli 7ec0478
fix(cluster): ensure replica client resolution for primary-configured…
SantoshDhaladhuli 90153a0
test: boost patch test coverage for sentinel, cluster, and replica co…
SantoshDhaladhuli d5071f2
refactor(tests): move async query timeout test to tests/test_async_ti…
SantoshDhaladhuli 81082ee
fix(schema): invalidate schema cache on ro_query to ensure compact pr…
SantoshDhaladhuli 7d27f62
Merge branch 'main' into feat/replica-connections-and-timeout-recovery
SantoshDhaladhuli 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
Some comments aren't visible on the classic Files Changed page.
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
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 |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import inspect | ||
|
|
||
| import redis as sync_redis # type: ignore[import-not-found] | ||
| import redis.asyncio as redis # type: ignore[import-not-found] | ||
| from redis.asyncio.sentinel import Sentinel # type: ignore[import-not-found] | ||
|
|
||
|
|
||
| # detect if a connection is a sentinel | ||
| def Is_Sentinel(conn: redis.Redis) -> bool: | ||
| pool = conn.connection_pool | ||
| kwargs = pool.connection_kwargs.copy() | ||
|
|
||
| kwargs["ssl"] = pool.connection_class is redis.SSLConnection | ||
|
|
||
| if pool.connection_class is redis.UnixDomainSocketConnection: | ||
| kwargs["unix_socket_path"] = kwargs.pop("path") | ||
|
|
||
| accepted = inspect.signature(sync_redis.Redis.__init__).parameters | ||
| kwargs = {k: v for k, v in kwargs.items() if k in accepted} | ||
|
|
||
| info = sync_redis.Redis(**kwargs).info(section="server") | ||
| return "redis_mode" in info and info["redis_mode"] == "sentinel" | ||
|
|
||
|
|
||
| # create an async sentinel connection from a Redis connection | ||
| def Sentinel_Conn(conn: redis.Redis, ssl: bool): | ||
| pool = conn.connection_pool | ||
| kwargs = pool.connection_kwargs.copy() | ||
|
|
||
| kwargs["ssl"] = pool.connection_class is redis.SSLConnection | ||
|
|
||
| if pool.connection_class is redis.UnixDomainSocketConnection: | ||
| kwargs["unix_socket_path"] = kwargs.pop("path") | ||
|
|
||
| accepted = inspect.signature(sync_redis.Redis.__init__).parameters | ||
| probe_kwargs = {k: v for k, v in kwargs.items() if k in accepted} | ||
|
|
||
| sync_conn = sync_redis.Redis(**probe_kwargs) | ||
| masters = sync_conn.sentinel_masters() | ||
|
|
||
| if len(masters) != 1: | ||
| raise Exception("Multiple masters, require service name") | ||
|
|
||
| service_name = list(masters.keys())[0] | ||
|
|
||
| host = kwargs.get("host", "localhost") | ||
| port = kwargs.get("port", 6379) | ||
| sentinels_conns = [(host, port)] | ||
|
|
||
| sentinel_kwargs = {} | ||
| if "username" in kwargs: | ||
| sentinel_kwargs["username"] = kwargs["username"] | ||
| if "password" in kwargs: | ||
| sentinel_kwargs["password"] = kwargs["password"] | ||
| if ssl: | ||
| sentinel_kwargs["ssl"] = True | ||
|
|
||
| return ( | ||
| Sentinel(sentinels_conns, sentinel_kwargs=sentinel_kwargs, **kwargs), | ||
| service_name, | ||
| ) |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.