Re: Reviewing a script to demo memcache get-set race conditions problems if it is used for distributed locking.

2016-06-04 Thread Nishant Varma
I did see Thread 1 
 
and Thread 2 
 as 
well. It also has some resources on this topic. Anyway, isn't the below 
pattern simple enough? Do we need any more complication in my scenario? 
Would help if you can clarify. Thanks.

Thanks,
Nishant

On Saturday, June 4, 2016 at 7:04:58 PM UTC+5:30, Nishant Varma wrote:
>
> I am reading 
> https://github.com/memcached/memcached/wiki/ProgrammingTricks#ghetto-central-locking,
>  
> it seems to deal with a slightly different lock scenario of getting some 
> expensive item from Database to avoid "Stampeding"
>
> In my case its slightly different lock that I need. I show regular files 
> from a folder in a web application to many users. So, to "lock" a file 
> using memcache isn't this simple API sufficient or I still need that 
> pattern :-)?
>
> def access(filename):
>  if memcache.add(filename, timestamp):
> return "Access Granted. Lock Obtained" # Normally this results in 
> checking HTML checkbox against the filename so User can do actions with 
> that/
>  else:
> return "Access Denied" # Normally this leads to an alert saying 
> that someone else is working on this.
>
> Isn't this simple API using add good enough in my case? I am sorry if I am 
> repeating this, but I could not really relate the "fetching expensive item 
> from Database" to my scenario which is why I even wrote a simple script to 
> test the validity of the claim etc.
>
> Can you please let me know?
>
>
> On Saturday, June 4, 2016 at 6:42:35 PM UTC+5:30, Nishant Varma wrote:
>>
>> Excellent I rely on you. I guess this is the reason you say I am 
>> over-engineering this problem. Makes sense :-) I will again check the link 
>> you gave me. I will go through the documentation this weekend.
>>
>> On Saturday, June 4, 2016 at 1:33:04 PM UTC+5:30, Dormando wrote:
>>>
>>> Hey, 
>>>
>>> You really don't need to test this: I'm telling you flatly, as an author 
>>> of this software and all of the documentation for it, that you should 
>>> absolutely not rely on that pattern. I'm trying to save you some time. 
>>>
>>> The pattern that is slightly better is written explicitly in pseudocode 
>>> in 
>>> the link I gave you several times in the issue. Please use it. 
>>>
>>> Thanks, 
>>> -Dormando 
>>>
>>> On Fri, 3 Jun 2016, Nishant Varma wrote: 
>>>
>>> > Can anyone help me peer review this script 
>>> https://gist.github.com/varmanishant/0129286d41038cc21471652a6460a5ff 
>>> that demonstrate potential problems with get set if it is used 
>>> > to implement distributed locking. I was suggested to modify from get 
>>> set to add in this thread 
>>> https://github.com/memcached/memcached/issues/163. However I wanted a 
>>> small 
>>> > simulation to demonstrate this. 
>>> > 
>>> > -- 
>>> > 
>>> > --- 
>>> > You received this message because you are subscribed to the Google 
>>> Groups "memcached" group. 
>>> > To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to memcached+...@googlegroups.com. 
>>> > For more options, visit https://groups.google.com/d/optout. 
>>> > 
>>> > 
>>>
>>
-- 
This e-mail message (including any attachments) may contain information 
that is confidential, protected by the attorney-client or other applicable 
privileges, or otherwise comprising non-public information. This message is 
intended to be conveyed only to the designated recipient(s). If you have 
any reason to believe you are not an intended recipient of this message, 
please notify the sender by replying to this message and then deleting it 
from your system. Any use, dissemination, distribution, or reproduction of 
this message by unintended recipients is not authorized and may be unlawful.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"memcached" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to memcached+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Reviewing a script to demo memcache get-set race conditions problems if it is used for distributed locking.

2016-06-04 Thread Nishant Varma
I am reading 
https://github.com/memcached/memcached/wiki/ProgrammingTricks#ghetto-central-locking,
 
it seems to deal with a slightly different lock scenario of getting some 
expensive item from Database to avoid "Stampeding"

In my case its slightly different lock that I need. I show regular files 
from a folder in a web application to many users. So, to "lock" a file 
using memcache isn't this simple API sufficient or I still need that 
pattern :-)?

def access(filename):
 if memcache.add(filename, timestamp):
return "Access Granted. Lock Obtained" # Normally this results in 
checking HTML checkbox against the filename so User can do actions with 
that/
 else:
return "Access Denied" # Normally this leads to an alert saying 
that someone else is working on this.

Isn't this simple API using add good enough in my case? I am sorry if I am 
repeating this, but I could not really relate the "fetching expensive item 
from Database" to my scenario which is why I even wrote a simple script to 
test the validity of the claim etc.

Can you please let me know?


On Saturday, June 4, 2016 at 6:42:35 PM UTC+5:30, Nishant Varma wrote:
>
> Excellent I rely on you. I guess this is the reason you say I am 
> over-engineering this problem. Makes sense :-) I will again check the link 
> you gave me. I will go through the documentation this weekend.
>
> On Saturday, June 4, 2016 at 1:33:04 PM UTC+5:30, Dormando wrote:
>>
>> Hey, 
>>
>> You really don't need to test this: I'm telling you flatly, as an author 
>> of this software and all of the documentation for it, that you should 
>> absolutely not rely on that pattern. I'm trying to save you some time. 
>>
>> The pattern that is slightly better is written explicitly in pseudocode 
>> in 
>> the link I gave you several times in the issue. Please use it. 
>>
>> Thanks, 
>> -Dormando 
>>
>> On Fri, 3 Jun 2016, Nishant Varma wrote: 
>>
>> > Can anyone help me peer review this script 
>> https://gist.github.com/varmanishant/0129286d41038cc21471652a6460a5ff 
>> that demonstrate potential problems with get set if it is used 
>> > to implement distributed locking. I was suggested to modify from get 
>> set to add in this thread 
>> https://github.com/memcached/memcached/issues/163. However I wanted a 
>> small 
>> > simulation to demonstrate this. 
>> > 
>> > -- 
>> > 
>> > --- 
>> > You received this message because you are subscribed to the Google 
>> Groups "memcached" group. 
>> > To unsubscribe from this group and stop receiving emails from it, send 
>> an email to memcached+...@googlegroups.com. 
>> > For more options, visit https://groups.google.com/d/optout. 
>> > 
>> > 
>>
>
-- 
This e-mail message (including any attachments) may contain information 
that is confidential, protected by the attorney-client or other applicable 
privileges, or otherwise comprising non-public information. This message is 
intended to be conveyed only to the designated recipient(s). If you have 
any reason to believe you are not an intended recipient of this message, 
please notify the sender by replying to this message and then deleting it 
from your system. Any use, dissemination, distribution, or reproduction of 
this message by unintended recipients is not authorized and may be unlawful.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"memcached" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to memcached+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Reviewing a script to demo memcache get-set race conditions problems if it is used for distributed locking.

2016-06-04 Thread Nishant Varma
Excellent I rely on you. I guess this is the reason you say I am 
over-engineering this problem. Makes sense :-) I will again check the link 
you gave me. I will go through the documentation this weekend.

On Saturday, June 4, 2016 at 1:33:04 PM UTC+5:30, Dormando wrote:
>
> Hey, 
>
> You really don't need to test this: I'm telling you flatly, as an author 
> of this software and all of the documentation for it, that you should 
> absolutely not rely on that pattern. I'm trying to save you some time. 
>
> The pattern that is slightly better is written explicitly in pseudocode in 
> the link I gave you several times in the issue. Please use it. 
>
> Thanks, 
> -Dormando 
>
> On Fri, 3 Jun 2016, Nishant Varma wrote: 
>
> > Can anyone help me peer review this script 
> https://gist.github.com/varmanishant/0129286d41038cc21471652a6460a5ff 
> that demonstrate potential problems with get set if it is used 
> > to implement distributed locking. I was suggested to modify from get set 
> to add in this thread https://github.com/memcached/memcached/issues/163. 
> However I wanted a small 
> > simulation to demonstrate this. 
> > 
> > -- 
> > 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups "memcached" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to memcached+...@googlegroups.com . 
> > For more options, visit https://groups.google.com/d/optout. 
> > 
> > 
>

-- 
This e-mail message (including any attachments) may contain information 
that is confidential, protected by the attorney-client or other applicable 
privileges, or otherwise comprising non-public information. This message is 
intended to be conveyed only to the designated recipient(s). If you have 
any reason to believe you are not an intended recipient of this message, 
please notify the sender by replying to this message and then deleting it 
from your system. Any use, dissemination, distribution, or reproduction of 
this message by unintended recipients is not authorized and may be unlawful.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"memcached" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to memcached+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Monitoring specific key patterns in Memcache server

2016-06-04 Thread Nishant Varma
Thanks. Can you please tell me why you say that I am overengineering. Maybe 
I am but I wanted good reasons so that I convince myself. The problem is 
some times locks are not happening like say 2-3 times out of 3000 requests, 
 and I have only 4 reasons so far - 1) get-set race 2) memcache client 
disconnects 3) data eviction 4) some ordinary coding issues (of which I 
don't see any evidence so far and the ratio suggests otherwise?). Also do 
you have any other ideas to take this forward, let me know. I wanted to see 
if it is set-get race mainly or else just rule out concurrency as the first 
step.

On Saturday, June 4, 2016 at 1:35:37 PM UTC+5:30, Dormando wrote:
>
> Hey, 
>
> Memcached can't do that easily right now. You can use the STDOUT logging 
> but that requires reading everything the server is doing directly. 
>
> I started a branch for a better logging situation a few months ago, and am 
> picking it up to finish over the next few weeks 
> (https://github.com/memcached/memcached/pull/127). That won't do you any 
> good in the short term though. 
>
> Printing via your overrides is probably the best way of getting the 
> localized data you need, however I insist *again* that you're 
> overengineering this. 
>
> On Sat, 4 Jun 2016, Nishant Varma wrote: 
>
> > Real time of offline solutions would be helpful. If I can profile in 
> background and query it later that is one option. However the only concern 
> with profiling is that I don't 
> > need to profile everything. Or does memcache do this by default? Can 
> anyone guide me? 
> > 
> > On Saturday, June 4, 2016 at 12:13:32 PM UTC+5:30, Nishant Varma wrote: 
> >   I am trying to troubleshoot an issue which could happen because of 
> get-set race condition. I can monitor the entire memcache operations but I 
> guess it is going to 
> >   be huge because its a small percentage of the DB itself, so I need 
> to filter only the keys I am interested in. We have a namespacing 
> convention to distinguish our 
> >   memcache entries so I would like to monitor the get and set that 
> happens to a specific namespace to track the get-set race condition. 
> > 
> > 
> >   I have a client side solution which is to over-ride (decorator in 
> Python) memcache.get and memcache.set to print the arguments if the key 
> matches our desired 
> >   pattern. 
> > 
> > 
> >   However can this be done in memcache server? We have so many 
> clients and we would have collect this information from all nodes and 
> morover this feels like suited 
> >   for server. Is there something that we could in memcached like 
> using debug module that would help us? 
> > 
> > 
> > This e-mail message (including any attachments) may contain information 
> that is confidential, protected by the attorney-client or other applicable 
> privileges, or otherwise 
> > comprising non-public information. This message is intended to be 
> conveyed only to the designated recipient(s). If you have any reason to 
> believe you are not an intended 
> > recipient of this message, please notify the sender by replying to this 
> message and then deleting it from your system. Any use, dissemination, 
> distribution, or reproduction of 
> > this message by unintended recipients is not authorized and may be 
> unlawful. 
> > 
> > -- 
> > 
> > --- 
> > You received this message because you are subscribed to the Google 
> Groups "memcached" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to memcached+...@googlegroups.com . 
> > For more options, visit https://groups.google.com/d/optout. 
> > 
> > 
>

-- 
This e-mail message (including any attachments) may contain information 
that is confidential, protected by the attorney-client or other applicable 
privileges, or otherwise comprising non-public information. This message is 
intended to be conveyed only to the designated recipient(s). If you have 
any reason to believe you are not an intended recipient of this message, 
please notify the sender by replying to this message and then deleting it 
from your system. Any use, dissemination, distribution, or reproduction of 
this message by unintended recipients is not authorized and may be unlawful.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"memcached" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to memcached+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Monitoring specific key patterns in Memcache server

2016-06-04 Thread dormando
Hey,

Memcached can't do that easily right now. You can use the STDOUT logging
but that requires reading everything the server is doing directly.

I started a branch for a better logging situation a few months ago, and am
picking it up to finish over the next few weeks
(https://github.com/memcached/memcached/pull/127). That won't do you any
good in the short term though.

Printing via your overrides is probably the best way of getting the
localized data you need, however I insist *again* that you're
overengineering this.

On Sat, 4 Jun 2016, Nishant Varma wrote:

> Real time of offline solutions would be helpful. If I can profile in 
> background and query it later that is one option. However the only concern 
> with profiling is that I don't
> need to profile everything. Or does memcache do this by default? Can anyone 
> guide me?
>
> On Saturday, June 4, 2016 at 12:13:32 PM UTC+5:30, Nishant Varma wrote:
>   I am trying to troubleshoot an issue which could happen because of 
> get-set race condition. I can monitor the entire memcache operations but I 
> guess it is going to
>   be huge because its a small percentage of the DB itself, so I need to 
> filter only the keys I am interested in. We have a namespacing convention to 
> distinguish our
>   memcache entries so I would like to monitor the get and set that 
> happens to a specific namespace to track the get-set race condition.
>
>
>   I have a client side solution which is to over-ride (decorator in 
> Python) memcache.get and memcache.set to print the arguments if the key 
> matches our desired
>   pattern.
>
>
>   However can this be done in memcache server? We have so many clients 
> and we would have collect this information from all nodes and morover this 
> feels like suited
>   for server. Is there something that we could in memcached like using 
> debug module that would help us?
>
>
> This e-mail message (including any attachments) may contain information that 
> is confidential, protected by the attorney-client or other applicable 
> privileges, or otherwise
> comprising non-public information. This message is intended to be conveyed 
> only to the designated recipient(s). If you have any reason to believe you 
> are not an intended
> recipient of this message, please notify the sender by replying to this 
> message and then deleting it from your system. Any use, dissemination, 
> distribution, or reproduction of
> this message by unintended recipients is not authorized and may be unlawful.
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups 
> "memcached" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to memcached+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"memcached" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to memcached+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Reviewing a script to demo memcache get-set race conditions problems if it is used for distributed locking.

2016-06-04 Thread dormando
Hey,

You really don't need to test this: I'm telling you flatly, as an author
of this software and all of the documentation for it, that you should
absolutely not rely on that pattern. I'm trying to save you some time.

The pattern that is slightly better is written explicitly in pseudocode in
the link I gave you several times in the issue. Please use it.

Thanks,
-Dormando

On Fri, 3 Jun 2016, Nishant Varma wrote:

> Can anyone help me peer review this script 
> https://gist.github.com/varmanishant/0129286d41038cc21471652a6460a5ff that 
> demonstrate potential problems with get set if it is used
> to implement distributed locking. I was suggested to modify from get set to 
> add in this thread https://github.com/memcached/memcached/issues/163. However 
> I wanted a small
> simulation to demonstrate this.
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups 
> "memcached" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to memcached+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>
>

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"memcached" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to memcached+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Monitoring specific key patterns in Memcache server

2016-06-04 Thread Nishant Varma
Real time of offline solutions would be helpful. If I can profile in 
background and query it later that is one option. However the only concern 
with profiling is that I don't need to profile everything. Or does memcache 
do this by default? Can anyone guide me?

On Saturday, June 4, 2016 at 12:13:32 PM UTC+5:30, Nishant Varma wrote:
>
> I am trying to troubleshoot an issue which could happen because of get-set 
> race condition. I can monitor the entire memcache operations but I guess it 
> is going to be huge because its a small percentage of the DB itself, so I 
> need to filter only the keys I am interested in. We have a namespacing 
> convention to distinguish our memcache entries so I would like to monitor 
> the get and set that happens to a specific namespace to track the get-set 
> race condition.
>
>
> I have a client side solution which is to over-ride (decorator in Python) 
> memcache.get and memcache.set to print the arguments if the key matches our 
> desired pattern.
>
>
> However can this be done in memcache server? We have so many clients and 
> we would have collect this information from all nodes and morover this 
> feels like suited for server. Is there something that we could in memcached 
> like using debug module that would help us?
>

-- 
This e-mail message (including any attachments) may contain information 
that is confidential, protected by the attorney-client or other applicable 
privileges, or otherwise comprising non-public information. This message is 
intended to be conveyed only to the designated recipient(s). If you have 
any reason to believe you are not an intended recipient of this message, 
please notify the sender by replying to this message and then deleting it 
from your system. Any use, dissemination, distribution, or reproduction of 
this message by unintended recipients is not authorized and may be unlawful.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"memcached" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to memcached+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Monitoring specific key patterns in Memcache server

2016-06-04 Thread Nishant Varma
I am trying to troubleshoot an issue which could happen because of get-set 
race condition. I can monitor the entire memcache operations but I guess it 
is going to be huge because its a small percentage of the DB itself, so I 
need to filter only the keys I am interested in. We have a namespacing 
convention to distinguish our memcache entries so I would like to monitor 
the get and set that happens to a specific namespace to track the get-set 
race condition.


I have a client side solution which is to over-ride (decorator in Python) 
memcache.get and memcache.set to print the arguments if the key matches our 
desired pattern.


However can this be done in memcache server? We have so many clients and we 
would have collect this information from all nodes and morover this feels 
like suited for server. Is there something that we could in memcached like 
using debug module that would help us?

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"memcached" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to memcached+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Reviewing a script to demo memcache get-set race conditions problems if it is used for distributed locking.

2016-06-04 Thread Nishant Varma
Can anyone help me peer review this script 
https://gist.github.com/varmanishant/0129286d41038cc21471652a6460a5ff that 
demonstrate potential problems with get set if it is used to implement 
distributed locking. I was suggested to modify from get set to add in this 
thread https://github.com/memcached/memcached/issues/163. However I wanted 
a small simulation to demonstrate this.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"memcached" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to memcached+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.