Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(360)

Issue 9209043: Fix deadlock bug between Get, SetCapacity and Put (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 2 months ago by sougou
Modified:
11 years, 11 months ago
Visibility:
Public.

Description

Fix deadlock bug between Get, SetCapacity and Put

Patch Set 1 #

Total comments: 3

Patch Set 2 : Fix race condition between Open & Get. Make fast paths more efficient. #

Total comments: 2

Patch Set 3 : #

Patch Set 4 : #

Patch Set 5 : Simplified version, but SetCapacity is less flexible #

Patch Set 6 : #

Patch Set 7 : #

Patch Set 8 : #

Total comments: 8

Patch Set 9 : #

Patch Set 10 : #

Patch Set 11 : #

Total comments: 5
Unified diffs Side-by-side diffs Delta from patch set Stats (+229 lines, -279 lines) Patch
M go/pools/resource_pool.go View 1 2 3 4 5 6 7 8 9 10 4 chunks +98 lines, -166 lines 5 comments Download
M go/pools/resource_pool_test.go View 1 2 3 4 5 6 7 8 9 10 17 chunks +115 lines, -113 lines 0 comments Download
M go/sync2/atomic.go View 1 2 3 4 5 4 chunks +16 lines, -0 lines 0 comments Download

Messages

Total messages: 32
sougou
With this change, Get releases the read lock before waiting on the channel. This will ...
13 years, 2 months ago (2013-05-04 21:10:57 UTC) #1
sougou
Please read the previous comments I posted on this CL.
13 years, 2 months ago (2013-05-04 21:14:05 UTC) #2
dvyukov
LGTM
13 years, 2 months ago (2013-05-05 08:04:57 UTC) #3
sougou
There are two other schemes I considered: 1. Two channel approach: Get fetches from an ...
13 years, 2 months ago (2013-05-05 18:01:51 UTC) #4
dvyukov
On Sun, May 5, 2013 at 10:01 PM, <sougou@google.com> wrote: > There are two other ...
13 years, 2 months ago (2013-05-06 15:39:12 UTC) #5
sougou
I have a lock-free scheme in mind, but it depends on a behavior that may ...
13 years, 2 months ago (2013-05-06 16:15:51 UTC) #6
sougou
After looking at the other CL, I'm leaning back towards this one. It's not that ...
13 years, 2 months ago (2013-05-07 02:33:38 UTC) #7
dvyukov
What do you think about this one? http://play.golang.org/p/TvtjgNpfff Fast path for both Put and Get ...
13 years, 2 months ago (2013-05-07 06:57:14 UTC) #8
sougou
I actually pursued this idea for a bit, and then abandoned it thinking that waiting ...
13 years, 2 months ago (2013-05-07 07:12:46 UTC) #9
dvyukov
On Tue, May 7, 2013 at 12:12 AM, Sugu Sougoumarane <sougou@google.com> wrote: > I actually ...
13 years, 2 months ago (2013-05-07 07:21:00 UTC) #10
sougou
> Yes, it's somewhat slower than normal chan operations now. I hope I > will ...
13 years, 2 months ago (2013-05-07 07:42:34 UTC) #11
sougou
I just looked up one of my past benchmarks. RoundRobin was beginning to show up ...
13 years, 2 months ago (2013-05-07 08:00:36 UTC) #12
dvyukov
On Tue, May 7, 2013 at 11:42 AM, Sugu Sougoumarane <sougou@google.com> wrote: > >> Yes, ...
13 years, 2 months ago (2013-05-07 10:03:04 UTC) #13
sougou
> You can implement a special eager mode. In this mode emptyc is always > ...
13 years, 2 months ago (2013-05-07 16:22:32 UTC) #14
dvyukov
On Tue, May 7, 2013 at 8:22 PM, Sugu Sougoumarane <sougou@google.com> wrote: > >> You ...
13 years, 2 months ago (2013-05-07 16:26:03 UTC) #15
sougou
> In eager mode it just need to create a new resource and put in ...
13 years, 2 months ago (2013-05-07 16:38:22 UTC) #16
dvyukov
On Tue, May 7, 2013 at 8:38 PM, Sugu Sougoumarane <sougou@google.com> wrote: > >> In ...
13 years, 2 months ago (2013-05-07 16:51:21 UTC) #17
sougou
This version greatly simplifies the implementation, but at the cost of not reallocating the channel. ...
13 years, 2 months ago (2013-05-08 00:17:52 UTC) #18
msolomon
It is somewhat simpler. I also like that Get/TryGet are merged.
13 years, 2 months ago (2013-05-08 01:30:14 UTC) #19
sougou
I couldn't go lock-free because of possible race condition between Close & Get. Changes in ...
13 years, 2 months ago (2013-05-08 05:37:10 UTC) #20
dvyukov
On Wed, May 8, 2013 at 9:37 AM, <sougou@google.com> wrote: > I couldn't go lock-free ...
13 years, 2 months ago (2013-05-08 18:08:59 UTC) #21
sougou
> Can't you set the capacity to 0 (thus waiting for all outstanding > Put's) ...
13 years, 2 months ago (2013-05-08 18:34:39 UTC) #22
sougou
> That was what I first went for. The race condition in that case is ...
13 years, 2 months ago (2013-05-08 18:38:00 UTC) #23
sougou
We finally have a lock-free implementation! - Got rid of the Open. So, ResourcePool should ...
13 years, 2 months ago (2013-05-08 21:31:54 UTC) #24
msolomon
This is going around in circles. I don't understand what benefit we are looking for. ...
13 years, 2 months ago (2013-05-08 21:53:15 UTC) #25
sougou
https://codereview.appspot.com/9209043/diff/41005/go/pools/resource_pool.go File go/pools/resource_pool.go (right): https://codereview.appspot.com/9209043/diff/41005/go/pools/resource_pool.go#newcode137 go/pools/resource_pool.go:137: panic(CLOSED_ERR) On 2013/05/08 21:53:15, msolomon wrote: > Is this ...
13 years, 2 months ago (2013-05-08 22:18:35 UTC) #26
msolomon
SGTM On Wed, May 8, 2013 at 3:18 PM, <sougou@google.com> wrote: > > https://codereview.appspot.com/9209043/diff/41005/go/pools/resource_pool.go > ...
13 years, 2 months ago (2013-05-08 22:37:11 UTC) #27
sougou
PTAL https://codereview.appspot.com/9209043/diff/43002/go/pools/resource_pool.go File go/pools/resource_pool.go (right): https://codereview.appspot.com/9209043/diff/43002/go/pools/resource_pool.go#newcode167 go/pools/resource_pool.go:167: } I couldn't move this to sync as ...
13 years, 2 months ago (2013-05-08 22:47:10 UTC) #28
dvyukov
I like this version. I think it's good idea to handle re-opening on the higher ...
13 years, 2 months ago (2013-05-11 12:48:33 UTC) #29
sougou
I'll send out a new CL. https://codereview.appspot.com/9209043/diff/43002/go/pools/resource_pool.go File go/pools/resource_pool.go (right): https://codereview.appspot.com/9209043/diff/43002/go/pools/resource_pool.go#newcode52 go/pools/resource_pool.go:52: func NewResourcePool(factory Factory, ...
13 years, 2 months ago (2013-05-11 18:16:58 UTC) #30
dvyukov
On 2013/05/11 18:16:58, sougou wrote: > I'll send out a new CL. > > https://codereview.appspot.com/9209043/diff/43002/go/pools/resource_pool.go ...
13 years, 1 month ago (2013-05-12 11:14:26 UTC) #31
sougou
13 years, 1 month ago (2013-05-12 17:58:50 UTC) #32
> Then why do you need SetCapacity()?
>
>
Because the functionality is already there. So, it's better to keep
supporting it. It's also possible we may need it in the future for a
different situation.
From an implementation perspective, getting rid of SetCapacity() won't make
the code any simpler because of Close() needs that same functionality, or
something of similar complexity.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b