Skip to content

disagg: Add O11y on object store usage summary of each tiflash store#10764

Merged
ti-chi-bot[bot] merged 5 commits intopingcap:masterfrom
JaySon-Huang:obj-store-usage-summary
Mar 24, 2026
Merged

disagg: Add O11y on object store usage summary of each tiflash store#10764
ti-chi-bot[bot] merged 5 commits intopingcap:masterfrom
JaySon-Huang:obj-store-usage-summary

Conversation

@JaySon-Huang
Copy link
Copy Markdown
Contributor

@JaySon-Huang JaySon-Huang commented Mar 23, 2026

What problem does this PR solve?

Issue Number: ref #10763

Problem Summary:

  • We need continuous and low-noise observability for remote object-store usage per TiFlash store.
  • Existing S3GC visibility is insufficient to quickly compare expected valid data size vs real object-store footprint.
  • We also need this summary collection to be configurable and safe for production overhead.

What is changed and how it works?

disagg: add configurable owner-only S3 storage summary and per-store usage metrics
  • Add periodic S3 storage summary in S3GCManagerService:

  • Add graceful shutdown behavior during summary scan:

    • getStoreStorageSummary checks shutdown_called in listPrefix loop and exits early.
  • Add per-store summary metrics:

    • New gauge family:
      • tiflash_storage_s3_store_summary_bytes{store_id, type}
      • type in {data_file_bytes, dt_file_bytes}
    • Metrics are updated after each getStoreStorageSummary completion.
  • Wire configuration from settings to S3GC config:

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
# Run chbenchmark workload and check the metrics of `prelock_keys` and OSS usage
tiup bench ch --host 10.2.12.81 -P 8081 --warehouses 8000 run -D chbenchmark8k -T 50 -t 0 --time 30m --ignore-error --queries q1
# Before the fix, from 23:29 to 00:00, the number of prelock_keys in memory would accumulate and increase with the write load; after the fix, from 02:00 to 02:30, there was no longer any persistent residue of prelock_keys in memory.
# Also can check the new added grafana panel "Remote Store Summary (Disagg arch)"
image image - [ ] 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

Add configurable owner-only periodic S3 storage summary and per-store summary metrics (`tiflash_storage_s3_store_summary_bytes`) for TiFlash disaggregated S3GC observability.

Summary by CodeRabbit

  • New Features

    • Added per-store S3 storage summary metrics for data and index file sizes.
    • Added configurable periodic S3 summary collection (default 24h; ≤0 disables).
    • New Grafana panels: Remote Store Summary, Local Lock Manager status, and Local Lock Manager QPS.
  • Documentation

    • Updated dashboard layout and panel organization for improved metric visibility.

@ti-chi-bot ti-chi-bot bot added the release-note-none Denotes a PR that doesn't merit a release note. label Mar 23, 2026
@pantheon-ai
Copy link
Copy Markdown

pantheon-ai bot commented Mar 23, 2026

Review Complete

Findings: 6 issues
Posted: 4
Duplicates/Skipped: 4

ℹ️ Learn more details on Pantheon AI.

@ti-chi-bot ti-chi-bot bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Mar 23, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 23, 2026

📝 Walkthrough

Walkthrough

Adds periodic remote S3 storage summary reporting: new setting to control interval, S3 GC manager/service ownership and scheduling for a periodic summary task, and Prometheus metrics to record per-store data and DT file byte totals.

Changes

Cohort / File(s) Summary
Metrics Infrastructure
dbms/src/Common/TiFlashMetrics.h, dbms/src/Common/TiFlashMetrics.cpp
Added Prometheus gauge family tiflash_storage_s3_store_summary_bytes, per-store metric storage, and setS3StoreSummaryBytes() with shared/unique-lock lazy initialization and updates for data_file_bytes and dt_file_bytes.
Configuration
dbms/src/Interpreters/Settings.h
Added SettingInt64 remote_summary_interval_seconds (default 0) to control periodic remote S3 summary collection; <=0 disables periodic task.
S3 GC Manager & Service
dbms/src/Storages/S3/S3GCManager.h, dbms/src/Storages/S3/S3GCManager.cpp
Added S3GCConfig::summary_interval_seconds, S3GCManager::isOwner(), S3GCManagerService::summary_timer; getStoreStorageSummary exits early on shutdown, reports metrics via TiFlashMetrics, schedules periodic summary when configured and owner, and handles shutdown/exception cases.
Context Initialization
dbms/src/Storages/KVStore/TMTContext.cpp
Passes remote_summary_interval_seconds from settings into S3 GC config during initS3GCManager.
Observability / Dashboard
metrics/grafana/tiflash_summary.json
Added/adjusted Grafana panels including new "Remote Store Summary" panel querying the new metric; layout and alert tweaks across the dashboard.

Sequence Diagram

sequenceDiagram
    participant BP as BackgroundProcessingPool
    participant SVC as S3GCManagerService
    participant MGR as S3GCManager
    participant S3 as S3 Storage
    participant Metrics as TiFlashMetrics

    rect rgba(100,200,150,0.5)
    Note over SVC: Periodic Summary Task
    BP->>SVC: run scheduled task
    SVC->>MGR: isOwner()?
    MGR-->>SVC: owner status
    alt manager is owner
        SVC->>MGR: getStoreStorageSummary(store_id)
        MGR->>S3: list objects (abort if shutdown)
        S3-->>MGR: object metadata
        MGR->>MGR: compute data_file.bytes & dt_file.bytes
        MGR->>Metrics: setS3StoreSummaryBytes(store_id, data, dt)
        Metrics->>Metrics: lazy-create/update per-store gauges
        Metrics-->>MGR: metrics recorded
    else not owner or shutdown
        SVC-->>BP: skip/stop scheduling
    end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

size/L

Suggested reviewers

  • CalvinNeo
  • JinheLin

Poem

🐰 I hop through buckets, counting bytes by score,

Per-store and DT, I tally more and more,
Timers tick, owners nod, metrics take their place,
A rabbit's cheer for tidy storage space,
Hooray for summaries, and one more carrot, por favor!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 5.56% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding observability (O11y) for object store usage summary metrics per TiFlash store, which directly aligns with the PR's core objective.
Description check ✅ Passed The pull request description is comprehensive and well-structured, following the template with clear problem statement, detailed technical changes, testing checklist, and release notes.

✏️ 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.

@ti-chi-bot ti-chi-bot bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed release-note-none Denotes a PR that doesn't merit a release note. labels Mar 23, 2026
Signed-off-by: JaySon-Huang <tshent@qq.com>
@ti-chi-bot ti-chi-bot bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 23, 2026
@JaySon-Huang JaySon-Huang requested a review from Copilot March 23, 2026 07:29
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@metrics/grafana/tiflash_summary.json`:
- Line 1116: The dashboard currently sets the panel option "nullPointMode":
"null as zero" for the owner-only remote-summary metric, which causes missing
summaries to display as 0 B; change the JSON to stop turning nulls into zeros by
replacing "nullPointMode": "null as zero" with a non-zero-filling mode (e.g.,
"nullPointMode": "null as null") or remove the nullPointMode entry for the
remote-summary panels (the JSON key is "nullPointMode" in tiflash_summary.json
where the remote-summary metric is defined).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f03894c1-c201-42c1-8324-238a765dfe8e

📥 Commits

Reviewing files that changed from the base of the PR and between f505e23 and 0df2268.

📒 Files selected for processing (1)
  • metrics/grafana/tiflash_summary.json

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds owner-only, configurable periodic S3 object-store usage summarization for TiFlash disaggregated mode, exporting per-store usage as Prometheus metrics and surfacing it on the Grafana summary dashboard to improve low-noise observability of remote footprint.

Changes:

  • Add configurable periodic S3 storage summary scheduling to S3GCManagerService (owner-only; disabled when interval ≤ 0) and early-exit behavior during shutdown.
  • Introduce new Prometheus gauge family tiflash_storage_s3_store_summary_bytes{store_id,type} and update it after each per-store summary scan.
  • Wire a new setting remote_summary_interval_seconds (default 24h) through TMTContext into S3GC config, and update Grafana dashboard panels.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
metrics/grafana/tiflash_summary.json Adds panels for remote store summary metric and adjusts dashboard layout.
dbms/src/Storages/S3/S3GCManager.h Extends S3GC config with summary interval and adds owner-check API + service task handle.
dbms/src/Storages/S3/S3GCManager.cpp Implements owner check, shutdown-aware listing break, per-store metric update, and periodic summary task scheduling/shutdown.
dbms/src/Storages/KVStore/TMTContext.cpp Wires the new settings value into S3GCConfig.
dbms/src/Interpreters/Settings.h Introduces remote_summary_interval_seconds setting (default 24h, ≤0 disables).
dbms/src/Common/TiFlashMetrics.h Declares setter and storage for per-store summary gauge metrics.
dbms/src/Common/TiFlashMetrics.cpp Registers the new gauge family and implements setS3StoreSummaryBytes.
Comments suppressed due to low confidence (1)

metrics/grafana/tiflash_summary.json:13769

  • In this panel, seriesOverrides contains an override with an empty alias and sets yaxis: 2, while the panel only has a single target (tiflash_storage_io_limiter_pending_count rate) that should use the left "ops" axis. This override is effectively dead configuration and the right Y-axis is formatted as seconds but has no series mapped to it. Consider removing the unused override and the unused seconds Y-axis (or reintroduce the intended duration series if that was the goal) to avoid confusion when editing the dashboard later.
          "seriesOverrides": [
            {
              "alias": "",
              "yaxis": 2
            }
          ],
          "spaceLength": 10,
          "stack": false,
          "steppedLine": false,
          "targets": [
            {
              "exemplar": true,
              "expr": "sum(rate(tiflash_storage_io_limiter_pending_count{k8s_cluster=\"$k8s_cluster\", tidb_cluster=\"$tidb_cluster\", instance=~\"$instance\", instance=~\"$tiflash_role\"}[1m])) by (type, instance)",
              "format": "time_series",
              "instant": false,
              "interval": "",
              "intervalFactor": 2,
              "legendFormat": "{{type}}-{{instance}}",
              "refId": "A"
            }
          ],
          "thresholds": [],
          "timeFrom": null,
          "timeRegions": [],
          "timeShift": null,
          "title": "I/O Limiter Pending Rate",
          "tooltip": {
            "shared": true,
            "sort": 0,
            "value_type": "individual"
          },
          "type": "graph",
          "xaxis": {
            "buckets": null,
            "mode": "time",
            "name": null,
            "show": true,
            "values": []
          },
          "yaxes": [
            {
              "decimals": 0,
              "format": "ops",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": "0",
              "show": true
            },
            {
              "format": "s",
              "label": null,
              "logBase": 1,
              "max": null,
              "min": null,
              "show": true
            }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: JaySon-Huang <tshent@qq.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
dbms/src/Interpreters/Settings.h (1)

243-243: Use camelCase for the new C++ setting field name.

remote_summary_interval_seconds introduces a new snake_case C++ member. Please rename it to camelCase (for example, remoteSummaryIntervalSeconds) and keep external config-key mapping explicit where needed.

As per coding guidelines, Method and variable names in C++ must use camelCase (e.g., readBlock, totalBytes).

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@dbms/src/Interpreters/Settings.h` at line 243, Rename the C++ setting
identifier remote_summary_interval_seconds to camelCase
remoteSummaryIntervalSeconds (the SettingInt64 declaration using
remote_summary_interval_seconds should be updated to
remoteSummaryIntervalSeconds) and ensure the external config key remains
explicit (keep the string "remote_summary_interval_seconds" as the config name
or add an explicit mapping initializer if required) so only the C++ member
follows camelCase while external configuration key stays unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@dbms/src/Interpreters/Settings.h`:
- Line 243: Rename the C++ setting identifier remote_summary_interval_seconds to
camelCase remoteSummaryIntervalSeconds (the SettingInt64 declaration using
remote_summary_interval_seconds should be updated to
remoteSummaryIntervalSeconds) and ensure the external config key remains
explicit (keep the string "remote_summary_interval_seconds" as the config name
or add an explicit mapping initializer if required) so only the C++ member
follows camelCase while external configuration key stays unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f0d5407e-e2cf-41f4-9f93-e0b8c1e2d663

📥 Commits

Reviewing files that changed from the base of the PR and between 0df2268 and 97fbfcc.

📒 Files selected for processing (2)
  • dbms/src/Interpreters/Settings.h
  • dbms/src/Storages/S3/S3GCManager.cpp
✅ Files skipped from review due to trivial changes (1)
  • dbms/src/Storages/S3/S3GCManager.cpp

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Mar 23, 2026
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Mar 23, 2026
@ti-chi-bot
Copy link
Copy Markdown
Contributor

ti-chi-bot bot commented Mar 23, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-03-23 08:40:26.009844934 +0000 UTC m=+171222.045915194: ☑️ agreed by CalvinNeo.
  • 2026-03-23 08:43:55.00134353 +0000 UTC m=+171431.037413790: ☑️ agreed by JinheLin.

@JaySon-Huang
Copy link
Copy Markdown
Contributor Author

/cherry-pick release-nextgen-20251011

@ti-chi-bot
Copy link
Copy Markdown
Member

@JaySon-Huang: once the present PR merges, I will cherry-pick it on top of release-nextgen-20251011 in the new PR and assign it to you.

Details

In response to this:

/cherry-pick release-nextgen-20251011

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
Contributor

ti-chi-bot bot commented Mar 23, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CalvinNeo, JinheLin, yudongusa

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 the approved label Mar 23, 2026
@ti-chi-bot ti-chi-bot bot merged commit 9433514 into pingcap:master Mar 24, 2026
8 checks passed
ti-chi-bot pushed a commit to ti-chi-bot/tiflash that referenced this pull request Mar 24, 2026
Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Copy Markdown
Member

@JaySon-Huang: new pull request created to branch release-nextgen-20251011: #10768.
But this PR has conflicts, please resolve them!

Details

In response to this:

/cherry-pick release-nextgen-20251011

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.

@JaySon-Huang JaySon-Huang deleted the obj-store-usage-summary branch March 24, 2026 01:37
ti-chi-bot bot pushed a commit that referenced this pull request Mar 25, 2026
…10764) (#10768)

ref #10763

disagg: add configurable owner-only S3 storage summary and per-store usage metrics

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Signed-off-by: JaySon-Huang <tshent@qq.com>

Co-authored-by: JaySon <tshent@qq.com>
Co-authored-by: JaySon-Huang <tshent@qq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note Denotes a PR that will be considered when it comes time to generate release notes. 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.

6 participants