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

Fix races in CQ execution #2553

Merged
merged 1 commit into from
May 12, 2015
Merged

Fix races in CQ execution #2553

merged 1 commit into from
May 12, 2015

Conversation

otoolep
Copy link
Contributor

@otoolep otoolep commented May 12, 2015

This change refactors the CQ code such that "should run" is checked within the goroutine that the CQ will run, if it does run. This avoids the race, at the cost a very-short lived goroutine if the CQ is not run.

@otoolep
Copy link
Contributor Author

otoolep commented May 12, 2015

@pauldix @toddboom @corylanou

@otoolep otoolep force-pushed the fix_cq_race branch 5 times, most recently from 9555750 to e86ebb0 Compare May 12, 2015 22:39
@otoolep otoolep changed the title Fix CQ race Fix races in CQ execution May 12, 2015
@otoolep
Copy link
Contributor Author

otoolep commented May 12, 2015

@@ -3955,6 +3953,18 @@ func (s *Server) runContinuousQuery(cq *ContinuousQuery) {
cq.mu.Lock()
defer cq.mu.Unlock()

// Get server CQ parameters under lock, to avoid races.
s.mu.RLock()
Copy link
Member

Choose a reason for hiding this comment

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

do we really need to lock on these? They can't ever get updated on a running process. They're set when the server object is created and never set again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps not. This may be rather pedantic. This was a drive-by change -- the real race is around lastRun which was being written and read from different goroutines.

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 can pull this change. I agree that these settings never change.

@toddboom
Copy link
Contributor

yeah, this seems sane to me, even if it only could ever fail during testing. +1

otoolep added a commit that referenced this pull request May 12, 2015
@otoolep otoolep merged commit 6ccb08b into master May 12, 2015
@otoolep otoolep deleted the fix_cq_race branch May 12, 2015 23:03
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

3 participants