Skip to content

Multiple KeyTuples support in Anna #46

Description

@authwork

@vsreekanti
Many thanks for your help.
I found KeyRequest can bring multiple KeyTuples in once transmission, so I try to upgrade it:

string vget_async(const vector<Key>& keys, int size) {
        # to simplify the process, or to jump the check of pending_get_response_map_
	//if (pending_get_response_map_.find(keys[0])
	//			== pending_get_response_map_.end()) {
		KeyRequest request;
		request.set_request_id(get_request_id());
		request.set_response_address(ut_.response_connect_address());
		request.set_type(RequestType::GET);
		for (int i = 0; i < size; i++) {
			KeyTuple* tp = request.add_tuples();
			tp->set_key(keys[i]);
		}
		try_request(request);
		return request.request_id();
	//}
	//return "";
}

When I set size = 1, it works normal; when it is larger than 1.
The request_id cannot match

# size = 1
time: 164087
throughput: 6.09433e-06
time: 1348
throughput: 0.00074184
time: 318
throughput: 0.00314465
staleness of one key: 12
10.1.2.1:0_9=?10.1.2.1:0_9
number of keys: 1
10.1.2.1:0_11=?10.1.2.1:0_11


# size = 2
time: 103791
throughput: 1.92695e-05
time: 56
throughput: 0.0357143
time: 310
throughput: 0.00645161
staleness of one key: 0
10.1.2.1:0_11=?10.1.2.1:0_7
number of keys: 1
=?10.1.2.1:0_11
staleness: 15
[libprotobuf FATAL /usr/local/include/google/protobuf/repeated_field.h:1522] CHECK failed: (index) < (current_size_):
terminate called after throwing an instance of 'google::protobuf::FatalException'
  what():  CHECK failed: (index) < (current_size_):
Aborted

Update:
I found the cause of this bug. It may not be related to the Multiple KeyTuples, but the receive function of batched put.
It is likes:

void receive(KvsClientInterface *client, int number) {
	vector<KeyResponse> responses = client->receive_async();
	while (responses.size() < number) {
		responses = client->receive_async();
		number = number - responses.size();
		if (number == 0)
			break;
	}
}

Update II:
The Python client said:

# PUT only supports one key operations, we only ever have to look at
# the first KeyTuple returned.

But I see user_request_handler goes through all tuples and handle all of them, then why it said PUT only supports one key operation?

 for (const auto &tuple : request.tuples()) {
    // first check if the thread is responsible for the key
    Key key = tuple.key();
    string payload = tuple.payload();
    ...
    else if (request_type == RequestType::PUT) {
           ...
    }
    ...
}

I have extended PUT operation like GET, but only the first key-value pair in the passed key vector is executed

x = client->vput_async(keys, values, count, LatticeType);
receive(client)
x = client->vget_async(keys, count);

only keys[0]'s value is returned.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions