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

Add support for MustObeyClient Module API #1582

Merged
merged 8 commits into from
Feb 10, 2025

Conversation

KarthikSubbarao
Copy link
Member

@KarthikSubbarao KarthikSubbarao commented Jan 18, 2025

This PR adds support for MustObeyClient Module API.

The purpose of this API is for Modules to handle commands / callbacks knowing whether commands are arriving from the primary client or AOF client and should never be rejected.

A use case is that Modules can have validation logic in command handlers which only should be executed on primary nodes. Replica nodes must obey commands replicated.

Signed-off-by: KarthikSubbarao <[email protected]>
Copy link

codecov bot commented Jan 18, 2025

Codecov Report

Attention: Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 71.00%. Comparing base (2d0b8e3) to head (93acad9).
Report is 50 commits behind head on unstable.

Files with missing lines Patch % Lines
src/module.c 25.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #1582      +/-   ##
============================================
+ Coverage     70.94%   71.00%   +0.05%     
============================================
  Files           121      121              
  Lines         65132    65181      +49     
============================================
+ Hits          46207    46279      +72     
+ Misses        18925    18902      -23     
Files with missing lines Coverage Δ
src/module.c 9.61% <25.00%> (+<0.01%) ⬆️

... and 22 files with indirect coverage changes

@madolson madolson added the major-decision-pending Major decision pending by TSC team label Jan 22, 2025
Signed-off-by: KarthikSubbarao <[email protected]>
Signed-off-by: KarthikSubbarao <[email protected]>
Signed-off-by: KarthikSubbarao <[email protected]>
Signed-off-by: Karthik Subbarao <[email protected]>
Signed-off-by: Karthik Subbarao <[email protected]>
Signed-off-by: Karthik Subbarao <[email protected]>
@madolson
Copy link
Member

madolson commented Feb 3, 2025

@valkey-io/core-team Please vote. This is a pretty straight forward API to give modules the ability to quickly check if they should apply the command and ignore checks because it's coming from a primary or AOF. Worth mentioning that this is more performant than ValkeyModule_GetContextFlags, since that command also checks for memory bounds.

@madolson madolson added major-decision-approved Major decision approved by TSC team and removed major-decision-pending Major decision pending by TSC team labels Feb 10, 2025
@madolson madolson merged commit 99e2dc9 into valkey-io:unstable Feb 10, 2025
50 checks passed
@enjoy-binbin enjoy-binbin added the release-notes This issue should get a line item in the release notes label Feb 10, 2025
enjoy-binbin added a commit to enjoy-binbin/valkey that referenced this pull request Mar 4, 2025
There is a timing issue in the test:
```
*** [err]: module RM_Call of expired key propagation in tests/unit/moduleapi/propagate.tcl
Expected '1' to be equal to '2' (context: type eval line 27 cmd {assert_equal [$replica propagate-test.obeyed] 2} proc ::test)
```

We should wait for sync, otherwise the replica may not be fully
synchronized before checking. The test was introduced in valkey-io#1582.

Signed-off-by: Binbin <[email protected]>
hwware pushed a commit that referenced this pull request Mar 4, 2025
There is a timing issue in the test:
```
*** [err]: module RM_Call of expired key propagation in tests/unit/moduleapi/propagate.tcl
Expected '1' to be equal to '2' (context: type eval line 27 cmd {assert_equal [$replica propagate-test.obeyed] 2} proc ::test)
```

We should wait for sync, otherwise the replica may not be fully
synchronized before checking. The test was introduced in #1582.

Signed-off-by: Binbin <[email protected]>
zuiderkwast pushed a commit that referenced this pull request Mar 18, 2025
There is a timing issue in the test:
```
*** [err]: module RM_Call of expired key propagation in tests/unit/moduleapi/propagate.tcl
Expected '1' to be equal to '2' (context: type eval line 27 cmd {assert_equal [$replica propagate-test.obeyed] 2} proc ::test)
```

We should wait for sync, otherwise the replica may not be fully
synchronized before checking. The test was introduced in #1582.

Signed-off-by: Binbin <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major-decision-approved Major decision approved by TSC team release-notes This issue should get a line item in the release notes
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants