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

Recognize byte slice for key argument in cluster client hash slot computation #3049

Merged
merged 4 commits into from
Nov 21, 2024

Conversation

LINKIWI
Copy link
Contributor

@LINKIWI LINKIWI commented Jul 13, 2024

This PR is mildly related to #3048.

The cluster client uses the command type to determine the expected key position in the command arguments slice to compute the hash slot. This enables the client to properly send the command to the node that owns that slot, according to the cached cluster topology state.

For generic commands assembled with the Do() API, the logic falls back to assuming the key is at position 1. Though this is a reasonable assumption, it depends on the argument to be of string type; []byte type arguments are not converted to strings, which results in an incorrect slot computation, thus forcing (in most cases) a double round trip caused by response to a MOVED redirection.

This PR adds a []byte type case for key string serialization, so that the generic commands passed as byte slices yield the correct cluster hash slot.

@LINKIWI LINKIWI changed the title Recognize byte slice for key argument in cluster client hash computation Recognize byte slice for key argument in cluster client hash slot computation Jul 13, 2024
@monkey92t
Copy link
Collaborator

It seems that you have restricted modifications to your PR code. You can either open the permissions or resolve the conflicts yourself.

@LINKIWI LINKIWI force-pushed the command-key-heuristic-bytes branch from e1f8ca8 to 7e90536 Compare July 13, 2024 11:42
@LINKIWI
Copy link
Contributor Author

LINKIWI commented Jul 13, 2024

It seems that you have restricted modifications to your PR code. You can either open the permissions or resolve the conflicts yourself.

Done! Rebased and conflicts resolved

@monkey92t
Copy link
Collaborator

@ofekshenawa merge?

@LINKIWI
Copy link
Contributor Author

LINKIWI commented Jul 22, 2024

Is it possible to merge this? This PR fixes a pretty significant performance bug for us. Thanks!

cc @vladvildanov @ofekshenawa

@LINKIWI LINKIWI force-pushed the command-key-heuristic-bytes branch from 35ae45e to 3cd7c33 Compare July 31, 2024 11:35
@LINKIWI
Copy link
Contributor Author

LINKIWI commented Jul 31, 2024

@ofekshenawa I rebased this branch and the build is now green. Are we good to merge? Thanks.

@LINKIWI
Copy link
Contributor Author

LINKIWI commented Oct 17, 2024

@vladvildanov @ofekshenawa Are you able to help with this merge? We have been running this patch in production for several months and have confirmed that it fixes the issue in the PR description.

@ofekshenawa ofekshenawa merged commit fc32d0a into redis:master Nov 21, 2024
10 checks passed
@ofekshenawa
Copy link
Collaborator

@LINKIWI Sorry for the delay, approved and merged!

@LINKIWI LINKIWI mentioned this pull request Feb 21, 2025
ndyakov pushed a commit that referenced this pull request Feb 21, 2025
…putation (#3049)

Co-authored-by: Vladyslav Vildanov <117659936+vladvildanov@users.noreply.github.com>
Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
ndyakov added a commit that referenced this pull request Feb 21, 2025
* Add guidance on unstable RESP3 support for RediSearch commands to README (#3177)

* Add UnstableResp3 to docs

* Add RawVal and RawResult to wordlist

* Explain more about SetVal

* Add UnstableResp to wordlist

* Eliminate redundant dial mutex causing unbounded connection queue contention (#3088)

* Eliminate redundant dial mutex causing unbounded connection queue contention

* Dialer connection timeouts unit test

---------

Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>

* SortByWithCount FTSearchOptions fix (#3201)

* SortByWithCount FTSearchOptions fix

* FTSearch test fix

* Another FTSearch test fix

* Another FTSearch test fix

---------

Co-authored-by: Christopher Golling <Chris.Golling@aexp.com>

* Fix race condition in clusterNodes.Addrs() (#3219)

Resolve a race condition in the clusterNodes.Addrs() method.
Previously, the method returned a reference to a string slice, creating
the potential for concurrent reads by the caller while the slice was
being modified by the garbage collection process.

Co-authored-by: Nedyalko Dyakov <nedyalko.dyakov@gmail.com>

* chore: fix some comments (#3226)

Signed-off-by: zhuhaicity <zhuhai@52it.net>
Co-authored-by: Nedyalko Dyakov <nedyalko.dyakov@gmail.com>

* fix(aggregate, search): ft.aggregate bugfixes (#3263)

* fix: rearange args for ft.aggregate

apply should be before any groupby or sortby

* improve test

* wip: add scorer and addscores

* enable all tests

* fix ftsearch with count test

* make linter happy

* Addscores is available in later redisearch releases.

For safety state it is available in redis ce 8

* load an apply seem to break scorer and addscores

* fix: add unstableresp3 to cluster client (#3266)

* fix: add unstableresp3 to cluster client

* propagate unstableresp3

* proper test that will ignore error, but fail if client panics

* add separate test for clusterclient constructor

* fix: flaky ClientKillByFilter test (#3268)

* Reinstate read-only lock on hooks access in dialHook (#3225)

* use limit when limitoffset is zero (#3275)

* remove redis 8 comments

* update package versions

* use latest golangci-lint

* fix(search&aggregate):fix error overwrite and typo  #3220 (#3224)

* fix (#3220)

* LOAD has NO AS param(https://redis.io/docs/latest/commands/ft.aggregate/)

* fix typo: WITHCOUT -> WITHCOUNT

* fix (#3220):

    * Compatible with known RediSearch issue in test

* fix (#3220)

    * fixed the calculation bug of the count of load params

* test should not include special condition

* return errors when they occur

---------

Co-authored-by: Nedyalko Dyakov <nedyalko.dyakov@gmail.com>
Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>

* Recognize byte slice for key argument in cluster client hash slot computation (#3049)

Co-authored-by: Vladyslav Vildanov <117659936+vladvildanov@users.noreply.github.com>
Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>

---------

Signed-off-by: zhuhaicity <zhuhai@52it.net>
Co-authored-by: ofekshenawa <104765379+ofekshenawa@users.noreply.github.com>
Co-authored-by: LINKIWI <LINKIWI@users.noreply.github.com>
Co-authored-by: Cgol9 <chris.golling@verizon.net>
Co-authored-by: Christopher Golling <Chris.Golling@aexp.com>
Co-authored-by: Shawn Wang <62313353+shawnwgit@users.noreply.github.com>
Co-authored-by: ZhuHaiCheng <zhuhai@52it.net>
Co-authored-by: herodot <54836727+bitsark@users.noreply.github.com>
Co-authored-by: Vladyslav Vildanov <117659936+vladvildanov@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants