Skip to content
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

[FIXED] Subscriptions not closed in the cluster when using auto unsubscribe #551

Merged
merged 1 commit into from Jul 21, 2017

Conversation

ingosus
Copy link
Contributor

@ingosus ingosus commented Jul 20, 2017

  • Link to issue, e.g. Resolves #NNN
  • Documentation added (if applicable)
  • Tests added
  • Branch rebased on top of current master (git pull --rebase origin master)
  • Changes squashed to a single commit (described here)
  • Build is green in Travis CI
  • You have certified that the contribution is your original work and that you license the work to the project under the MIT license

Resolves #549

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 91.596% when pulling d0817bb on ingosus:zombie_sub into 4ccbd2e on nats-io:master.

Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good catch! I would like to discuss the need for a new broadcast function. It seems to be that setting max to 0 when gathering the subscriptions would be enough.
For tests, I like that you made the cluster check function more generic. We could modify checkClusterFormed to use yours.

server/client.go Outdated
@@ -1344,7 +1344,7 @@ func (c *client) closeConnection() {
// Forward on unsubscribes if we are not
// a router ourselves.
if c.typ != ROUTER {
srv.broadcastUnSubscribe(sub)
srv.broadcastForceUnSubscribe(sub)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could do without this new function by simply setting sub.max = 0 (with a comment ;-)) above in the loop where we gather the subscriptions. We are under the client's mutex lock that protects the subscription's object. https://github.com/nats-io/gnatsd/pull/551/files#diff-853eb184ac73cf9597d7833f6b89e9c9R1320

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that https://github.com/nats-io/gnatsd/pull/551/files#diff-853eb184ac73cf9597d7833f6b89e9c9R1320 is the right place for zeroing sub.max, and no need new function)

server/route.go Outdated
@@ -610,6 +610,13 @@ func (s *Server) broadcastUnSubscribe(sub *subscription) {
s.broadcastInterestToRoutes(proto)
}

func (s *Server) broadcastForceUnSubscribe(sub *subscription) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May not need that function.

cluster := []*Server{srvA, srvB}

// Wait for route to form.
checkClusterFor(t, routesCheck(len(cluster)-1), 10*time.Second, cluster...)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now that you use this function for different type of checks. However, to check for cluster formation, there is already a function. You could use:checkClusterFormed(t, srvA, srvB). I see that yours is more generic (I did something very similar in NATS Streaming server). Since checkClusterFormed() is used quite a bit, we could change checkClusterFormed() implementation to simply call into yours. Does not have to be part of this PR though...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe https://github.com/nats-io/gnatsd/blob/master/test/cluster_test.go is better place for this test, if we test the behavior of the cluster? I can move it in this PR

@kozlovic
Copy link
Member

@ingosus I marked it as "Request changes" because I would like to open the discussion about where the max is set. Seems to be that it could be done in a different place but could be convinced otherwise.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 91.477% when pulling e1f27ba on ingosus:zombie_sub into 4ccbd2e on nats-io:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.08%) to 91.542% when pulling 5145723 on ingosus:zombie_sub into 4ccbd2e on nats-io:master.

@tylertreat tylertreat self-requested a review July 21, 2017 14:15
Copy link
Contributor

@tylertreat tylertreat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@kozlovic
Copy link
Member

@ingosus Thanks! Nice simple fix and test.

@kozlovic kozlovic merged commit 3ee7f3b into nats-io:master Jul 21, 2017
@kozlovic kozlovic changed the title Fixed error of hang subscriptions in the cluster when used auto unsubscribe [FIXED] Subscriptions not closed in the cluster when using auto unsubscribe Jul 21, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants