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

executor: add remain time for showAnalyzeStatus #43866

Merged
merged 22 commits into from May 25, 2023

Conversation

hawkingrei
Copy link
Member

@hawkingrei hawkingrei commented May 16, 2023

What problem does this PR solve?

Issue Number: close #44033

Problem Summary:

What is changed and how it works?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot
Copy link

ti-chi-bot bot commented May 16, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • qw4990
  • xuyifangreeneyes

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-linked-issue release-note-none size/M Denotes a PR that changes 30-99 lines, ignoring generated files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels May 16, 2023
@hawkingrei hawkingrei force-pushed the add_remain_time_for_analyze branch 3 times, most recently from 8793f1b to 01b9751 Compare May 17, 2023 07:23
@xuyifangreeneyes xuyifangreeneyes self-requested a review May 17, 2023 08:47
@hawkingrei hawkingrei force-pushed the add_remain_time_for_analyze branch from 654e989 to 6fe1de5 Compare May 19, 2023 09:09
@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. do-not-merge/needs-linked-issue labels May 19, 2023
// setDataForAnalyzeStatus gets all the analyze jobs.
func (e *memtableRetriever) setDataForAnalyzeStatus(sctx sessionctx.Context) (err error) {
e.rows, err = dataForAnalyzeStatusHelper(sctx)
e.rows, err = dataForAnalyzeStatusHelper(sctx, false)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it is also ok to add those fields for information_schema.analyze_status.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, As the changes are extensive, it may be difficult to review all of them within a single pull request. information_schema.analyze_status will be in the next PR.

@hawkingrei hawkingrei force-pushed the add_remain_time_for_analyze branch 3 times, most recently from 4608f72 to be97a66 Compare May 24, 2023 16:35
@hawkingrei
Copy link
Member Author

/retest

pt := tb.Meta().GetPartitionInfo()
tid = pt.GetPartitionIDByName(partitionName)
} else {
statsTable := statistics.PseudoTable(tb.Meta())
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe here we can call domain.GetDomain(sctx).StatsHandle().GetPartitionStats(tbl.Meta(), tid) for both partition and non-partitioned table. (*Handle).GetTableStats is just a thin wrapper of (*Handle).GetPartitionStats.

Copy link
Member Author

Choose a reason for hiding this comment

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

OK, I have refactored it.

@hawkingrei hawkingrei force-pushed the add_remain_time_for_analyze branch from 8e57c73 to 5804ddb Compare May 25, 2023 03:48
pt := meta.GetPartitionInfo()
tid = pt.GetPartitionIDByName(partitionName)
statsTbl = statsHandle.GetPartitionStats(meta, tid)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that we need to exchange the two branches.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

regionStats.Count = 1
// Set a very large approximate count.
regionStats.StorageKeys = 1000000
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Will we add some tests using the failpoint?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I will add tests by the other PR. This failpoint is from the old test.

Copy link
Member Author

Choose a reason for hiding this comment

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

I hope it can be merged and included in today's nightly version so that I can test it manually.

Copy link
Contributor

@xuyifangreeneyes xuyifangreeneyes left a comment

Choose a reason for hiding this comment

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

rest LGTM

@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label May 25, 2023
@hawkingrei hawkingrei requested a review from qw4990 May 25, 2023 06:52
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
@hawkingrei hawkingrei force-pushed the add_remain_time_for_analyze branch from 7b522f8 to da40a2c Compare May 25, 2023 11:12
@ti-chi-bot ti-chi-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 25, 2023
@hawkingrei
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels May 25, 2023
@qw4990 qw4990 added the sig/planner SIG: Planner label May 25, 2023
@hawkingrei
Copy link
Member Author

/merge

@ti-chi-bot
Copy link

ti-chi-bot bot commented May 25, 2023

This pull request has been accepted and is ready to merge.

Commit hash: da40a2c

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label May 25, 2023
@hawkingrei
Copy link
Member Author

/retest

@ti-chi-bot ti-chi-bot bot merged commit 557167e into pingcap:master May 25, 2023
11 checks passed
@hawkingrei hawkingrei deleted the add_remain_time_for_analyze branch May 25, 2023 16:05
}
}
if tid > 0 && totalCnt == 0 {
totalCnt, _ = internalutil.GetApproximateTableCountFromStorage(sctx, tid, dbName, tableName, partitionName)
Copy link
Contributor

Choose a reason for hiding this comment

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

This func will be called at getAdjustedSampleRate when we do the first analyze, and called again when show analyze status, right? Can we reuse, like persisting the ApproximateTableCount somewhere?

Copy link
Contributor

Choose a reason for hiding this comment

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

UI will call showAnalyzeStatus many times to get fresh status. I'm afraid there will be frequent calls to internalutil.GetApproximateTableCountFromStorage.

duration = 1 * time.Second
}
i := float64(remainLine) * duration.Seconds() / float64(processedRows)
persentage := float64(processedRows) / float64(totalCnt)
Copy link
Contributor

Choose a reason for hiding this comment

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

typo: persentage-> percentage

instance, // INSTANCE
procID, // PROCESS_ID
remainDurationStr, // REMAINING_SECONDS
progressStr, // PROGRESS
Copy link
Contributor

@chrysan chrysan Jun 15, 2023

Choose a reason for hiding this comment

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

It's better to be a numeric type for UI to easily parse and aggregate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none sig/planner SIG: Planner size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

more information in the analyze status
4 participants