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

Fixing memory leak caused by blocking query #939

Merged
merged 7 commits into from
May 15, 2015
Merged

Fixing memory leak caused by blocking query #939

merged 7 commits into from
May 15, 2015

Conversation

armon
Copy link
Member

@armon armon commented May 15, 2015

Blocking queries work by registering a notification channel along various write paths and watching for trigger to be hit. Once triggered, those channels are notified and cleared. However, for many blocking queries, their trigger point may not be hit for a long (potentially infinite) time, causing a memory leak. To avoid this, this PR changes behavior to pro-actively clear the notification channels and timeout timers. This avoids the leaks caused by blocking queries.

@@ -421,6 +421,13 @@ func (s *StateStore) Watch(tables MDBTables, notify chan struct{}) {
}
}

// StopWatch is used to unsubscribe a channel to a set of MDBTables
func (s *StateStore) StopWatch(tables MDBTables, notify chan struct{}) {
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 are missing a test for this function

@ryanuber
Copy link
Member

@armon everything looks great, just one untested method. Otherwise LGTM!

@armon
Copy link
Member Author

armon commented May 15, 2015

@ryanuber Added test!

armon added a commit that referenced this pull request May 15, 2015
Fixing memory leak caused by blocking query
@armon armon merged commit c559023 into master May 15, 2015
@armon armon deleted the f-leak branch May 15, 2015 01:32
@ryanuber
Copy link
Member

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

2 participants