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

Issue 11506043: state/api/watcher: Client-side watchers improved (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 9 months ago by dimitern
Modified:
10 years, 9 months ago
Reviewers:
mp+175485, fwereade, rog
Visibility:
Public.

Description

state/api/watcher: Client-side watchers improved This branch fixes an issue with StringsWatcher at client-side: it was possible to drop events if you do not keep reading constantly. Now they get queued up and arrive in the order delivered when reading. Added a test as well. Also, as a drive-by fix: there was a possibility for deadlocking in both StringsWatcher and NotifyWatcher when trying to close it while there is an event waiting to be read. Added tests for these cases as well and verified that without the fix deadlocks are indeed triggered. https://code.launchpad.net/~dimitern/juju-core/071-stringswatcher-client-improvements/+merge/175485 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 12

Patch Set 2 : state/api/watcher: StringsWatcher improvements #

Total comments: 2

Patch Set 3 : state/api/watcher: StringsWatcher improvements #

Total comments: 14

Patch Set 4 : state/api/watcher: Client-side watchers improved #

Unified diffs Side-by-side diffs Delta from patch set Stats (+176 lines, -54 lines) Patch
A [revision details] View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
M state/api/watcher/watcher.go View 1 2 3 2 chunks +25 lines, -33 lines 0 comments Download
M state/api/watcher/watcher_test.go View 1 2 3 4 chunks +122 lines, -19 lines 0 comments Download
M state/testing/watcher.go View 1 2 3 3 chunks +27 lines, -2 lines 0 comments Download

Messages

Total messages: 8
dimitern
Please take a look.
10 years, 9 months ago (2013-07-18 10:01:06 UTC) #1
fwereade
A few thoughts, let me know yours. https://codereview.appspot.com/11506043/diff/1/state/api/watcher/watcher.go File state/api/watcher/watcher.go (left): https://codereview.appspot.com/11506043/diff/1/state/api/watcher/watcher.go#oldcode225 state/api/watcher/watcher.go:225: panic("unreachable") I ...
10 years, 9 months ago (2013-07-18 10:27:35 UTC) #2
dimitern
Please take a look. https://codereview.appspot.com/11506043/diff/1/state/api/watcher/watcher.go File state/api/watcher/watcher.go (left): https://codereview.appspot.com/11506043/diff/1/state/api/watcher/watcher.go#oldcode225 state/api/watcher/watcher.go:225: panic("unreachable") On 2013/07/18 10:27:36, fwereade ...
10 years, 9 months ago (2013-07-18 10:52:57 UTC) #3
fwereade
LGTM, just suggestions. https://codereview.appspot.com/11506043/diff/1/state/api/watcher/watcher.go File state/api/watcher/watcher.go (left): https://codereview.appspot.com/11506043/diff/1/state/api/watcher/watcher.go#oldcode225 state/api/watcher/watcher.go:225: panic("unreachable") On 2013/07/18 10:52:57, dimitern wrote: ...
10 years, 9 months ago (2013-07-18 11:02:10 UTC) #4
dimitern
Please take a look. https://codereview.appspot.com/11506043/diff/1/state/api/watcher/watcher.go File state/api/watcher/watcher.go (left): https://codereview.appspot.com/11506043/diff/1/state/api/watcher/watcher.go#oldcode225 state/api/watcher/watcher.go:225: panic("unreachable") On 2013/07/18 11:02:10, fwereade ...
10 years, 9 months ago (2013-07-18 14:44:00 UTC) #5
rog
LGTM assuming you got the watcher deadlock test to fail before applying the new changes. ...
10 years, 9 months ago (2013-07-18 15:19:24 UTC) #6
rog
On 2013/07/18 15:19:24, rog wrote: > LGTM assuming you got the watcher deadlock test to ...
10 years, 9 months ago (2013-07-18 15:20:10 UTC) #7
dimitern
10 years, 9 months ago (2013-07-18 15:39:36 UTC) #8
Please take a look.

https://codereview.appspot.com/11506043/diff/7003/state/api/watcher/watcher.go
File state/api/watcher/watcher.go (right):

https://codereview.appspot.com/11506043/diff/7003/state/api/watcher/watcher.g...
state/api/watcher/watcher.go:157: break
On 2013/07/18 15:19:25, rog wrote:
> maybe return nil for symmetry here and panic below the loop.
> alternatively add a loop label and use break label.

Will return nil instead.

https://codereview.appspot.com/11506043/diff/7003/state/api/watcher/watcher.g...
state/api/watcher/watcher.go:203: // Send changes when we have them.
On 2013/07/18 15:19:25, rog wrote:
> // Send the initial event or subsequent change.
> 
> ?

Done.

https://codereview.appspot.com/11506043/diff/7003/state/api/watcher/watcher.g...
state/api/watcher/watcher.go:208: // Then read the next event, so we ensure the
order of delivery.
On 2013/07/18 15:19:25, rog wrote:
> // Read the next change.
> ?

Done.

https://codereview.appspot.com/11506043/diff/7003/state/testing/watcher.go
File state/testing/watcher.go (right):

https://codereview.appspot.com/11506043/diff/7003/state/testing/watcher.go#ne...
state/testing/watcher.go:27: func AssertStoppedWhenSending(c *C, stopper
Stopper) {
On 2013/07/18 15:19:25, rog wrote:
> AssertCanStopWhenSending ?

Done.

https://codereview.appspot.com/11506043/diff/7003/state/testing/watcher.go#ne...
state/testing/watcher.go:34: AssertStop(c, stopper)
On 2013/07/18 15:19:25, rog wrote:
> you shouldn't use assert in goroutines outside the main gocheck test.
> 
>    c.Check(stopper.Stop(), IsNil)
> 
> instead.

Done.

https://codereview.appspot.com/11506043/diff/7003/state/testing/watcher.go#ne...
state/testing/watcher.go:35: stopped = true
On 2013/07/18 15:19:25, rog wrote:
> this is racy.
> 
> use a chan bool instead.

Done.

https://codereview.appspot.com/11506043/diff/7003/state/testing/watcher.go#ne...
state/testing/watcher.go:183: func (c StringsWatcherC) AssertOneChange(expect
...string) {
On 2013/07/18 15:19:25, rog wrote:
> "OneChange" doesn't seem quite right when there are an arbitrary number.
> AssertChangesAndNoMore ?
> 
> tbh i think i'd lose this function - it's only an extra line for any test code
> to implement; i don't think it's worth its weight.

I was thinking about removing it. Ok, will do.
Sign in to reply to this message.

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