-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add restartable view support #105
Conversation
d7293f2
to
8acf000
Compare
view.go
Outdated
if v.terminated { | ||
return fmt.Errorf("view: cannot reinitialize terminated view") | ||
} | ||
defer v.mInit.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This defer should be above the conditional as it could return without unlocking
ba7e365
to
ecdeedf
Compare
True, I just fixed it.
… On 14. Mar 2018, at 10:47, Sami Hiltunen ***@***.***> wrote:
@SamiHiltunen commented on this pull request.
In view.go <#105 (comment)>:
> @@ -110,6 +112,12 @@ func (v *View) createPartitions(brokers []string) (err error) {
// reinit (re)initializes the view and its partitions to connect to Kafka
func (v *View) reinit() error {
+ v.mInit.Lock()
+ if v.terminated {
+ return fmt.Errorf("view: cannot reinitialize terminated view")
+ }
+ defer v.mInit.Unlock()
This defer should be above the conditional
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#105 (review)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAZmJiF1QxFNv4sszmUdFSSInPwsFcSLks5teOdEgaJpZM4So2b9>.
|
v.mInit.Lock() | ||
if v.terminated { | ||
return | ||
v.mInit.Unlock() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This unlock is dead code and could result in a deadlock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
damn it. Thanks
This PR resolves #102.
If one starts a view with the option
goka.WithViewRestartable()
, the view may be restarted or used, eg, by callingGet()
andRecovered()
,Iterator()
, etc. To release all resources, ie, close the underlying local storage, one must callStop()
when using theRestartable()
option.