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

fix: handle no key commands in slot check #1207

Merged
merged 1 commit into from May 14, 2023

Conversation

dranikpg
Copy link
Contributor

@dranikpg dranikpg commented May 12, 2023

DF build currently gives this warning:

../src/server/main_service.cc: In member function ‘bool dfly::Service::CheckKeysOwnership(const dfly::CommandId*, facade::CmdArgList, dfly::ConnectionContext*)’:
../src/server/main_service.cc:625:49: warning: ‘keys_slot’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  625 |   if (!server_family_.cluster_config()->IsMySlot(keys_slot)) {

I first wanted to ignore it, but it seems that slot_id can actually be non initialized. Because even if cid->first_key_pos() > 0, the command itself can have 0 keys if it uses variadic keys. For example: EVAL {script} 0.

(Yes, it seems like we don't have any tests for this part yet)

Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
@dranikpg dranikpg requested a review from adiholden May 13, 2023 22:18
}
}
if (cross_slot) {
(*dfly_cntx)->SendError("-CROSSSLOT Keys in request don't hash to the same slot");
return false;
}
// Check keys slot is in my ownership
if (!server_family_.cluster_config()->IsMySlot(keys_slot)) {
if (keys_slot && !server_family_.cluster_config()->IsMySlot(*keys_slot)) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd use keys_slot.has_value(), but definitely your call.
Anyway, thanks for making this change!

@dranikpg dranikpg merged commit 3b003e3 into dragonflydb:main May 14, 2023
6 checks passed
@dranikpg dranikpg deleted the fix-slot-check branch May 28, 2023 09:17
romange pushed a commit that referenced this pull request Jun 1, 2023
Signed-off-by: Vladislav Oleshko <vlad@dragonflydb.io>
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.

None yet

2 participants