-
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
*: Modify tidb/executor to implement plan recreator #26381
base: master
Are you sure you want to change the base?
Conversation
[REVIEW NOTIFICATION] This pull request has not been approved. To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
No release note, Please follow https://github.com/pingcap/community/blob/master/contributors/release-note-checker.md |
No release note, Please follow https://github.com/pingcap/community/blob/master/contributors/release-note-checker.md |
No release note, Please follow https://github.com/pingcap/community/blob/master/contributors/release-note-checker.md |
Blocked by parser pull request. |
executor/plan_recreator.go
Outdated
|
||
// Dump bindings | ||
normSql, _ := parser.NormalizeDigest(e.ExecStmt.Text()) | ||
recordSets, err = e.Ctx.(sqlexec.SQLExecutor).Execute(context.TODO(), fmt.Sprintf("show bindings where Original_sql='%s'", normSql)) |
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.
I think we‘d better dump all bindings.
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.
Done in the new commit.
@zhuo-zhi: Adding the "do-not-merge/release-note-label-needed" label because no release-note block was detected, please follow our release note process to remove it. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Moved some code to pr #26700 |
return sRows, nil | ||
} | ||
|
||
func getRows4Test(ctx context.Context, rs sqlexec.RecordSet) ([]chunk.Row, error) { |
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.
Can we use DrainRecordSet()
directly? I think they're similar.
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.
It's only used for oom action.
Co-authored-by: Zhou Kunqin <[email protected]>
} | ||
return in, true | ||
} | ||
|
||
// planRecreatorVarKeyType is a dummy type to avoid naming collision in context. | ||
type planRecreatorVarKeyType int |
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.
Can this variable be removed?
result := newFirstChunk(e) | ||
result.AppendString(0, res) | ||
req.Append(result, 0, 1) |
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.
We can directly use req.AppendString(0, res)
here.
} | ||
|
||
// Create zip file | ||
startTime := time.Now() | ||
fileName := fmt.Sprintf("recreator_single_%v.zip", startTime.UnixNano()) | ||
zf, err := os.Create(recreatorPath + "/" + fileName) | ||
zf, err := os.Create(path + "/" + fileName) |
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.
Please use filepath.Join(path, fileName)
here, which is safer than path + "/" + fileName
.
@@ -145,7 +177,7 @@ func (e *PlanRecreatorSingleInfo) dumpSingle() (string, error) { | |||
TList := val.(fileList).TokenMap | |||
for k, v := range Flist { | |||
if time.Since(v.StartTime).Minutes() > remainedInterval { | |||
err := os.Remove(recreatorPath + "/" + k) | |||
err := os.Remove(path + "/" + k) |
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.
ditto
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.
Please add some test cases for this feature, you can refer to select ... into outfile
TestSelectIntoOutfileFromTable
.
ExecStmt ast.StmtNode | ||
Analyze bool | ||
Load bool | ||
File string |
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.
These fields seem not be used?
if s.Value(executor.PlanRecreatorFileList) != nil { | ||
executor.CleanUpPlanRecreatorFile(s.GetSessionVars().ConnectionID) | ||
} |
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.
Does this mean if the client closed this session, the file would be no longer available? Is this expected?
return nil | ||
} | ||
|
||
func resultSetToStringSlice(ctx context.Context, rs sqlexec.RecordSet) ([][]string, error) { |
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.
Seems we can directly use ResultSetToStringSlice
from the session package?
Also please fix the lint error. |
@zhuo-zhi: PR needs rebase. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
What problem does this PR solve?
Issue Number: close #26335, subitem of #26325
Problem Summary:
What is changed and how it works?
Check List
Tests
Side effects
Documentation
Release note