Skip to content

executor: keep analyze status remaining time in UTC (#67229)#67516

Open
ti-chi-bot wants to merge 1 commit into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-67229-to-release-8.5
Open

executor: keep analyze status remaining time in UTC (#67229)#67516
ti-chi-bot wants to merge 1 commit into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-67229-to-release-8.5

Conversation

@ti-chi-bot
Copy link
Copy Markdown
Member

@ti-chi-bot ti-chi-bot commented Apr 2, 2026

This is an automated cherry-pick of #67229

What problem does this PR solve?

Issue Number: close #67230

Problem Summary:

SHOW ANALYZE STATUS can report a negative Remaining_seconds when the session time_zone is ahead of UTC.

What changed and how does it work?

Keep the UTC start_time for remaining-time calculation and continue using the session-local time only for display. This PR also adds a regression test that reproduces the negative duration under +08:00.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Validation commands:

  • make failpoint-enable
  • go test -run '^TestShowAnalyzeStatus$' -tags=intest,deadlock ./pkg/executor
  • make failpoint-disable
  • make lint

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.

Fix negative Remaining_seconds in SHOW ANALYZE STATUS when the session time_zone is ahead of UTC.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Fixed remaining-duration calculation in ANALYZE status display to accurately reflect elapsed time across different timezone configurations.

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR. labels Apr 2, 2026
@ti-chi-bot
Copy link
Copy Markdown
Member Author

@0xPoe This PR has conflicts, I have hold it.
Please resolve them or ask others to resolve them, then comment /unhold to remove the hold label.

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 2, 2026

This cherry pick PR is for a release branch and has not yet been approved by triage owners.
Adding the do-not-merge/cherry-pick-not-approved label.

To merge this cherry pick:

  1. It must be LGTMed and approved by the reviewers firstly.
  2. For pull requests to TiDB-x branches, it must have no failed tests.
  3. AFTER it has lgtm and approved labels, please wait for the cherry-pick merging approval from triage owners.
Details

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-sigs/prow repository.

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 2, 2026

@ti-chi-bot: ## If you want to know how to resolve it, please read the guide in TiDB Dev Guide.

Details

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 ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 2, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign eurekaka for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 10a8c557-d529-48be-9351-5498d78d7530

📥 Commits

Reviewing files that changed from the base of the PR and between d64cd8c and 91be411.

📒 Files selected for processing (2)
  • pkg/executor/infoschema_reader.go
  • pkg/executor/show_stats_test.go

📝 Walkthrough

Walkthrough

Fixed a timezone-related bug in SHOW ANALYZE STATUS where remaining-duration calculations incorrectly reused session-timezone-converted timestamps as UTC values. Separated the job start time into a local-display value and a UTC-based value for accurate remaining-duration computation, with corresponding test validation.

Changes

Cohort / File(s) Summary
Timezone bug fix in executor
pkg/executor/infoschema_reader.go
Split job start timestamp into startTime (local-time display) and startTimeUTC (UTC *time.Time). Updated remaining-duration calculation to validate and use startTimeUTC directly in time.Since() rather than converting a session-timezone-adjusted value as if it were UTC.
Test coverage for timezone handling
pkg/executor/show_stats_test.go
Updated TestShowAnalyzeStatus to expect 3 rows instead of 2 post-analyze assertions. Added test setup/teardown with table t3 using time_zone = '+08:00', inserting a running analyze job with start_time = CURRENT_TIMESTAMP - INTERVAL 1 MINUTE, and validating remaining-duration field is >= 0.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~23 minutes

Possibly related PRs

  • #67229 — Identical changes to pkg/executor/infoschema_reader.go and pkg/executor/show_stats_test.go addressing the same timezone handling issue.

Suggested labels

needs-cherry-pick-release-8.5, affects-8.5

Suggested reviewers

  • 0xPoe
  • winoros
  • mjonss

Poem

🐰 A timestamp's tale in timezones deep,
UTC values we now shall keep,
No more negative seconds in sight,
When '+08:00' shines bright! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: keeping analyze status remaining time in UTC, which directly addresses the bug being fixed.
Description check ✅ Passed The description follows the repository template with complete sections including issue number, problem summary, what changed, test validation checklist, and release note.
Linked Issues check ✅ Passed The code changes fully address issue #67230 by fixing the bug where negative Remaining_seconds occurred. The implementation keeps UTC start_time for calculation while preserving session-local time for display, matching the issue's root cause analysis.
Out of Scope Changes check ✅ Passed All code changes in the PR are directly related to fixing the negative remaining duration bug. The modifications to infoschema_reader.go and test additions are scoped to the stated objective.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.11.4)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@tiprow
Copy link
Copy Markdown

tiprow Bot commented Apr 2, 2026

@ti-chi-bot: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
fast_test_tiprow_for_release 91be411 link true /test fast_test_tiprow_for_release

Full PR test history. Your PR dashboard.

Details

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-sigs/prow repository. I understand the commands that are listed here.

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot Bot commented Apr 2, 2026

@ti-chi-bot: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/unit-test 91be411 link true /test unit-test
idc-jenkins-ci-tidb/build 91be411 link true /test build
idc-jenkins-ci-tidb/check_dev_2 91be411 link true /test check-dev2
idc-jenkins-ci-tidb/check_dev 91be411 link true /test check-dev
idc-jenkins-ci-tidb/mysql-test 91be411 link true /test mysql-test

Full PR test history. Your PR dashboard.

Details

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-sigs/prow repository. I understand the commands that are listed here.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 2, 2026

Caution

Review failed

An error occurred during the review process. Please try again later.

📝 Walkthrough

Walkthrough

Fixed a timezone-related bug in SHOW ANALYZE STATUS where remaining-duration calculations incorrectly reused session-timezone-converted timestamps as UTC values. Separated the job start time into a local-display value and a UTC-based value for accurate remaining-duration computation, with corresponding test validation.

Changes

Cohort / File(s) Summary
Timezone bug fix in executor
pkg/executor/infoschema_reader.go
Split job start timestamp into startTime (local-time display) and startTimeUTC (UTC *time.Time). Updated remaining-duration calculation to validate and use startTimeUTC directly in time.Since() rather than converting a session-timezone-adjusted value as if it were UTC.
Test coverage for timezone handling
pkg/executor/show_stats_test.go
Updated TestShowAnalyzeStatus to expect 3 rows instead of 2 post-analyze assertions. Added test setup/teardown with table t3 using time_zone = '+08:00', inserting a running analyze job with start_time = CURRENT_TIMESTAMP - INTERVAL 1 MINUTE, and validating remaining-duration field is >= 0.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~23 minutes

Possibly related PRs

  • #67229 — Identical changes to pkg/executor/infoschema_reader.go and pkg/executor/show_stats_test.go addressing the same timezone handling issue.

Suggested labels

needs-cherry-pick-release-8.5, affects-8.5

Suggested reviewers

  • 0xPoe
  • winoros
  • mjonss

Poem

🐰 A timestamp's tale in timezones deep,
UTC values we now shall keep,
No more negative seconds in sight,
When '+08:00' shines bright! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: keeping analyze status remaining time in UTC, which directly addresses the bug being fixed.
Description check ✅ Passed The description follows the repository template with complete sections including issue number, problem summary, what changed, test validation checklist, and release note.
Linked Issues check ✅ Passed The code changes fully address issue #67230 by fixing the bug where negative Remaining_seconds occurred. The implementation keeps UTC start_time for calculation while preserving session-local time for display, matching the issue's root cause analysis.
Out of Scope Changes check ✅ Passed All code changes in the PR are directly related to fixing the negative remaining duration bug. The modifications to infoschema_reader.go and test additions are scoped to the stated objective.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/cherry-pick-not-approved do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants