-
Notifications
You must be signed in to change notification settings - Fork 222
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
Enable arbitrary commands to be run on cluster mode #117
Enable arbitrary commands to be run on cluster mode #117
Conversation
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.
@filipecosta90 This looks good to me, with a few minor changes (and we'll need to rebase all the commits). In your example above you only specify a single __key__
, I guess there should be no problem to use an arbitrary number of __key__
and __data__
arguments right?
Yes, assuming that the keys are all in the same slot ( given that we request for a connection based on the key ). I'll make that change and mention that the first key position will always be the one used by memtier to internal map the command to the proper shard connection. WDYT? |
20fd759
to
631b731
Compare
c627c75
to
e3cac2f
Compare
3e9ef61
to
6cb6eef
Compare
6cb6eef
to
3ab8c0f
Compare
@yossigo I've added the multi-placeholder test on the last commit. I believe all issues have been solved and we're ready to review :) |
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.
@filipecosta90 Had a quick look, seems OK to me.
@YaacovHazan Any other inputs?
@filipecosta90 Looks good. I see that in the example test you are still using one Did we test it? As far as I remember when we are running with |
@YaacovHazan with the following example:
the expected CROSSSLOT error is replied:
I believe this is the expected behavior correct? |
@YaacovHazan I've added an extra test for multi-key placeholders in 6ef066a on the tests we confirm that the number of requests matches the expected. |
@YaacovHazan / @yossigo followed the recommendations and key placeholder is only allowed to be used once per command. |
@filipecosta90 why did you add "Don't fill key_index_pool for other connections on cluster client" commit, this is by design |
@YaacovHazan if we kept the code as is it hanged indefinitely given we were generating random keys that did not belong to that slot and then stopped prior generating any other key for that connection. As soon as I removed the check for total generated keys that included the keys that were buffered we were then issuing more commands that were required. The solution, ( proper one IMHO ) is not to buffer any key that does not belong to that conn. In this manner, we've solved both issues. |
@filipecosta90 assuming Cluster Mode with SET/GET (1 key command), the idea is that you as a client have some key generator based on the user requirements. Once you generated a key you should deliver it, if currently, you are in a context of a connection that the key does not belong to, it doesn't mean you can't or don't want to send it. You should use it but with the right connection. If we were not connection driven, you could think of it as you have some basic component that generates keys and sends them with the right connection based on the current Cluster topology (and not that one connection put keys for another connection). Otherwise, you are impacting the randomization of the keys based on the connection (you will use more keys that route to a good connection than a bad one). Now for Cluster with Arbitrary-Command (Multiple keys), the current implementation will not work well and will cause the client to hang. As I said at the early stage of this PR, we should think and consider what is the right way to handle that. |
@YaacovHazan given arbitrary commands won't allow multiple key placeholders as in the current implementation I guess the only missing concern that is still to be addressed is the part of dropping the keys from different slots when not in arbitrary command. If we fix it IMHO we can move forward with this PR without compromising any of the current usage of cluster mode. Agree? Trying to see if we can make this as simple as possible to merge and have this feature. We need this so much! =) |
@filipecosta90 ,Not sure I got you about the last concern. I think that once we limit the arbitrary command to one key placeholder, the PR is ok. Two more notes:
|
…request count(when defined)
… bellow request count(when defined)" This reverts commit 19c079b.
…y_command_hset and test_default_arbitrary_command_hset_multi_data_placeholders
…request count(when defined)
@YaacovHazan I've enabled all tests and updated based upon:
All is green now. Can you check it? |
protocol.cpp
Outdated
if (current_arg->data.length() != strlen(KEY_PLACEHOLDER)) { | ||
benchmark_error_log("error: key placeholder can't combined with other data\n"); | ||
return false; | ||
} | ||
|
||
if (key_placeholder_count > 1) { |
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.
This should apply only to cluster mode. The non-cluster mode does support more than one key.
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.
Also, "IMOH just dropping keys is not the right solution and if yes, maybe only for this case of arbitrary command in Cluster mode." was relevant for the initial PR where we allowed more than one key.
Since we agree to limited the arbitrary command in cluster mode for one key (for now) there is no need to "play" with the pool
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.
This should apply only to cluster mode. The non-cluster mode does support more than one key.
@YaacovHazan both for standalone and cluster versions we don't allow for more than one key placeholder.
memtier_benchmark.cpp
Outdated
@@ -1293,6 +1290,11 @@ int main(int argc, char *argv[]) | |||
exit(1); | |||
} | |||
|
|||
// Cluster mode supports only a single key commands | |||
if (cfg.cluster_mode && cfg.arbitrary_commands->at(i).keys_count != 1) { |
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.
@YaacovHazan we should change from !=1
to >1
.
Example of a failing command that should work:
$ ./memtier_benchmark --cluster --command="SET key __data__" -p 30001
error: Cluster mode supports only a single key commands
and another keyless one
./memtier_benchmark --cluster --command="PUBLISH channel __data__" -p 30001
error: Cluster mode supports only a single key commands
I'm including that example on CI and addressing it.
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.
@YaacovHazan I've added the test and confirmed behaviour is as expected with the code change.
Codecov Report
❗ 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. @@ Coverage Diff @@
## master #117 +/- ##
==========================================
- Coverage 56.87% 56.25% -0.62%
==========================================
Files 21 21
Lines 4283 4330 +47
==========================================
Hits 2436 2436
- Misses 1847 1894 +47
|
This PR enables running arbitrary commands on cluster mode and adds the required testing to it.
Example command:
Given it detected the issue in #204 it fixes it as well.