yujun777 opened a new pull request, #71199:
URL: https://github.com/apache/doris/pull/71199
### Background
OLAP Table Streams track per-partition consumption progress as committed TSO
offsets in FE metadata (shared-nothing mode) or in MetaService (cloud mode). PR
#71062 added `ChangelogMonitor` on the Master FE to periodically publish an
immutable `ChangelogMonitorSnapshot` for `/metrics` scraping without holding
metadata locks or issuing RPCs on the scrape path. Until now,
`ChangelogMonitor` sampled only IVM refresh summaries, and
`information_schema.table_stream_consumption` exposed only raw TSO offsets and
TSO deltas.
### What problem does this PR solve?
Issue Number: None
Related PR: #71062 (Master FE ChangelogMonitor snapshot framework), #67820
(columns_name rolling-upgrade pattern)
PR Type: Enhancement
Problem Summary:
Operators cannot alert on how long unconsumed changes have waited in an OLAP
Table Stream or whether a stream's checkpoint can still resume within
`changelog.ttl_seconds`. This PR extends `ChangelogMonitor` to batch-sample
OLAP Table Streams in shared-nothing and cloud modes, exports
`doris_fe_stream_pending_age_seconds` and `doris_fe_stream_can_resume` on
Master FE `/metrics`, and appends `PENDING_AGE_SECONDS`, `CAN_RESUME`, and
`UNRESUMABLE_REASON` to `information_schema.table_stream_consumption`. About
40% of the diff (+748 lines) is FE/BE unit and regression tests; the rest
handles shared TTL resumability validation, in-memory pending-age tracking,
lock-free cloud batch RPC sampling, and rolling-upgrade schema compatibility.
Existing queries stay backward compatible during rolling upgrades.
### Details
- **Change map:** +1,050/-71 lines production code (15 files); +748/-1 lines
tests (8 files).
- Shared resumability checker (`StreamResumabilityChecker`,
`ChangelogUtils`, `NormalizeOlapTableStreamScan`, +184/-6): unifies
`changelog.ttl_seconds` cutoff calculation and
`RESUMABLE(1)`/`CANNOT_RESUME(0)`/`UNKNOWN(-1)` rules between planning and
monitoring.
- Pending-age tracker (`StreamPendingAgeTracker`, +134/-0): single-point
in-memory `(trackedBaselineOffset, oldestPendingTimeMs)` anchor per `(streamId,
partitionId)` bounded by TSO physical time on cold start.
- Batch stream collector & snapshot (`OlapStreamMonitorCollector`,
`ChangelogMonitor`, `ChangelogMonitorSnapshot`, `Config`, +493/-8): short table
read locks in shared-nothing mode, lock-free batched MetaService RPCs with
per-stream failure isolation in cloud mode, and configurable sample expiration.
- Snapshot metrics (`StreamSnapshotMetrics`, `MetricRepo`, +61/-0):
exports `doris_fe_stream_pending_age_seconds` and `doris_fe_stream_can_resume`
(`db_name`, `stream_name`, `stream_id`), reporting `-1.0`/`-1` when stale or
failed.
- Schema table extension (`SchemaTable`, `OlapTableStream`,
`TableStreamManager`, `MetadataGenerator`,
`schema_table_stream_consumption_scanner.cpp`, +178/-57): appends 3 diagnostic
columns gated on `TSchemaTableRequestParams.isSetColumnsName()`.
- Tests (6 FE UTs, 1 BE UT, 1 P0 regression suite, +748/-1).
- **Before and after:**
- Before: No stream pending-age or resumability gauges on `/metrics`;
`information_schema.table_stream_consumption` returned 7 columns.
- After: Verified locally on 1FE+1BE with active stream `stream_mon_s` and
expired-TTL stream `stream_mon_ttl_s` (`changelog.ttl_seconds = 1`):
- `table_stream_consumption`: `stream_mon_s` reports
`PENDING_AGE_SECONDS=0, CAN_RESUME=1, UNRESUMABLE_REASON=""`;
`stream_mon_ttl_s` reports `CAN_RESUME=0, UNRESUMABLE_REASON="TTL_EXPIRED"`.
- `/metrics`: `doris_fe_stream_pending_age_seconds{...,
stream_name="stream_mon_s", ...} 0.0`, `doris_fe_stream_can_resume{...,
stream_name="stream_mon_s", ...} 1`, `doris_fe_stream_can_resume{...,
stream_name="stream_mon_ttl_s", ...} 0`.
- **Configs and defaults:** `changelog_monitor_snapshot_expire_seconds` (FE
mutable, default `0` -> `3 * changelog_monitor_interval_seconds`; positive
values override in seconds). Expired or failed stream samples report `-1.0` /
`-1`.
- **Impact on existing users:** Explicit 7-column queries are unchanged;
`SELECT *` gets 3 trailing columns. During rolling upgrades (new FE + old BE),
FE omits the 3 new columns unless `columns_name` is set.
### Testing
- **Builds & style (local):** `./build.sh --fe`, `./build.sh --be`, FE
checkstyle (`mvn -f fe/pom.xml -pl fe-common,fe-core -am validate
-DskipTests`), `build-support/check-format.sh`, and
`build-support/check-build-hygiene.sh` all passed.
- **FE UTs (local, 18/18 passed):** `StreamResumabilityCheckerTest` (3/3),
`StreamPendingAgeTrackerTest` (2/2), `OlapStreamMonitorCollectorTest` (2/2),
`StreamSnapshotMetricsTest` (1/1), `ChangelogMonitorTest` (3/3),
`IvmRefreshSnapshotMetricsTest` (1/1), `ChangelogUtilsTest` (2/2),
`StreamConsumptionMetadataGeneratorTest` (3/3),
`CloudTableStreamConsumptionTest` (1/1).
- **Regression (local 1FE+1BE, 3/3 passed):**
`table_stream_p0/test_stream_monitoring_metrics`,
`query_p0/schema_table/test_stream_consumption_schema`,
`mtmv_p0/ivm/test_ivm_refresh_method_metrics`.
- **BE UT (CI):** `SchemaTableStreamConsumptionScannerTest` updated for 10
columns; runtime path exercised by local regression suites, BE UT binary runs
in CI.
### Notes for Reviewers
- `StreamResumabilityChecker.calculateCutoffTso` is shared with
`NormalizeOlapTableStreamScan` so planning and monitoring apply identical TTL
boundaries.
- `OlapStreamMonitorCollector` never holds a table lock across cloud
MetaService RPCs and falls back from batch to per-stream calls on failure.
### Release note
Master FE `/metrics` now exports `doris_fe_stream_pending_age_seconds` and
`doris_fe_stream_can_resume` per OLAP Table Stream, and
`information_schema.table_stream_consumption` adds `PENDING_AGE_SECONDS`,
`CAN_RESUME`, and `UNRESUMABLE_REASON` columns.
### Check List (For Author)
- Behavior changed: No
- Does this need documentation: No
- Pre-submission status: Partially verified: BE unit test
`SchemaTableStreamConsumptionScannerTest` was not run locally (runs in CI; BE
scanner verified via local regression suites). All FE unit tests and 1FE+1BE
regression suites passed locally.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]