Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Memcached-libmemcached CPAN distribution.

Report information
The Basics
Id: 41299
Status: stalled
Priority: 0/
Queue: Memcached-libmemcached

People
Owner: Nobody in particular
Requestors: moseley [...] hank.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.2101
Fixed in: (no value)



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, ); } }
Subject: Re: [rt.cpan.org #41299] On some failures I'm getting $memc->errstr "SYSTEM ERROR Success"
Date: Fri, 28 Nov 2008 20:18:46 +0000
To: Bill Moseley via RT <bug-Memcached-libmemcached [...] rt.cpan.org>
From: Tim Bunce <Tim.Bunce [...] pobox.com>
On Fri, Nov 28, 2008 at 01:58:46PM -0500, Bill Moseley via RT wrote: Show quoted text
> On some failures I'm getting $memc->errstr "SYSTEM ERROR Success".
Might be a while before I can work on it. Feel free to dig in and investigate yourself. Patches welcome! Commit bits freely given. Tim.
Tim, This is not a bug as I described it. You documented that you append the strerror(errno) to the message and that's what is happening. You have: if (lmc_state->last_return == MEMCACHED_ERRNO) sv_catpvf(RETVAL, " %s", strerror(lmc_state->last_errno)); but when the error is MEMCACHED_ERRNO then errno is not reflecting the error. Which is shown by the resulting (and somewhat conflicting) "SYSTEM ERROR Success". I'm not sure if that's libmemcached not saving errno correctly or if it's setting MEMCACHED_ERRNO when errno is really 0. Perhaps the simple solution is to just not add the message if errno is also 0. I'll try and dig deeper into libmemcached and see what's happening.
I'm going to close this (very old) ticket for now. Free free to reopen if it's still an issue with recent versions.
I could avoid appending strerror if lmc_state->last_return is 0, but that seems to be just treating the symptom rather than the cause. As a compromise I've appended "(last_error==0!)" instead. See https://github.com/timbunce/Memcached-libmemcached/commit/f203b090236b3231be8428a329f9f8d44127e447
Could you please retest with https://metacpan.org/release/WOLFSAGE/Memcached-libmemcached-1.001702 and see if this works for you? Thanks, -- Matthew Horsfall (alh)