Skip to content
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

Introduce procedure mode selection for RedisGraph. #162

Merged
merged 6 commits into from
Aug 1, 2023

Conversation

haysch
Copy link
Contributor

@haysch haysch commented Jul 27, 2023

Problem

It is not possible to use GraphCache for replicas-only connections.
If GraphCache.GetCachedData is invoked, the following exception will be thrown

StackExchange.Redis.RedisServerException: READONLY You can't write against a read only replica.
   at NRedisStack.Auxiliary.ExecuteAsync(IDatabaseAsync db, SerializedCommand command)
   at NRedisStack.GraphCommandsAsync.QueryAsync(String graphName, String query, Nullable`1 timeout)
   at NRedisStack.GraphCommandsAsync.CallProcedureAsync(String graphName, String procedure, IEnumerable`1 args, Dictionary`2 kwargs)
   at NRedisStack.GraphCommandsAsync.CallProcedureAsync(String graphName, String procedure)

Context

Current implementation uses Query and QueryAsync for every CALL PROCEDURE.
However, as procedures can be defined as write or read (as defined by dbms.procedures()), it would make sense to be able to select mode.

Solution

Add option to specify procedures as Read or Write when calling CallProcedure and CallProcedureAsync.

Discussion

I opted to go for the enum approach, and specify ProcedureMode.Write as default to avoid breaking existing use.
One could instead go with a new CallReadProcedure and CallReadProcedureAsync.

* Add option to specify procedure mode as specified by `dbms.procedures()`.
* Refactor `GraphCacheList` to use READ mode for `db.labels()`, `db.propertyKeys()`, and `db.relationshipTypes()` in `GraphCache`.
@codecov-commenter
Copy link

codecov-commenter commented Jul 27, 2023

Codecov Report

Patch coverage: 96.96% and project coverage change: +0.17% 🎉

Comparison is base (78be574) 93.82% compared to head (08238a8) 93.99%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #162      +/-   ##
==========================================
+ Coverage   93.82%   93.99%   +0.17%     
==========================================
  Files          82       82              
  Lines        5082     5080       -2     
  Branches      476      479       +3     
==========================================
+ Hits         4768     4775       +7     
+ Misses        185      177       -8     
+ Partials      129      128       -1     
Files Changed Coverage Δ
src/NRedisStack/Graph/GraphCacheList.cs 97.36% <94.73%> (-2.64%) ⬇️
src/NRedisStack/Graph/GraphCommands.cs 94.44% <100.00%> (+7.30%) ⬆️
src/NRedisStack/Graph/GraphCommandsAsync.cs 94.44% <100.00%> (+7.30%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@shacharPash
Copy link
Contributor

Hi @haysch, thanks for your contribution!
I hope to go through the PR in the coming days.
In the meantime, I noticed that the coverage has dropped a bit, can you fix it?

@haysch
Copy link
Contributor Author

haysch commented Jul 27, 2023

Sure thing, will look into it as soon as possible.

Please let me know what you think of the procedure mode discriminator.
As stated I was a bit in doubt what would fit best - an enum or a new method.

Copy link
Contributor

@shacharPash shacharPash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks again for your contribution, looks good!
I wrote some comments and questions about the code. I would appreciate it if you could answer my questions and change what is needed :)

Copy link
Contributor Author

@haysch haysch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First batch of answers.
Will take a look at the remaining suggestions later :)

@haysch
Copy link
Contributor Author

haysch commented Jul 31, 2023

Is it possible to retry the test run without pushing a dummy commit?
It seems like something had gone wrong in a completely unrelated test 🤔

@shacharPash
Copy link
Contributor

@slorello89 do you want to take a look?

@shacharPash shacharPash requested a review from slorello89 August 1, 2023 08:38
@shacharPash shacharPash added the bug Something isn't working label Aug 1, 2023
Copy link
Contributor

@shacharPash shacharPash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@shacharPash shacharPash merged commit 6c9ea15 into redis:master Aug 1, 2023
@haysch haysch deleted the graph/procedure-mode branch August 1, 2023 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants