Skip to content

importinto: add SHOW RAW IMPORT JOB(S) for machine-readable stats#66502

Open
GMHDBJD wants to merge 11 commits intopingcap:masterfrom
GMHDBJD:rawImportInto
Open

importinto: add SHOW RAW IMPORT JOB(S) for machine-readable stats#66502
GMHDBJD wants to merge 11 commits intopingcap:masterfrom
GMHDBJD:rawImportInto

Conversation

@GMHDBJD
Copy link
Copy Markdown
Contributor

@GMHDBJD GMHDBJD commented Feb 26, 2026

What problem does this PR solve?

Issue Number: close #66461

Problem Summary:

Import SDK / Lightning import-into backend needs a stable, machine-friendly contract to poll IMPORT INTO job status/progress without parsing SHOW IMPORT JOBS output.

What changed and how does it work?

  • Add SHOW RAW IMPORT JOB <job_id> and SHOW RAW IMPORT JOBS [WHERE group_key = ...].
  • Return Raw_Stats as a JSON contract (RawImportJobStats) with timestamps (unix seconds) and current-step progress/ETA.
  • Wire it into Import SDK / Lightning polling.

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.

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.

Added `SHOW RAW IMPORT JOB(S)` to expose machine-friendly JSON stats for `IMPORT INTO` job polling.

@ti-chi-bot ti-chi-bot bot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Feb 26, 2026
@pantheon-ai
Copy link
Copy Markdown

pantheon-ai bot commented Feb 26, 2026

Review Complete

Findings: 2 issues
Posted: 2
Duplicates/Skipped: 0

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot bot commented Feb 26, 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 d3hunter, king-dylan, yudongusa 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

@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. sig/planner SIG: Planner labels Feb 26, 2026
@tiprow
Copy link
Copy Markdown

tiprow bot commented Feb 26, 2026

Hi @GMHDBJD. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

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.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 26, 2026

Codecov Report

❌ Patch coverage is 56.66667% with 104 lines in your changes missing coverage. Please review.
✅ Project coverage is 78.2425%. Comparing base (bce815e) to head (128c41b).
⚠️ Report is 17 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #66502        +/-   ##
================================================
+ Coverage   77.6746%   78.2425%   +0.5678%     
================================================
  Files          2006       1936        -70     
  Lines        548722     536906     -11816     
================================================
- Hits         426218     420089      -6129     
+ Misses       120844     116376      -4468     
+ Partials       1660        441      -1219     
Flag Coverage Δ
integration 44.1883% <6.7708%> (-3.9951%) ⬇️
unit 76.6293% <55.0000%> (+0.3049%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 56.7974% <ø> (ø)
parser ∅ <ø> (∅)
br 48.7840% <ø> (-12.1085%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

return err
}

loc := sctx.GetSessionVars().Location()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P2] Unix timestamps can be incorrect/unstable across sessions due to timezone mismatch

Why: SHOW RAW IMPORT JOB(S) computes *_time_unix fields using the caller session's time_zone, but the underlying TIMESTAMP(6) data is loaded via an internal session that may have a different timezone. This causes GoTime(location).Unix() to produce incorrect Unix seconds that vary across sessions with different time_zone settings, breaking the machine-readable stats contract.

Evidence: pkg/executor/show.go:2878

loc := sctx.GetSessionVars().Location()
// ... later calls BuildRawImportJobStats(loc, info, runInfo)

The internal session (taskManager.WithNewSession) doesn't sync timezone with the caller, and types.Time.GoTime(loc) interprets the stored timestamp in the provided loc, causing Unix second shifts.

Suggested fix: Compute Unix timestamps in SQL using UNIX_TIMESTAMP(create_time) or consistently convert using the internal session's timezone, not the caller's.

}
// JobStatus is a machine-friendly contract returned by SHOW RAW IMPORT JOB(S).
// It is a type alias to keep the contract centralized in one place.
type JobStatus = importer.RawImportJobStats
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[P2] Breaking change to public SDK API - importsdk.JobStatus type alias

Why: importsdk.JobStatus was changed from a standalone struct to a type alias of importer.RawImportJobStats, which removes/renames public fields (ResultMessage, SourceFileSize, time.Time timestamps). This breaks compilation for external SDK consumers relying on these fields.

Evidence: pkg/importsdk/model.go:79

type JobStatus = importer.RawImportJobStats

Previously (commit 0f706ff), JobStatus was a struct with fields like SourceFileSize string, ResultMessage string, and time.Time timestamps. The new RawImportJobStats has different field names/types (e.g., SourceFileSizeBytes, ErrorMessage, unix timestamps).

Suggested fix: Keep the old JobStatus struct for backward compatibility, or introduce a new type (e.g., RawJobStatus) to avoid breaking downstream consumers.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think downstream updates should modify the corresponding code based on this update.

@ti-chi-bot
Copy link
Copy Markdown

ti-chi-bot bot commented Feb 26, 2026

@GMHDBJD: 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
pull-integration-realcluster-test-next-gen 128c41b link true /test pull-integration-realcluster-test-next-gen
idc-jenkins-ci-tidb/check_dev_2 128c41b link true /test check-dev2

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.

@GMHDBJD GMHDBJD mentioned this pull request Apr 2, 2026
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

importinto: add SHOW RAW IMPORT JOB(S) for machine-friendly job stats

1 participant