Skip to content

dxf: separate metered traffic into object storage and cluster and fix missing cluster traffic for import-into#64523

Merged
ti-chi-bot[bot] merged 11 commits into
pingcap:masterfrom
D3Hunter:record-dxf-traffic
Nov 18, 2025
Merged

dxf: separate metered traffic into object storage and cluster and fix missing cluster traffic for import-into#64523
ti-chi-bot[bot] merged 11 commits into
pingcap:masterfrom
D3Hunter:record-dxf-traffic

Conversation

@D3Hunter

@D3Hunter D3Hunter commented Nov 17, 2025

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: ref #61702

Problem Summary:

What changed and how does it work?

  • separate metered traffic into object storge and cluster, and metering them all, and we always collect those traffic to the global sort bucket for add-index and import-into
  • make recording access stats of object storage a function of the storage pkg, instead of pass by context. we impl this for GCS/S3/KS3 for now.
  • metering cluster traffic for import-into, we don't do it previously
  • log the number of KV files we write to global sort store to help diagnose

Check List

Tests

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

when set tidb_cloud_storage_uri to S3

[2025/11/18 04:23:00.000 +00:00] [INFO] [metering.go:241] ["no metering data to flush"] [keyspaceName=SYSTEM] [component=meter] [duration=3.485µs]
[2025/11/18 04:24:00.039 +00:00] [INFO] [metering.go:252] ["succeed to write metering data"] [keyspaceName=SYSTEM] [component=meter] [duration=39.23868ms] [data="[{\"cluster_id\":\"SYSTEM\",\"cluster_write_bytes\":5002047690,\"get_requests\":2,\"obj_store_read_bytes\":9943,\"obj_store_write_bytes\":11234241470,\"put_requests\":2182,\"source_name\":\"dxf\",\"task_id\":1,\"task_type\":\"ImportInto\",\"version\":\"1\"}]"]
[2025/11/18 04:25:00.047 +00:00] [INFO] [metering.go:252] ["succeed to write metering data"] [keyspaceName=SYSTEM] [component=meter] [duration=47.675478ms] [data="[{\"cluster_id\":\"SYSTEM\",\"cluster_write_bytes\":5004356262,\"source_name\":\"dxf\",\"task_id\":1,\"task_type\":\"ImportInto\",\"version\":\"1\"}]"]
[2025/11/18 04:26:00.036 +00:00] [INFO] [metering.go:252] ["succeed to write metering data"] [keyspaceName=SYSTEM] [component=meter] [duration=36.279928ms] [data="[{\"cluster_id\":\"SYSTEM\",\"cluster_write_bytes\":1058969657,\"get_requests\":1726,\"obj_store_read_bytes\":12078406435,\"source_name\":\"dxf\",\"task_id\":1,\"task_type\":\"ImportInto\",\"version\":\"1\"}]"]
[2025/11/18 04:26:00.036 +00:00] [INFO] [metering.go:185] ["recorder unregistered and finished final flush"] [keyspaceName=SYSTEM] [component=meter] [accumulatedData="{id: 1, keyspace: SYSTEM, type: ImportInto, requests{get: 1728, put: 2182}, obj_store{r: 11.25GiB, w: 10.46GiB}, cluster{r: 0B, w: 10.31GiB}"]

when set tidb_cloud_storage_uri to KS3, the time difference is due to different resource amplify factor.

[2025/11/18 05:50:00.000 +00:00] [INFO] [metering.go:241] ["no metering data to flush"] [keyspaceName=SYSTEM] [component=meter] [duration=2.345µs]
[2025/11/18 05:51:00.045 +00:00] [INFO] [metering.go:252] ["succeed to write metering data"] [keyspaceName=SYSTEM] [component=meter] [duration=44.915921ms] [data="[{\"cluster_id\":\"SYSTEM\",\"cluster_write_bytes\":1193815663,\"get_requests\":1,\"obj_store_read_bytes\":9943,\"obj_store_write_bytes\":11234241166,\"put_requests\":2180,\"source_name\":\"dxf\",\"task_id\":2,\"task_type\":\"ImportInto\",\"version\":\"1\"}]"]
[2025/11/18 05:52:00.063 +00:00] [INFO] [metering.go:252] ["succeed to write metering data"] [keyspaceName=SYSTEM] [component=meter] [duration=63.015217ms] [data="[{\"cluster_id\":\"SYSTEM\",\"cluster_write_bytes\":1265077099,\"source_name\":\"dxf\",\"task_id\":2,\"task_type\":\"ImportInto\",\"version\":\"1\"}]"]
[2025/11/18 05:53:00.057 +00:00] [INFO] [metering.go:252] ["succeed to write metering data"] [keyspaceName=SYSTEM] [component=meter] [duration=57.098408ms] [data="[{\"cluster_id\":\"SYSTEM\",\"cluster_write_bytes\":1371390058,\"source_name\":\"dxf\",\"task_id\":2,\"task_type\":\"ImportInto\",\"version\":\"1\"}]"]
[2025/11/18 05:54:00.038 +00:00] [INFO] [metering.go:252] ["succeed to write metering data"] [keyspaceName=SYSTEM] [component=meter] [duration=38.03373ms] [data="[{\"cluster_id\":\"SYSTEM\",\"cluster_write_bytes\":1431501070,\"source_name\":\"dxf\",\"task_id\":2,\"task_type\":\"ImportInto\",\"version\":\"1\"}]"]
[2025/11/18 05:55:00.048 +00:00] [INFO] [metering.go:252] ["succeed to write metering data"] [keyspaceName=SYSTEM] [component=meter] [duration=48.795181ms] [data="[{\"cluster_id\":\"SYSTEM\",\"cluster_write_bytes\":1435424059,\"source_name\":\"dxf\",\"task_id\":2,\"task_type\":\"ImportInto\",\"version\":\"1\"}]"]
[2025/11/18 05:56:00.057 +00:00] [INFO] [metering.go:252] ["succeed to write metering data"] [keyspaceName=SYSTEM] [component=meter] [duration=57.170976ms] [data="[{\"cluster_id\":\"SYSTEM\",\"cluster_write_bytes\":1307569864,\"source_name\":\"dxf\",\"task_id\":2,\"task_type\":\"ImportInto\",\"version\":\"1\"}]"]
[2025/11/18 05:57:00.087 +00:00] [INFO] [metering.go:252] ["succeed to write metering data"] [keyspaceName=SYSTEM] [component=meter] [duration=87.248747ms] [data="[{\"cluster_id\":\"SYSTEM\",\"cluster_write_bytes\":1324189166,\"source_name\":\"dxf\",\"task_id\":2,\"task_type\":\"ImportInto\",\"version\":\"1\"}]"]
[2025/11/18 05:58:00.070 +00:00] [INFO] [metering.go:252] ["succeed to write metering data"] [keyspaceName=SYSTEM] [component=meter] [duration=70.290451ms] [data="[{\"cluster_id\":\"SYSTEM\",\"cluster_write_bytes\":1437334208,\"source_name\":\"dxf\",\"task_id\":2,\"task_type\":\"ImportInto\",\"version\":\"1\"}]"]
[2025/11/18 05:59:00.098 +00:00] [INFO] [metering.go:252] ["succeed to write metering data"] [keyspaceName=SYSTEM] [component=meter] [duration=97.899363ms] [data="[{\"cluster_id\":\"SYSTEM\",\"cluster_write_bytes\":299072422,\"get_requests\":2473,\"obj_store_read_bytes\":11477680143,\"source_name\":\"dxf\",\"task_id\":2,\"task_type\":\"ImportInto\",\"version\":\"1\"}]"]
[2025/11/18 05:59:00.098 +00:00] [INFO] [metering.go:185] ["recorder unregistered and finished final flush"] [keyspaceName=SYSTEM] [component=meter] [accumulatedData="{id: 2, keyspace: SYSTEM, type: ImportInto, requests{get: 2474, put: 2180}, obj_store{r: 10.69GiB, w: 10.46GiB}, cluster{r: 0B, w: 10.31GiB}"]
  • 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.

None

@ti-chi-bot ti-chi-bot Bot added release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 17, 2025
@tiprow

tiprow Bot commented Nov 17, 2025

Copy link
Copy Markdown

Hi @D3Hunter. 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

codecov Bot commented Nov 17, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 62.56684% with 70 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.1041%. Comparing base (c1247a0) to head (32c0b29).
⚠️ Report is 11 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #64523        +/-   ##
================================================
+ Coverage   72.6909%   75.1041%   +2.4131%     
================================================
  Files          1866       1889        +23     
  Lines        506250     516435     +10185     
================================================
+ Hits         367998     387864     +19866     
+ Misses       115882     104871     -11011     
- Partials      22370      23700      +1330     
Flag Coverage Δ
integration 48.3872% <8.0213%> (?)
unit 72.6908% <62.5668%> (+0.4263%) ⬆️

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

Components Coverage Δ
dumpling 52.8700% <ø> (+0.1132%) ⬆️
parser ∅ <ø> (∅)
br 63.2089% <72.2222%> (+17.0327%) ⬆️
🚀 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.

Comment thread br/pkg/storage/gcs.go
}

httpClient := opts.HTTPClient
if reqRec := recording.GetRequests(ctx); reqRec != nil {

@D3Hunter D3Hunter Nov 18, 2025

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.

to meter traffic, we need to have it inside object reader/writer, the old context var not fit in this scenario, so it's better pass it as a option

@GMHDBJD GMHDBJD self-requested a review November 18, 2025 06:26
Comment thread br/pkg/storage/gcs.go
@ti-chi-bot ti-chi-bot Bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Nov 18, 2025

@GMHDBJD GMHDBJD left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

rest LGTM

writer = bw.writer
}
compressedWriter := newBufferedWriter(writer, hardcodedS3ChunkSize, w.compressType)
compressedWriter := newBufferedWriter(writer, hardcodedS3ChunkSize, w.compressType, nil)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Will we lose the records of bytes/requests for compression options?

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 add a comment, this withCompression is a wrapper around ExternalStorage which will do the recording

@ti-chi-bot ti-chi-bot Bot added the lgtm label Nov 18, 2025
@ti-chi-bot

ti-chi-bot Bot commented Nov 18, 2025

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: GMHDBJD, joechenrh

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

The pull request process is described 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 approved and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Nov 18, 2025
@ti-chi-bot

ti-chi-bot Bot commented Nov 18, 2025

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2025-11-18 08:42:37.332212997 +0000 UTC m=+1120.981407453: ☑️ agreed by joechenrh.
  • 2025-11-18 10:48:25.776002762 +0000 UTC m=+8669.425197220: ☑️ agreed by GMHDBJD.

@D3Hunter

Copy link
Copy Markdown
Contributor Author

/retest

@tiprow

tiprow Bot commented Nov 18, 2025

Copy link
Copy Markdown

@D3Hunter: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/retest

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.

@joechenrh

Copy link
Copy Markdown
Contributor

/retest

@tiprow

tiprow Bot commented Nov 18, 2025

Copy link
Copy Markdown

@joechenrh: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/retest

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.

@D3Hunter

Copy link
Copy Markdown
Contributor Author

/retest

@tiprow

tiprow Bot commented Nov 18, 2025

Copy link
Copy Markdown

@D3Hunter: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/retest

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.

@D3Hunter

Copy link
Copy Markdown
Contributor Author

/retest

@tiprow

tiprow Bot commented Nov 18, 2025

Copy link
Copy Markdown

@D3Hunter: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/retest

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 ti-chi-bot Bot merged commit 4b2223c into pingcap:master Nov 18, 2025
59 of 69 checks passed
@D3Hunter D3Hunter deleted the record-dxf-traffic branch November 19, 2025 01:21
D3Hunter added a commit to D3Hunter/tidb that referenced this pull request Nov 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note-none Denotes a PR that doesn't merit a release note. 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.

3 participants