-
Notifications
You must be signed in to change notification settings - Fork 759
client: add lock in tso.Request to avoid data race #10130
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
base: master
Are you sure you want to change the base?
Changes from 4 commits
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 |
|---|---|---|
|
|
@@ -174,13 +174,15 @@ func (c *Cli) scheduleUpdateTSOConnectionCtxs() { | |
| func (c *Cli) GetTSORequest(ctx context.Context) *Request { | ||
| req := c.tsoReqPool.Get().(*Request) | ||
| // Set needed fields in the request before using it. | ||
| req.mu.Lock() | ||
|
Member
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. Will it cause performance regression?
Member
Author
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. Let's wait a test result. I will do it.
Member
Author
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. Almost -2% performance regression. Can we accept it? cc @JmPotato
Member
Author
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. One more test after applying this comment #10130 (comment), the conclusion remains unchanged
Member
Author
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. |
||
| req.start = time.Now() | ||
| req.pool = c.tsoReqPool | ||
| req.requestCtx = ctx | ||
| req.clientCtx = c.ctx | ||
| req.physical = 0 | ||
| req.logical = 0 | ||
| req.streamID = "" | ||
| req.mu.Unlock() | ||
| return req | ||
| } | ||
|
|
||
|
|
||
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.
Here the
physical,logical,streamID, and other fields are reset, but thedonechannel is not reset. A req taken from the pool may have leftover data in its done channel. However, this isn’t an issue introduced by this PR, but it’s worth keeping an eye on.