You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@curator.apache.org by Krishmin Rai <kr...@catalist.us> on 2014/02/03 21:22:43 UTC

InterProcessSemaphoreV2 and updated SharedCount

Hi All,
  This is my first experiment with Curator, and I have some questions about
the SharedSemaphore recipe. In my code, I'm creating an
InterProcessSemaphoreV2 object using SharedCount. Things seem to work as
expected, except in the following case: all leases are currently in use, an
existing process is waiting for the next available lease, and then I
increase the value in the shared counter. Instead of (relatively)
immediately getting the newly-available lease, the waiting process
continues to block until it reaches the end of the timeout period (or
presumably until other processes finish or some other notification occurs).

  After a quick peek in the source code, it seems like updates to
SharedCount set the volatile local variable but do not trigger any
notification. Is this correct?

  Let me know if I'm expecting the wrong behavior or perhaps have some
error on my side (I can provide some sample code or more details on how
I've been testing if that seems likely).

Thanks!
Krishmin

p.s. This is with 2.3.0/2.3.1

Re: InterProcessSemaphoreV2 and updated SharedCount

Posted by Krishmin Rai <kr...@catalist.us>.
Yep -- that looks like the same issue I'm running into and the same fix I
would have suggested.

Thanks for following up.

-Krishmin


On Mon, Feb 3, 2014 at 4:08 PM, Jordan Zimmerman <jordan@jordanzimmerman.com
> wrote:

> Actually, it looks like there is already a patch for this. I'll have a
> look:
>
> https://issues.apache.org/jira/browse/CURATOR-75
>
> ------------------------------
> From: Jordan Zimmerman Jordan Zimmerman <jo...@jordanzimmerman.com>
> Reply: Jordan Zimmerman jordan@jordanzimmerman.com
> Date: February 3, 2014 at 3:45:37 PM
> To: Krishmin Rai krai@catalist.us, user@curator.apache.org
> user@curator.apache.org
> Subject:  Re: InterProcessSemaphoreV2 and updated SharedCount
>
>  Frankly, I don't remember how it works ;) But, it sounds like it should
> work as you describe. Please write a test case and open an issue in Jira. A
> patch fixing the problem would be appreciated.
>
>  -JZ
>
>  ------------------------------
> From: Krishmin Rai Krishmin Rai <kr...@catalist.us>
> Reply: user@curator.apache.org user@curator.apache.org
> Date: February 3, 2014 at 3:23:13 PM
> To: user@curator.apache.org user@curator.apache.org
> Subject:  InterProcessSemaphoreV2 and updated SharedCount
>
>    Hi All,
>   This is my first experiment with Curator, and I have some questions
> about the SharedSemaphore recipe. In my code, I'm creating an
> InterProcessSemaphoreV2 object using SharedCount. Things seem to work as
> expected, except in the following case: all leases are currently in use, an
> existing process is waiting for the next available lease, and then I
> increase the value in the shared counter. Instead of (relatively)
> immediately getting the newly-available lease, the waiting process
> continues to block until it reaches the end of the timeout period (or
> presumably until other processes finish or some other notification occurs).
>
>   After a quick peek in the source code, it seems like updates to
> SharedCount set the volatile local variable but do not trigger any
> notification. Is this correct?
>
>   Let me know if I'm expecting the wrong behavior or perhaps have some
> error on my side (I can provide some sample code or more details on how
> I've been testing if that seems likely).
>
> Thanks!
> Krishmin
>
> p.s. This is with 2.3.0/2.3.1
>
>
>
>
>
>

Re: InterProcessSemaphoreV2 and updated SharedCount

Posted by Jordan Zimmerman <jo...@jordanzimmerman.com>.
Actually, it looks like there is already a patch for this. I’ll have a look:

https://issues.apache.org/jira/browse/CURATOR-75

From: Jordan Zimmerman Jordan Zimmerman
Reply: Jordan Zimmerman jordan@jordanzimmerman.com
Date: February 3, 2014 at 3:45:37 PM
To: Krishmin Rai krai@catalist.us, user@curator.apache.org user@curator.apache.org
Subject:  Re: InterProcessSemaphoreV2 and updated SharedCount  
Frankly, I don’t remember how it works ;) But, it sounds like it should work as you describe. Please write a test case and open an issue in Jira. A patch fixing the problem would be appreciated.

-JZ

From: Krishmin Rai Krishmin Rai
Reply: user@curator.apache.org user@curator.apache.org
Date: February 3, 2014 at 3:23:13 PM
To: user@curator.apache.org user@curator.apache.org
Subject:  InterProcessSemaphoreV2 and updated SharedCount
Hi All,
  This is my first experiment with Curator, and I have some questions about the SharedSemaphore recipe. In my code, I'm creating an InterProcessSemaphoreV2 object using SharedCount. Things seem to work as expected, except in the following case: all leases are currently in use, an existing process is waiting for the next available lease, and then I increase the value in the shared counter. Instead of (relatively) immediately getting the newly-available lease, the waiting process continues to block until it reaches the end of the timeout period (or presumably until other processes finish or some other notification occurs).

  After a quick peek in the source code, it seems like updates to SharedCount set the volatile local variable but do not trigger any notification. Is this correct?

  Let me know if I'm expecting the wrong behavior or perhaps have some error on my side (I can provide some sample code or more details on how I've been testing if that seems likely).

Thanks!
Krishmin

p.s. This is with 2.3.0/2.3.1

 

 

Re: InterProcessSemaphoreV2 and updated SharedCount

Posted by Jordan Zimmerman <jo...@jordanzimmerman.com>.
Frankly, I don’t remember how it works ;) But, it sounds like it should work as you describe. Please write a test case and open an issue in Jira. A patch fixing the problem would be appreciated.

-JZ

From: Krishmin Rai Krishmin Rai
Reply: user@curator.apache.org user@curator.apache.org
Date: February 3, 2014 at 3:23:13 PM
To: user@curator.apache.org user@curator.apache.org
Subject:  InterProcessSemaphoreV2 and updated SharedCount  
Hi All,
  This is my first experiment with Curator, and I have some questions about the SharedSemaphore recipe. In my code, I'm creating an InterProcessSemaphoreV2 object using SharedCount. Things seem to work as expected, except in the following case: all leases are currently in use, an existing process is waiting for the next available lease, and then I increase the value in the shared counter. Instead of (relatively) immediately getting the newly-available lease, the waiting process continues to block until it reaches the end of the timeout period (or presumably until other processes finish or some other notification occurs).

  After a quick peek in the source code, it seems like updates to SharedCount set the volatile local variable but do not trigger any notification. Is this correct?

  Let me know if I'm expecting the wrong behavior or perhaps have some error on my side (I can provide some sample code or more details on how I've been testing if that seems likely).

Thanks!
Krishmin

p.s. This is with 2.3.0/2.3.1