Welcome! Log In Create A New Profile

Advanced

Which key is chosen when key duplicates exist in a cluster?

Posted by Granit 
Suppose one of the memcached machines in a cluster looses connection,
when asking for a key it is non existent on any other machine in the
cluster so
the client decides to create a new one, now the disconnected machine
is back.
Thus we have two machines with the same key, which key->value pair
would we get
when requesting this duplicated key?

- the one created the last?
- which ever server answers first?

thanks
Granit
I think you need to read up a little bit on memcached's entire strategy on
this:

http://code.google.com/p/memcached/wiki/FAQ#Cluster_Architecture_Questions

On Tue, Sep 14, 2010 at 7:03 PM, Granit <[email protected]> wrote:

> Suppose one of the memcached machines in a cluster looses connection,
> when asking for a key it is non existent on any other machine in the
> cluster so
> the client decides to create a new one, now the disconnected machine
> is back.
> Thus we have two machines with the same key, which key->value pair
> would we get
> when requesting this duplicated key?
>
> - the one created the last?
> - which ever server answers first?
>
> thanks
> Granit
>



--
awl
Thank you for the quick reply,
I did read that
> It is able to use the same hashing process to figure out key "foo" is on server B. It then directly requests key "foo" and gets back "barbaz".
So what happens when key "foo" exists on server A and B? I mean by
accident not deliberately. I am aware that duplications are not
supposed to happen.


On Sep 15, 12:09 am, Adam Lee <[email protected]> wrote:
> I think you need to read up a little bit on memcached's entire strategy on
> this:
>
> http://code.google.com/p/memcached/wiki/FAQ#Cluster_Architecture_Ques...
>
>
>
> On Tue, Sep 14, 2010 at 7:03 PM, Granit <[email protected]> wrote:
> > Suppose one of the memcached machines in a cluster looses connection,
> > when asking for a key it is non existent on any other machine in the
> > cluster so
> > the client decides to create a new one, now the disconnected machine
> > is back.
> > Thus we have two machines with the same key, which key->value pair
> > would we get
> > when requesting this duplicated key?
>
> > - the one created the last?
> > - which ever server answers first?
>
> > thanks
> > Granit
>
> --
> awl
Oh yeah,

I think my question would be answered in the not yet written:
> getting stale entries when a memcached server flaps in and out of the cluster

which is why I posted it here...

many thanks in advance

On Sep 15, 12:17 am, Granit <[email protected]> wrote:
> Thank you for the quick reply,
> I did read that> It is able to use the same hashing process to figure out key "foo" is on server B. It then directly requests key "foo" and gets back "barbaz".
>
> So what happens when key "foo" exists on server A and B? I mean by
> accident not deliberately. I am aware that duplications are not
> supposed to happen.
>
> On Sep 15, 12:09 am, Adam Lee <[email protected]> wrote:
>
> > I think you need to read up a little bit on memcached's entire strategy on
> > this:
>
> >http://code.google.com/p/memcached/wiki/FAQ#Cluster_Architecture_Ques...
>
> > On Tue, Sep 14, 2010 at 7:03 PM, Granit <[email protected]> wrote:
> > > Suppose one of the memcached machines in a cluster looses connection,
> > > when asking for a key it is non existent on any other machine in the
> > > cluster so
> > > the client decides to create a new one, now the disconnected machine
> > > is back.
> > > Thus we have two machines with the same key, which key->value pair
> > > would we get
> > > when requesting this duplicated key?
>
> > > - the one created the last?
> > > - which ever server answers first?
>
> > > thanks
> > > Granit
>
> > --
> > awl
>
>
or is it, if a server disconnects which a client was working with,
this particular client simply couldn't work with any server at all and
would have to wait for reappearance? at which state it would simply
receive possibly stale data.

On Sep 15, 12:22 am, Granit <[email protected]> wrote:
> Oh yeah,
>
> I think my question would be answered in the not yet written:
>
> > getting stale entries when a memcached server flaps in and out of the cluster
>
> which is why I posted it here...
>
> many thanks in advance
>
> On Sep 15, 12:17 am, Granit <[email protected]> wrote:
>
> > Thank you for the quick reply,
> > I did read that> It is able to use the same hashing process to figure out key "foo" is on server B. It then directly requests key "foo" and gets back "barbaz".
>
> > So what happens when key "foo" exists on server A and B? I mean by
> > accident not deliberately. I am aware that duplications are not
> > supposed to happen.
>
> > On Sep 15, 12:09 am, Adam Lee <[email protected]> wrote:
>
> > > I think you need to read up a little bit on memcached's entire strategy on
> > > this:
>
> > >http://code.google.com/p/memcached/wiki/FAQ#Cluster_Architecture_Ques....
>
> > > On Tue, Sep 14, 2010 at 7:03 PM, Granit <[email protected]> wrote:
> > > > Suppose one of the memcached machines in a cluster looses connection,
> > > > when asking for a key it is non existent on any other machine in the
> > > > cluster so
> > > > the client decides to create a new one, now the disconnected machine
> > > > is back.
> > > > Thus we have two machines with the same key, which key->value pair
> > > > would we get
> > > > when requesting this duplicated key?
>
> > > > - the one created the last?
> > > > - which ever server answers first?
>
> > > > thanks
> > > > Granit
>
> > > --
> > > awl
>
>
At any given moment, your client thinks key k exists on the server
represented in the server list by n where n = hash(k)

99.9999% of the time this list doesn't change unless you're doing a really
bad job of running your memcached servers or your network, so you don't need
to worry too much about it. Plus you can only really get inconsistent
results if the server your key hashes to goes down, the value changes, gets
written to the new server and then the original server comes back offline.
If you really do care about not getting inconsistent results, though, you
should just turn off failover.

On Tue, Sep 14, 2010 at 7:25 PM, Granit <[email protected]> wrote:

> or is it, if a server disconnects which a client was working with,
> this particular client simply couldn't work with any server at all and
> would have to wait for reappearance? at which state it would simply
> receive possibly stale data.
>
> On Sep 15, 12:22 am, Granit <[email protected]> wrote:
> > Oh yeah,
> >
> > I think my question would be answered in the not yet written:
> >
> > > getting stale entries when a memcached server flaps in and out of the
> cluster
> >
> > which is why I posted it here...
> >
> > many thanks in advance
> >
> > On Sep 15, 12:17 am, Granit <[email protected]> wrote:
> >
> > > Thank you for the quick reply,
> > > I did read that> It is able to use the same hashing process to figure
> out key "foo" is on server B. It then directly requests key "foo" and gets
> back "barbaz".
> >
> > > So what happens when key "foo" exists on server A and B? I mean by
> > > accident not deliberately. I am aware that duplications are not
> > > supposed to happen.
> >
> > > On Sep 15, 12:09 am, Adam Lee <[email protected]> wrote:
> >
> > > > I think you need to read up a little bit on memcached's entire
> strategy on
> > > > this:
> >
> > > >
> http://code.google.com/p/memcached/wiki/FAQ#Cluster_Architecture_Ques...
> >
> > > > On Tue, Sep 14, 2010 at 7:03 PM, Granit <[email protected]> wrote:
> > > > > Suppose one of the memcached machines in a cluster looses
> connection,
> > > > > when asking for a key it is non existent on any other machine in
> the
> > > > > cluster so
> > > > > the client decides to create a new one, now the disconnected
> machine
> > > > > is back.
> > > > > Thus we have two machines with the same key, which key->value pair
> > > > > would we get
> > > > > when requesting this duplicated key?
> >
> > > > > - the one created the last?
> > > > > - which ever server answers first?
> >
> > > > > thanks
> > > > > Granit
> >
> > > > --
> > > > awl
> >
> >
>



--
awl
It depends if your client library code has reconnected with the lost (old)
machine or not. If the client has not reconnected yet, it will get the key
from the last machine. If the client has reestablished the connection,
it will get it from the old machine - you might have stale data in that case.

The bottom line is that the client decides which server to go for the key.


Tony Wong

> Date: Tue, 14 Sep 2010 16:03:46 -0700
> Subject: Which key is chosen when key duplicates exist in a cluster?
> From: ivolation@gmail.com
> To: memcached@googlegroups.com
>
> Suppose one of the memcached machines in a cluster looses connection,
> when asking for a key it is non existent on any other machine in the
> cluster so
> the client decides to create a new one, now the disconnected machine
> is back.
> Thus we have two machines with the same key, which key->value pair
> would we get
> when requesting this duplicated key?
>
> - the one created the last?
> - which ever server answers first?
>
> thanks
> Granit
thanks

On Sep 15, 12:19 am, Tony Wong <[email protected]> wrote:
> It depends if your client library code has reconnected with the lost (old)
> machine or not.  If the client has not reconnected yet, it will get the key
> from the last machine.  If the client has reestablished the connection,
> it will get it from the old machine - you might have stale data in that case.
>
> The bottom line is that the client decides which server to go for the key..
>
> Tony Wong
>
> > Date: Tue, 14 Sep 2010 16:03:46 -0700
> > Subject: Which key is chosen when key duplicates exist in a cluster?
> > From: ivolat...@gmail.com
> > To: memcached@googlegroups.com
>
> > Suppose one of the memcached machines in a cluster looses connection,
> > when asking for a key it is non existent on any other machine in the
> > cluster so
> > the client decides to create a new one, now the disconnected machine
> > is back.
> > Thus we have two machines with the same key, which key->value pair
> > would we get
> > when requesting this duplicated key?
>
> > - the one created the last?
> > - which ever server answers first?
>
> > thanks
> > Granit
>
>
Sorry, only registered users may post in this forum.

Click here to login