-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
domain: close slow query channel after closing session pool #7847
Changes from 4 commits
912cb54
477672a
5ebd928
fed5327
ee75a5e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,11 @@ type topNSlowQueries struct { | |
period time.Duration | ||
ch chan *SlowQueryInfo | ||
msgCh chan *showSlowMessage | ||
|
||
mu struct { | ||
sync.RWMutex | ||
closed bool | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. how about use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. atomic can't protect multiple operations. @crazycs520
Take this order for example:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. great~ |
||
} | ||
} | ||
|
||
func newTopNSlowQueries(topN int, period time.Duration, queueSize int) *topNSlowQueries { | ||
|
@@ -196,6 +201,10 @@ func (q *topNSlowQueries) QueryTop(count int, kind ast.ShowSlowKind) []*SlowQuer | |
} | ||
|
||
func (q *topNSlowQueries) Close() { | ||
q.mu.Lock() | ||
q.mu.closed = true | ||
q.mu.Unlock() | ||
|
||
close(q.ch) | ||
} | ||
|
||
|
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.
Is it enough to put “do.slowQuery.Close()” after line462?
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.
do.slowQuery.Close()
will make goroutine exit and WaitGroup count -1.If this line is moved to line 462,
do.wg.Wait()
would wait forever.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.
Ignore it.
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.
But I think it's useless. After this function is executed, "updateStatsWorker" may still be called by another goroutine. This problem still exists.
Maybe we can replace "ctx"(the updateStatsWorker's argument) with the session created in the sysSessionPool.
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.
Do you mean after session pool is closed,
updateStatsWorker
will be still executing ? @zimulalaThere 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.
Ye. Because the
session
used in statistic bootstrap is not get fromsession pool
. @tiancaiamaoThere 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.
Current session pool implementation will block waiting resource to be put back, so after the pool is closed, there won't be system session running. @crazycs520 @zimulala