-
Notifications
You must be signed in to change notification settings - Fork 325
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
get/getMulti return RES_NOTFOUND after buffered increment with result RES_UNKNOWN_READ_FAILURE with OPT_BINARY_PROTOCOL #554
Comments
Thank you for the minimal repro! This is most likely a library issue rather than the php plugin code. What version of libmemcache are you using? Try libmemcache-awesome for more recent updates and bug fixes. |
I tested this example on:
I checked it in C language #include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <libmemcached/memcached.h>
int main(int argc, char *argv[])
{
char *key= "KEY";
char *value= "VALUE";
memcached_server_st *servers = NULL;
memcached_st *memc;
memcached_return rc;
uint64_t incr = UINT64_MAX;
size_t key_length = strlen(key);
char return_key[MEMCACHED_MAX_KEY];
size_t return_key_length;
char *return_value;
size_t return_value_length;
uint32_t flags;
const char* keys[] = {key};
size_t keys_length[] = {key_length};
memcached_server_st *memcached_servers_parse (const char *server_strings);
memc= memcached_create(NULL);
servers= memcached_server_list_append(servers, "127.0.0.1", 11211, &rc);
rc= memcached_server_push(memc, servers);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 1);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1);
rc= memcached_set(memc, key, key_length, value, strlen(value), (time_t)0, (uint32_t)0);
rc = memcached_increment_with_initial(memc, key, key_length, 1, 1, (time_t)600, &incr);
rc = memcached_mget(memc, keys, keys_length, 1);
return_value = memcached_fetch(memc, return_key, &return_key_length, &return_value_length, &flags, &rc);
fprintf(stdout,"Value: %s\n",return_value);
return_value = memcached_fetch(memc, return_key, &return_key_length, &return_value_length, &flags, &rc);
fprintf(stdout,"Value: %s\n",return_value);
memcached_quit(memc);
return 0;
} Expect:
Result:
libmemcached send request 1 TCP package for set, incr and get server memcached return 1 TCP package with 2 results:
I checked it in C language on Fedora 39 with libmemcached-awesome 1.1.4 memcached-1.6.21
libmemcached send request 2 TCP package:
server memcached return 1 TCP package with 2 results:
|
Another example: <?php
$key1 = 'KEY1';
$key2 = 'KEY2';
$value1 = 'VALUE1';
$value2 = 'VALUE2';
$memcached = new Memcached();
$memcached->addServer('127.0.0.1', '11212', 1);
$memcached->setOption( Memcached::OPT_BINARY_PROTOCOL, true);
$memcached->set($key1, $value1);
$memcached->setOption(Memcached::OPT_BUFFER_WRITES, true);
$memcached->setOption(Memcached::OPT_NOREPLY, true);
for ($i = 0; $i < 100; ++$i) {
$memcached->delete($key2);
}
echo 'get ', $key1, ' ', $memcached->get($key1), ' ', $memcached->getResultMessage(), "\n"; Expect:
Result:
Next execute result random:
C Language: #include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <libmemcached/memcached.h>
int main(int argc, char *argv[])
{
char *key1= "KEY1";
char *value1= "VALUE1";
char *key2= "KEY2";
char *value2= "VALUE2";
memcached_server_st *servers = NULL;
memcached_st *memc;
memcached_return rc;
size_t key1_length = strlen(key1);
size_t key2_length = strlen(key2);
char *return_value;
size_t return_value_length;
uint32_t flags;
memcached_server_st *memcached_servers_parse (const char *server_strings);
memc= memcached_create(NULL);
servers= memcached_server_list_append(servers, "127.0.0.1", 11211, &rc);
rc= memcached_server_push(memc, servers);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL, 1);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 1);
rc= memcached_set(memc, key1, key1_length, value1, strlen(value1), (time_t)0, (uint32_t)0);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1);
memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1);
for (int i = 0; i < 100; ++i) {
rc= memcached_delete(memc, key2, key2_length, (time_t)0);
}
return_value = memcached_get(memc, key1, key1_length, &return_value_length, &flags, &rc);
fprintf(stdout,"Value: %s\n",return_value); Expect:
Result:
Memcached to delete a non-existent key sometimes returns a response.
Sometimes there is no answer. Questions:
|
Hello!
Code:
Expect:
Result:
libmemcached send request 1 TCP package for set, incr and get
server memcached return 1 TCP package with 2 results:
But php-memcached for get return NOT FOUND
Text protocol:
Expect:
Result:
libmemcached send request 1 TCP package for incr and get
server memcached return 1 TCP package with 1 results:
The text was updated successfully, but these errors were encountered: