-
Notifications
You must be signed in to change notification settings - Fork 210
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
tikvrpc: avoid data race on XxxRequest.Context
#1242
Conversation
Signed-off-by: zyguan <zhongyangguan@gmail.com>
Signed-off-by: zyguan <zhongyangguan@gmail.com>
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.
Rest LGTM
Signed-off-by: zyguan <zhongyangguan@gmail.com>
@@ -118,6 +118,11 @@ const ( | |||
CmdEmpty CmdType = 3072 + iota | |||
) | |||
|
|||
// CmdType aliases. | |||
const ( | |||
CmdGetKeyTTL = CmdRawGetKeyTTL |
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.
😰
} else { | ||
cmd := *req.${cmd}() | ||
cmd.Context = ctx | ||
req.Req = &cmd |
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.
May there still be data race on the reading/writing the pointer req.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.
No, I only see the data race on the value refered by the pointer, AFAIK, there is no concurrent access to the pointer field itself.
Signed-off-by: zyguan <zhongyangguan@gmail.com>
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.
The chagne LGTM. Needs to figure out what's wrong in the unit test..
Does this have anything to do with this PR? |
@zyguan PTAL |
Signed-off-by: zyguan <zhongyangguan@gmail.com>
* tikvrpc: avoid data race on `XxxRequest.Context` Signed-off-by: zyguan <zhongyangguan@gmail.com> * fix grammar of codegen comment Signed-off-by: zyguan <zhongyangguan@gmail.com> * address comments Signed-off-by: zyguan <zhongyangguan@gmail.com> * check diff of go generate Signed-off-by: zyguan <zhongyangguan@gmail.com> * fix a typo Signed-off-by: zyguan <zhongyangguan@gmail.com> --------- Signed-off-by: zyguan <zhongyangguan@gmail.com>
* tikvrpc: avoid data race on `XxxRequest.Context` * fix grammar of codegen comment * address comments * check diff of go generate * fix a typo --------- Signed-off-by: zyguan <zhongyangguan@gmail.com>
Try to fix pingcap/tidb#51921 . To reduce the memory allocation overhead, only do COW when
req.rev > 0
.