Hi Tim,
On some failures I'm getting $memc->errstr "SYSTEM ERROR Success". I
think the string should just be "SYSTEM ERROR" so I wonder if it's not
getting terminated correctly or if something is writing to the wrong
place in memory.
I'll attach a script, but the script starts a server, writes a few items
to the cache, then reads them back:
Fetched key 000001
Fetched key 000002
Fetched key 000003
Fetched key 000004
Fetched key 000005
Then I kill the memcached server and attempt to read again:
Fetched key 000001
Failed to fetch key '000002'. Error: [SUCCESS], errstr: [SOME ERRORS
WERE REPORTED]
Failed to fetch key '000003'. Error: [SUCCESS], errstr: [SYSTEM ERROR
Success]
Failed to fetch key '000004'. Error: [SUCCESS], errstr: [SYSTEM ERROR
Success]
Failed to fetch key '000005'. Error: [SUCCESS], errstr: [SYSTEM ERROR
Success]
What's odd is "SYSTEM ERROR Success". AFAIK, the returned string should
simply be "SYSTEM ERROR".
That first "SUCCESS" is from calling
$memc->memcached_strerror( $rc )
So, I'm not clear why that's returning SUCCESS instead of the system error.
It's also a bit odd that first fetch after killing the server returns ok
after I kill the memcached server.
Subject: | errstr.pl |
use strict;
use warnings;
use Memcached::libmemcached;
my $port = 12000;
my $items = 5;
# Start a server:
my $pid = fork();
exec( qw/ memcached -m 10 -p /, $port ) unless $pid;
sleep 1; # let server start
my $memc = Memcached::libmemcached->new;
$memc->memcached_server_add( 'localhost', $port );
$SIG{PIPE} = sub { warn "Received SIGPIPE: Ignoring\n" };
for ( 1 .. $items ) {
$memc->memcached_set( sprintf( '%06d', $_ ), { some => 'data' } )
|| die "failed set $!\n";
}
fetch_keys();
# Now kill memcached and sleep
#
print "kill pid $pid\n";
kill 1, $pid;
sleep 2;
print "fetching keys again\n";
fetch_keys();
sub fetch_keys {
for ( 1 .. $items ) {
my $key = sprintf( '%06d', $_ );
my ($flags, $rc );
my $value = $memc->memcached_get( $key, $flags, $rc );
print defined $value
? "Fetched key $key\n"
: sprintf("Failed to fetch key '$key'. Error: [%s], errstr: [%s]\n",
$memc->memcached_strerror( $rc ),
$memc->errstr,
);
}
}