Hi Bill,

On Mar 3, 3:54 pm, Bill Moseley <mose...@hank.org> wrote:
> On Thu, Mar 3, 2011 at 9:54 AM, Felipe Cerqueira <skylaz...@gmail.com>wrote:
>
> > Hi,
>
> > Its works for me on version 0.45 with C.
>
> Well, perhaps I'm not configuring the client correctly.  See below.
>
>
>
> > I didnt like of this behavior but its works.
>
> > The concept of master and slave dont exist. So, if its get a error
> > trying to send data to the hash(key)->server, its dont send data to
> > the others server(s).
>
> Are you saying that even with " MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS" set
> to 1 if the first server write fails then it won't write to the second?
>  That is, once a server fails only reads work?


First of all, replication is only for write. Internally, its wont ask
for a second server.

About your question, its really wont replicate the data if fails on
first server. You can see it on the source code of libmemcached:

See: http://goo.gl/JSSro

I dont like this behaivor too.

>
> Here's a simple test script using the most recent Perl version with output
> below.  Am I not setting this up correctly?
>
> use Memcached::libmemcached qw( :memcached_behavior_t );
> use strict;
> use warnings;
>
> my $memc = Memcached::libmemcached->new;
> $memc->memcached_behavior_set( MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS() => 1
> );
>
> $memc->memcached_server_add( 'localhost', 11211 );
> $memc->memcached_server_add( 'localhost', 11212 );
>
> my $mem1 = Memcached::libmemcached->new;
> $mem1->memcached_server_add( 'localhost', 11211 );
>
> my $mem2 = Memcached::libmemcached->new;
> $mem2->memcached_server_add( 'localhost', 11212 );
>
> printf "Running libmemcached version %s\n",
>     Memcached::libmemcached::memcached_lib_version();
>


The replication only works with binary mode. Did you set it up?
And, remember, this feature is only for replication data, not
consulting (get).

I have tested on libmemcached with C. I dont known about perl.



> for ( 1 .. 8 ) {
>
>     my $id = int rand 1000;
>
>     print "\n============= key $id =============\n";
>     $memc->memcached_set( $id, 1, 10 )
>         || die 'set failed "' . $memc->errstr . "'\n";
>
>     my ( $flag, $rc );
>
>     $mem1->memcached_get( $id, $flag, $rc )
>         && print "found in mem1\n";
>
>     $mem2->memcached_get( $id, $flag, $rc )
>         && print "found in mem2\n";
>
> }
>
> Running this I see -- not it's only finding the key in one server.
>
> Running libmemcached version 0.44
>
> ============= key 869 =============
> found in mem2
>
> ============= key 321 =============
> found in mem1
>
> ============= key 618 =============
> found in mem1
>
> ============= key 234 =============
> found in mem2
>
> ============= key 667 =============
> found in mem1
>
> ============= key 54 =============
> found in mem2
>
> ============= key 441 =============
> found in mem1
>
> ============= key 178 =============
> found in mem1
>
> One thing I always find odd is if I don't have Memcached running I get:
>
> set failed "SYSTEM ERROR Success'
>
> Does that mean a successful system error? ;)
>
> --
> Bill Moseley
> mose...@hank.org

Reply via email to