Skip to content

Commit

Permalink
fix cluster mode with keyless command
Browse files Browse the repository at this point in the history
  • Loading branch information
YaacovHazan committed Jun 20, 2023
1 parent 5e6175f commit 9cd9c82
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
9 changes: 4 additions & 5 deletions client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,15 @@ bool client::create_arbitrary_request(unsigned int command_index, struct timeval

benchmark_debug_log("%s: %s:\n", m_connections[conn_id]->get_readable_id(), cmd.command.c_str());

unsigned long long key_index;
get_key_response res = get_key_for_conn(command_index, conn_id, &key_index);
/* If key not available for this connection, we have a bug of sending partial request */
assert(res == available_for_conn);

for (unsigned int i = 0; i < cmd.command_args.size(); i++) {
const command_arg* arg = &cmd.command_args[i];
if (arg->type == const_type) {
cmd_size += m_connections[conn_id]->send_arbitrary_command(arg);
} else if (arg->type == key_type) {
unsigned long long key_index;
get_key_response res = get_key_for_conn(command_index, conn_id, &key_index);
/* If key not available for this connection, we have a bug of sending partial request */
assert(res == available_for_conn);
cmd_size += m_connections[conn_id]->send_arbitrary_command(arg, m_key_buffer, m_key_len);
} else if (arg->type == data_type) {
unsigned int value_len;
Expand Down
10 changes: 8 additions & 2 deletions cluster_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,16 @@ get_key_response cluster_client::get_key_for_conn(unsigned int command_index, un
}

bool cluster_client::create_arbitrary_request(unsigned int command_index, struct timeval& timestamp, unsigned int conn_id) {
/* In arbitrary request, where we send the command arg by arg, we need to check if the
* generated key belongs to this connection before starting to send it */
/* In arbitrary request, where we send the command arg by arg, we need to check for a key command,
* if the generated key belongs to this connection before starting to send it */
assert(m_key_index_pools[conn_id]->empty());

/* keyless command can be used by any connection */
if (get_arbitrary_command(command_index).keys_count == 0) {
client::create_arbitrary_request(command_index, timestamp, conn_id);
return true;
}

unsigned long long key_index;
get_key_response res = get_key_for_conn(command_index, conn_id, &key_index);

Expand Down

0 comments on commit 9cd9c82

Please sign in to comment.