Skip to content

[improvement](fe) Add the branch-4.x weight budget columns to catalog_meta_cache_statistics - #69557

Merged
morningman merged 2 commits into
apache:masterfrom
morningman:b2m-t12b-meta-cache-weight-columns
Oct 25, 2026
Merged

morningman merged 2 commits into
apache:masterfrom
morningman:b2m-t12b-meta-cache-weight-columns

Conversation

@morningman

@morningman morningman commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

What problem does this PR solve?

Issue Number: None

Related PR: #66717, #67726

Problem Summary:

In short. This brings the weight columns of information_schema.catalog_meta_cache_statistics from branch-4.x #66717 to master. Master shows four of the ten: this PR adds WEIGHT_BOUNDED, EVICTION_WEIGHT, CATALOG_MAX_WEIGHT, CATALOG_ESTIMATED_WEIGHT, GLOBAL_MAX_WEIGHT and GLOBAL_ESTIMATED_WEIGHT with the 4.x names, types and meanings, and makes a cache entry without a weight bound report -1 in every weight column, as 4.x does, instead of 0 in ESTIMATED_WEIGHT and WEIGHT_REJECT_COUNT.

Background. External catalogs can bound the memory of their metadata caches: an FE-global limit (external_meta_cache_max_weight), a catalog limit (meta.cache.max-weight) and per-entry limits. catalog_meta_cache_statistics is how users watch those caches. On branch-4.x (#66717) the view tells, per entry, whether it is weight bounded, what it holds and has evicted, and how full its catalog and the FE-global budget are. Master (#67726) re-implemented the governance on the connector cache framework and exposed only MAX_WEIGHT, ESTIMATED_WEIGHT, WEIGHT_REJECT_COUNT and LAST_WEIGHT_REJECT_REASON.

The problem, and what it cost. Monitoring queries written for 4.x fail on master with an unknown column as soon as they name one of the other six, and so do the weight scenarios of 4.x's test_paimon_table_meta_cache and test_iceberg_table_meta_cache. There is also no way on master to see how much of a catalog or of the FE-global budget is used, or how many bytes were evicted to make room. And an entry without a weight bound reports ESTIMATED_WEIGHT = 0 and WEIGHT_REJECT_COUNT = 0, which reads like an empty but bounded cache.

How this PR fixes it.

  • MetaCacheBudgetManager.EntryBudget exposes the catalog limit the entry is admitted under (the smaller of the catalog and FE-global limits, as the admission check uses it), the bytes charged to its catalog, the FE-global limit and the bytes charged to it. A limit that does not exist is -1.
  • ScopedMetaCache adds the bytes each value was admitted with to an eviction-weight counter when it removes the value by eviction, by Caffeine (capacity or expiry) or to make room in the budget. The bytes are recorded when the value is admitted, because an exact invalidation can release the reservation of an evicted value before the eviction is accounted. Invalidation and replacement do not count.
  • ScopedMetaCache.CacheMetrics, MetaCacheEntryStats, SchemaTable and MetadataGenerator carry the six values. The columns are appended after LAST_WEIGHT_REJECT_REASON. For an entry without a weight bound, every weight column is -1.
  • The BE scanner knows the six columns. An FE that does not know them rejects the request, and the scanner then asks for the leading 28 columns, then 24, as it already did for the four earlier weight columns.

SELECT * positions still differ from 4.x, because master's base columns also have EVICTION_RATE; queries that name their columns now work on both.

Results.

master this PR
SELECT weight_bounded, catalog_max_weight ... FROM catalog_meta_cache_statistics fails: unknown column works, as on 4.x
Entry of a catalog with meta.cache.max-weight = 128MB MAX_WEIGHT = 134217728 only also CATALOG_MAX_WEIGHT = 134217728, the catalog's and the FE-global charges, the evicted bytes
Entry without any weight bound ESTIMATED_WEIGHT = 0, WEIGHT_REJECT_COUNT = 0 -1 in every weight column
New BE, FE without the six columns n/a the BE falls back to the leading 28 columns

Tests:

  • MetaCacheWeightGovernanceTest: an entry without a weight bound reports -1 everywhere; the catalog and FE-global limits and charges of bounded entries, with and without an FE-global limit; a budget reclaim and a capacity eviction add the evicted reservation to the eviction weight, an invalidation does not. An eviction keeps the bytes it was admitted with when the key is invalidated before the deferred eviction is accounted. Restoring master's 0 for unbounded entries, or dropping the eviction accounting, turns these tests red.
  • FeMetaCacheEntryTest checks the fe-core view of an unbounded and of a bounded entry; HudiConnectorHmsCacheTest now expects -1 for its unbounded entry.
  • Regression: test_paimon_table_meta_cache gets the weight scenario of 4.x on master's entry names (a catalog with meta.cache.max-weight = 128MB next to an unbounded one); test_iceberg_table_meta_cache puts its first catalog under a catalog limit and checks the budget hierarchy of its bounded entries, as 4.x does; the new test_remote_doris_meta_cache_weight covers the doris engine without any external service.
  • Manually: a BE from this PR against an FE without the six columns returns the rows (the FE rejects the 34 columns, the BE retries with 28).

Original author: @CalvinKirs

Release note

information_schema.catalog_meta_cache_statistics adds the columns WEIGHT_BOUNDED, EVICTION_WEIGHT, CATALOG_MAX_WEIGHT, CATALOG_ESTIMATED_WEIGHT, GLOBAL_MAX_WEIGHT and GLOBAL_ESTIMATED_WEIGHT. A metadata cache entry without a weight bound now reports -1 instead of 0 in ESTIMATED_WEIGHT and WEIGHT_REJECT_COUNT.

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
      With an FE built before this PR and a BE built from it, SELECT ... FROM information_schema.catalog_meta_cache_statistics returns the rows; the FE log shows the rejected 34-column request.
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason

    test_paimon_table_meta_cache and test_remote_doris_meta_cache_weight were run against a local cluster and generated their .out files. test_iceberg_table_meta_cache needs the hive3 environment and was not run locally; its new check uses assertions only.

  • Behavior changed:

    • No.
    • Yes.
      A metadata cache entry without a weight bound reports -1 instead of 0 in ESTIMATED_WEIGHT and WEIGHT_REJECT_COUNT. Upgrade BE before FE: an older BE cannot fill the six new columns.
  • Does this need documentation?

    • No.
    • Yes.
      The page of catalog_meta_cache_statistics should list the six columns (doc PR to follow).

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

…_meta_cache_statistics

### What problem does this PR solve?

Issue Number: None

Related PR: apache#66717, apache#67726

Problem Summary: branch-4.x (apache#66717) shows ten memory-weight columns in
information_schema.catalog_meta_cache_statistics. Master (apache#67726) has only
MAX_WEIGHT, ESTIMATED_WEIGHT, WEIGHT_REJECT_COUNT and
LAST_WEIGHT_REJECT_REASON, so monitoring queries written for 4.x, and the
weight scenarios of 4.x's own regression suites, fail on master with unknown
columns: WEIGHT_BOUNDED, EVICTION_WEIGHT, CATALOG_MAX_WEIGHT,
CATALOG_ESTIMATED_WEIGHT, GLOBAL_MAX_WEIGHT and GLOBAL_ESTIMATED_WEIGHT.
For an entry without a weight bound master also reports ESTIMATED_WEIGHT and
WEIGHT_REJECT_COUNT as 0, where 4.x reports -1.

The six columns are appended after LAST_WEIGHT_REJECT_REASON with the 4.x
names, types and meanings: whether the entry is weight bounded; the bytes of
the values removed by eviction, by Caffeine or to make room in the budget;
the catalog limit the entry is admitted under (the smaller of the catalog and
FE-global limits) and the bytes charged to its catalog; the FE-global limit
and the bytes charged to it. A limit that does not exist is -1, and an entry
without a weight bound reports -1 in every weight column, as on 4.x. The BE
scanner asks an older FE that rejects the new columns for the leading 28,
then 24 columns. SELECT * positions still differ from 4.x, whose base columns
lack EVICTION_RATE; queries by column name now work on both.

### Release note

information_schema.catalog_meta_cache_statistics adds the columns
WEIGHT_BOUNDED, EVICTION_WEIGHT, CATALOG_MAX_WEIGHT, CATALOG_ESTIMATED_WEIGHT,
GLOBAL_MAX_WEIGHT and GLOBAL_ESTIMATED_WEIGHT. A cache entry without a weight
bound now reports -1 instead of 0 in ESTIMATED_WEIGHT and WEIGHT_REJECT_COUNT.

### Check List (For Author)

- Test: Regression test / Unit Test
    - MetaCacheWeightGovernanceTest, FeMetaCacheEntryTest, HudiConnectorHmsCacheTest
    - test_paimon_table_meta_cache and test_remote_doris_meta_cache_weight, run against a local cluster;
      test_iceberg_table_meta_cache needs the hive3 environment and was not run locally
    - Manual: a new BE against an FE without the six columns falls back to the leading 28
- Behavior changed: Yes. A cache entry without a weight bound reports -1 instead of 0 in ESTIMATED_WEIGHT and
  WEIGHT_REJECT_COUNT. Upgrade BE before FE: an older BE cannot fill the six new columns.
- Does this need documentation: Yes. The catalog_meta_cache_statistics page should list the six columns (doc PR to follow).

Co-authored-by: Calvin Kirs <[email protected]>
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@hello-stephen

Copy link
Copy Markdown
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@morningman

Copy link
Copy Markdown
Contributor Author

run buildall

@morningman

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed all 14 changed files at eef214d. One P2 issue is reported inline: concurrent invalidation can release a reservation before deferred eviction accounting reads its bytes, permanently understating EVICTION_WEIGHT. No existing inline findings were present, and no additional user focus was supplied.

The inspected flow is:

CatalogMetaCache / EntryBudget
  -> ScopedMetaCache admission, replacement and deferred removal
  -> CacheMetrics -> MetaCacheEntryStats -> MetadataGenerator TRow/TCell
  -> BE catalog-meta-cache scanner -> information_schema SQL columns

Applicable code-review skill checkpoints:

Checkpoint Conclusion
Goal and evidence Six weight columns and unbounded numeric -1 sentinels reach the SQL view. Added tests cover nominal eviction, hierarchy and sentinels; the inline finding identifies an uncovered eviction/invalidation race.
Scope and reuse Focused changes reuse shared budget accounting and the existing snapshot/serializer/scanner pipeline.
Concurrency and locks Request workers, refresh workers, direct Caffeine maintenance and peer reclamation can interleave. Manager arithmetic is locked; reclaim callbacks run outside that lock. No new lock inversion or heavy I/O under locks found. The lifetime of the sampled eviction weight is incorrect in the reported race.
Lifecycle and initialization Reservation replacement/rollback and exactly-once release were traced. New metrics add scalar state with no retaining cycle or cross-TU initialization dependency; eviction event weight must survive reservation release.
Configuration No new configuration key. Existing entry, catalog and global bounds, disabled caches and unbounded entries were inspected.
Compatibility FE declarations, encoded cells and BE descriptors agree on 34 ordered columns. New BE retries old FE with 28 then 24 columns and fills missing tails with NULL. BE must be upgraded before querying the new columns through an upgraded FE; this is the documented rollout restriction. No persisted format or connector SPI definition changes.
Thrift/protobuf IDs No definition files changed; release-branch ID comparison is not applicable.
Parallel paths Load, put, CAS, refresh and bulk publication share the reviewed removal machinery. Capacity, expiry and budget eviction reach the common counter; explicit invalidation and replacement are excluded. Builtin and connector statistics share the FE serializer.
Conditions and errors Bounded published values have a nonnull reservation by construction. That guarantee does not preserve its mutable byte count until deferred removal. Retry widths are documented; transport and terminal FE errors still propagate.
Test coverage Unit coverage includes nominal capacity/budget eviction, invalidation exclusion, hierarchy and unbounded values; regression changes cover Paimon, Iceberg and remote Doris. Expiry/invalidation ordering and direct mixed-version scanner tests are missing.
Changed test results Both added .out files have deterministic order_qt projections and expected entry sets/types under the default unlimited-global configuration. Their generation history and execution were not verified.
Observability Added fields expose boundedness and budget usage; existing rejection reasons and FE-host failure logs remain. The reported issue permanently loses eviction-byte events. Hierarchy getters sample different instants, consistent with the surrounding approximate statistics; no functional consumer relies on cross-field atomicity.
Transactions and persistence No transaction, visible-version, delete-bitmap, EditLog or persisted metadata behavior changes.
Data writes and crashes Implementation changes concern transient cache statistics; no data-write atomicity or newly introduced crash leak/deadlock defect established.
FE/BE field passing All six fields are present in FE schema, shared snapshot conversion, TCell encoding and BE schema/decoding. No alternate constant-folding or point-query variable path applies.
Performance and memory Added work is constant-time primitive accounting, short budget-lock reads and bounded fallback retries. Saturating addition prevents cumulative overflow. No significant untracked allocation or new retained object graph.
Other concerns and final recheck Rechecked null/disabled values, replacement generations, expiry, exact/scope invalidation, close, old-FE status conversion, boolean decoding and nullable tails. No additional substantiated finding or unresolved code candidate remains.

Coverage limits: this was a static-only review. No builds, unit/regression tests, cluster runs or rolling-upgrade experiments were executed; runtime behavior and .out generation provenance remain unverified. The review ledger records each candidate and risk disposition. The separate hierarchy-snapshot concern was dismissed with the consumer and lock evidence above.

Review converged after 2 round(s).

if (weightBounded) {
// Every value of a bounded cache holds a reservation; it is released below.
evictionWeight.accumulateAndGet(
versioned.registration.reservation.getBytes(), JvmSizeUtils::saturatedAdd);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[P2] Preserve the admitted byte count through deferred eviction accounting

An eviction can permanently add zero bytes here. After thread A removes a weighted value for expiry, capacity or budget reclamation, its deferred callback can pause before this read. Thread B can then call invalidateKey(key): the old registration is still attached, the value is already absent from data, and the registration CAS/release at lines 490-491 calls MetaCacheBudgetManager.release(), which sets reservation.bytes to 0. When A resumes, evictionCount increments but EVICTION_WEIGHT loses that value's entire weight. The deferred drain holds no publication gate or key-node monitor that prevents this schedule. Preserve the admitted generation's immutable weight for the removal event instead of reading the live reservation after another path can release it, and cover eviction racing with invalidation.

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.

Confirmed, and fixed in 31dba971849. Releasing an AdmissionReservation zeroes its bytes, and an exact invalidateKey releases the generation its key node still points to, by a CAS outside the key node's monitor, so a release landing between Caffeine's removal and the deferred drain made the eviction count 0 bytes. Quota accounting was not affected: the reservation is still released exactly once. Each Registration now records the bytes its reservation was admitted with when the generation is created (both the fresh admission and the replacement create it right after admission), and completeRemoval adds those; reading the reservation under the key node's monitor would not have helped, since the invalidation's release does not take it. Budget reclamation in evictLocalColdestWithDeferredRemovals reads the same field for the bytes it removed, which equals the live value of a reservation that is not released and needs no budget manager lock. MetaCacheWeightGovernanceTest#evictionWeightKeepsTheAdmittedBytesWhenInvalidationReleasesFirst keeps the removal deferral open inside forEach, queues a capacity eviction and invalidates both keys before the drain: EVICTION_WEIGHT is now 768, where it was 0, and the budget is fully released.

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 28452 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit eef214dfe8fd452f805b43c1711a93e5e1e65375, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17610	5193	5121	5121
q2	2169	307	246	246
q3	10227	1339	824	824
q4	4680	455	333	333
q5	7441	790	546	546
q6	189	188	156	156
q7	758	800	617	617
q8	9253	1299	1080	1080
q9	5468	4176	4157	4157
q10	6813	1271	1013	1013
q11	421	252	227	227
q12	646	401	284	284
q13	18064	3548	2956	2956
q14	276	278	251	251
q15	q16	727	734	665	665
q17	1179	743	571	571
q18	6947	6161	6077	6077
q19	1103	950	645	645
q20	377	334	229	229
q21	5250	2197	2227	2197
q22	349	298	257	257
Total cold run time: 99947 ms
Total hot run time: 28452 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5681	5663	5638	5638
q2	670	575	529	529
q3	5152	5346	4880	4880
q4	2007	2147	1546	1546
q5	5238	5113	5553	5113
q6	259	193	159	159
q7	2369	1984	1812	1812
q8	3108	2714	2731	2714
q9	8016	7871	7913	7871
q10	3753	3657	3315	3315
q11	732	455	408	408
q12	701	698	549	549
q13	3660	3893	3197	3197
q14	322	320	300	300
q15	q16	721	721	626	626
q17	8282	7613	6992	6992
q18	12954	12158	12853	12158
q19	948	841	832	832
q20	2123	2178	1943	1943
q21	5780	4721	4936	4721
q22	497	450	413	413
Total cold run time: 72973 ms
Total hot run time: 65716 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 150648 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit eef214dfe8fd452f805b43c1711a93e5e1e65375, data reload: false

query5	4306	594	441	441
query6	428	206	187	187
query7	4800	447	224	224
query8	329	160	143	143
query9	8793	3074	3091	3074
query10	464	326	256	256
query11	6088	3860	3580	3580
query12	149	93	88	88
query13	1249	428	334	334
query14	6110	3936	3642	3642
query14_1	3408	3382	3391	3382
query15	210	203	182	182
query16	920	435	427	427
query17	873	685	539	539
query18	2426	420	311	311
query19	203	159	134	134
query20	84	84	83	83
query21	206	126	107	107
query22	12995	13012	12874	12874
query23	13415	12821	12484	12484
query23_1	12504	12487	12501	12487
query24	7369	821	456	456
query24_1	482	468	467	467
query25	531	422	361	361
query26	1270	258	139	139
query27	2763	433	271	271
query28	4630	1959	1956	1956
query29	1870	600	460	460
query30	297	222	186	186
query31	1020	926	830	830
query32	143	94	93	93
query33	532	303	257	257
query34	1077	871	500	500
query35	746	766	660	660
query36	837	793	769	769
query37	119	97	82	82
query38	1787	1750	1709	1709
query39	802	805	775	775
query39_1	751	735	750	735
query40	226	124	93	93
query41	72	64	63	63
query42	85	85	82	82
query43	350	367	311	311
query44	1359	710	695	695
query45	169	176	165	165
query46	846	962	567	567
query47	3010	3059	2683	2683
query48	313	305	214	214
query49	560	399	316	316
query50	689	282	212	212
query51	10906	10547	10215	10215
query52	78	80	69	69
query53	187	207	148	148
query54	246	186	176	176
query55	68	69	69	69
query56	234	218	197	197
query57	1669	1620	1570	1570
query58	282	257	255	255
query59	2105	2084	1981	1981
query60	302	223	263	223
query61	147	144	144	144
query62	399	324	279	279
query63	185	158	161	158
query64	2717	923	725	725
query65	3321	3248	3250	3248
query66	1766	405	295	295
query67	20343	20081	19986	19986
query68	3002	985	599	599
query69	386	284	245	245
query70	847	761	776	761
query71	305	240	241	240
query72	2702	2580	2307	2307
query73	510	535	297	297
query74	4642	4515	4355	4355
query75	2322	2297	1879	1879
query76	2300	998	570	570
query77	350	366	267	267
query78	9791	9680	9158	9158
query79	1024	833	520	520
query80	548	431	335	335
query81	531	320	278	278
query82	586	134	102	102
query83	306	198	177	177
query84	326	125	108	108
query85	807	471	436	436
query86	324	239	263	239
query87	1987	1993	1827	1827
query88	3691	2659	2651	2651
query89	332	281	240	240
query90	1902	177	163	163
query91	160	153	123	123
query92	100	90	88	88
query93	986	1002	571	571
query94	433	295	270	270
query95	572	322	300	300
query96	671	477	232	232
query97	2432	2448	2308	2308
query98	163	159	146	146
query99	771	758	644	644
Total cold run time: 235078 ms
Total hot run time: 150648 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 24.2 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit eef214dfe8fd452f805b43c1711a93e5e1e65375, data reload: false

query1	0.00	0.00	0.00
query2	0.09	0.05	0.05
query3	0.26	0.08	0.08
query4	1.60	0.11	0.10
query5	0.25	0.24	0.24
query6	1.16	0.70	0.67
query7	0.04	0.01	0.00
query8	0.07	0.04	0.04
query9	0.41	0.35	0.36
query10	0.58	0.61	0.59
query11	0.19	0.13	0.14
query12	0.18	0.14	0.14
query13	0.48	0.48	0.50
query14	1.02	1.00	1.01
query15	0.63	0.60	0.60
query16	0.35	0.34	0.34
query17	1.11	1.21	1.12
query18	0.22	0.19	0.20
query19	2.14	1.98	1.98
query20	0.02	0.02	0.01
query21	15.44	0.20	0.14
query22	4.84	0.05	0.06
query23	16.27	0.34	0.13
query24	3.10	0.60	0.35
query25	0.12	0.06	0.05
query26	1.22	0.21	0.16
query27	0.05	0.04	0.05
query28	3.59	0.73	0.35
query29	12.53	4.09	3.23
query30	0.29	0.13	0.11
query31	2.77	0.57	0.32
query32	3.21	0.60	0.49
query33	3.14	3.23	3.19
query34	15.54	3.97	3.40
query35	3.34	3.33	3.32
query36	0.56	0.45	0.42
query37	0.10	0.07	0.06
query38	0.05	0.04	0.03
query39	0.04	0.03	0.03
query40	0.17	0.15	0.14
query41	0.08	0.03	0.02
query42	0.04	0.03	0.03
query43	0.05	0.03	0.04
Total cold run time: 97.34 s
Total hot run time: 24.2 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 68.75% (22/32) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100% (0/0) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 77.23% (35950/46552)
Line Coverage 62.52% (406264/649766)
Region Coverage 58.92% (342985/582083)
Branch Coverage 59.92% (158691/264841)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 100.00% (32/32) 🎉
Increment coverage report
Complete coverage report

### What problem does this PR solve?

Issue Number: None

Related PR: apache#69557

Problem Summary: EVICTION_WEIGHT of catalog_meta_cache_statistics adds the
bytes of every value Caffeine evicts or budget reclamation removes. The
removal is handled by a deferred drain on the evicting thread, which read
the live reservation of the evicted generation. An exact invalidation of the
same key can release that generation's reservation between the eviction and
the drain (the key node still points to it, and the invalidation releases it
outside the key node's monitor), and releasing a reservation zeroes its
bytes, so the eviction was counted with 0 bytes and EVICTION_WEIGHT stayed
short for good. Quota accounting was not affected: the reservation is still
released exactly once.

Each generation's registration now records the bytes its reservation was
admitted with when the generation is created, and eviction accounting adds
those. Budget reclamation reads the same field for the bytes it removed,
which equals the live value of a reservation that is not released and needs
no budget manager lock.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - MetaCacheWeightGovernanceTest#evictionWeightKeepsTheAdmittedBytesWhenInvalidationReleasesFirst: inside forEach, which defers removals, a capacity eviction is queued and both keys are invalidated before the drain; EVICTION_WEIGHT is the admitted bytes (it was 0) and the budget is fully released
    - fe-connector-cache module tests
- Behavior changed: No
- Does this need documentation: No

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@morningman

Copy link
Copy Markdown
Contributor Author

Addressed the review in 31dba971849. Per finding:

  • 4365835392 (P2, eviction weight read after a concurrent release): fixed. Each registration keeps the bytes it was admitted with, and eviction accounting adds those instead of the live reservation.

One new test in MetaCacheWeightGovernanceTest; the fe-connector-cache module (164 tests) and the fe-core and Hudi cache tests this PR touches pass. The PR description is updated.

@morningman

Copy link
Copy Markdown
Contributor Author

run buildall

@morningman

Copy link
Copy Markdown
Contributor Author

/review

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed head 31dba971849fb187515b97da98ba42518921df37, covering all 14 changed files and their relevant callers, lifecycle and parallel paths. No new actionable findings identified.

Existing P2 comment 4365835392 is addressed: both fresh and replacement generations capture immutable admitted bytes before publication, and deferred eviction accounting reads that value after any reservation release. The added release-before-drain test exercises the reported ordering. No duplicate comment is posted, and no existing P0/P1 finding remains in the supplied/live thread context. No additional user focus was supplied.

The reviewed flow is CatalogMetaCache / EntryBudget -> ScopedMetaCache admission and removal -> CacheMetrics -> MetaCacheEntryStats -> ExternalMetaCacheMgr -> MetadataGenerator -> schema-table RPC -> BE scanner -> SQL projection.

Critical checkpoint conclusions:

  1. Goal and supporting tests: the six added columns and unbounded numeric -1 values are carried through the complete flow. Added unit and regression cases support the intended bounded/unbounded, hierarchy and eviction behavior.
  2. Scope and reuse: changes are focused on cache observability, reuse the existing stats/RPC/scanner paths and add no unrelated production behavior.
  3. Concurrency: query/load/refresh/invalidation threads and the peer-reclaim worker were traced. Manager arithmetic uses its existing lock; release uses registration CAS; eviction-byte addition is atomic and saturating. Hierarchy gauges remain independently sampled observations.
  4. Lock work and order: new reads and counter updates are constant time. Reclamation runs outside the manager lock and deferred removals drain outside publication/Caffeine maintenance locks; no new reverse lock edge was found.
  5. Lifecycle and initialization: immutable admission bytes retain no cached-value graph. Fresh admission, replacement commit/rollback, invalidation and close preserve ownership/release paths. No new static initialization dependency or reference cycle.
  6. Configuration: no new setting or dynamic-update behavior; metrics reflect the existing entry/catalog/global budget lifecycle.
  7. Compatibility: FE and BE agree on all 34 names, positions and types. New BE retries older FE schemas with 28 then 24 columns, padding unavailable trailing cells with NULL; old BE requests retain their existing filtered columns. Materializing added columns requires the documented BE-before-FE upgrade order.
  8. Thrift/protobuf definitions: no field IDs, enum values or generated definitions changed; existing RPC cells carry the values.
  9. Parallel paths: FE-owned and plugin-owned stats, fresh/replacement/refresh/bulk publication, and expiry/capacity/peer/invalidation/close removal paths were checked. Shared constructors and removal accounting cover the affected paths.
  10. Special conditions: bounded/unbounded branches follow the constructor-established estimator/budget pairing. The deferred-release and older-schema conditions have concrete explanatory comments.
  11. Test coverage: reviewed hierarchy and sentinel cases, capacity and budget eviction, explicit invalidation exclusion, rejected mutation, and the deterministic release-before-drain case, alongside relevant existing concurrency/rollback coverage. Rolling-upgrade fallback was checked statically.
  12. Test results: both new result files match selected columns, registered entry names, 128 MiB limits and expected sentinels; ordered query checks provide deterministic output. Result-generation provenance was not independently verified.
  13. Observability: bounded status, eviction bytes and enclosing-budget usage provide the intended diagnostics; no new heavy logging or external I/O.
  14. Transactions and persistence: no EditLog, transaction visibility, delete bitmap, storage format or failover protocol change.
  15. Writes and crash atomicity: production changes expose transient cache state; existing publication, accounting rollback and exactly-once release protections remain in place. No new durable write path.
  16. FE/BE propagation: schema registration, stats mapping, TCell construction, RPC filtering, scanner decoding and projection agree; no alternative send path applies.
  17. Performance and memory: constant-size metric additions and one primitive admitted-weight field per generation; no new graph traversal or unbounded retry. Compatibility fallback adds at most two RPC attempts.
  18. Further recheck: revisited delayed old-generation cleanup, pending replacement/removal overlap, close-before-publication, absent enclosing limits, empty old-FE batches and added-column projection. No further substantiated issue or unresolved static candidate remains.

Coverage limits: review was static only. No builds, tests, runtime concurrency experiment or mixed-version cluster validation was executed in this invocation. These limits apply to the verification method; all assigned changed-file and risk scopes were reviewed.

Review converged in 1 round: both complete-review agents and the separate risk reviewer returned NO_NEW_VALUABLE_FINDINGS, and the final main-agent sweep found no uncovered changed path or unresolved candidate.

Review converged after 1 round(s).

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-H: Total hot run time: 28557 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit 31dba971849fb187515b97da98ba42518921df37, data reload: false

------ Round 1 ----------------------------------
============================================
q1	17592	5158	5337	5158
q2	2118	342	249	249
q3	10218	1358	809	809
q4	4683	468	334	334
q5	7427	797	529	529
q6	202	187	150	150
q7	753	795	601	601
q8	9263	1315	1093	1093
q9	5524	4234	4170	4170
q10	6812	1296	1014	1014
q11	438	262	239	239
q12	644	394	286	286
q13	18078	3514	3017	3017
q14	273	268	251	251
q15	q16	730	719	649	649
q17	1200	755	579	579
q18	7007	6181	6106	6106
q19	1090	949	590	590
q20	384	327	228	228
q21	5188	2244	2346	2244
q22	361	304	261	261
Total cold run time: 99985 ms
Total hot run time: 28557 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	5638	5617	5642	5617
q2	679	591	525	525
q3	5208	5367	4944	4944
q4	2037	2168	1594	1594
q5	5276	5128	5630	5128
q6	250	201	158	158
q7	2296	2108	1858	1858
q8	3091	2762	2722	2722
q9	7979	8049	8002	8002
q10	3696	3681	3240	3240
q11	628	568	472	472
q12	693	706	534	534
q13	3573	3940	3313	3313
q14	324	326	289	289
q15	q16	735	743	669	669
q17	8315	7578	7082	7082
q18	13036	12194	12875	12194
q19	916	783	846	783
q20	2144	2154	1950	1950
q21	6001	4998	5058	4998
q22	498	480	433	433
Total cold run time: 73013 ms
Total hot run time: 66505 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 150763 ms
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit 31dba971849fb187515b97da98ba42518921df37, data reload: false

query5	4309	613	442	442
query6	425	208	197	197
query7	4805	450	234	234
query8	323	169	156	156
query9	8764	3097	3105	3097
query10	496	316	257	257
query11	6004	3857	3565	3565
query12	148	92	89	89
query13	1267	446	322	322
query14	6085	3971	3643	3643
query14_1	3461	3465	3466	3465
query15	210	195	179	179
query16	942	436	406	406
query17	866	656	549	549
query18	2433	424	309	309
query19	201	163	140	140
query20	86	85	87	85
query21	213	127	111	111
query22	12930	12963	12807	12807
query23	13418	12783	12429	12429
query23_1	12509	12516	12574	12516
query24	7378	834	478	478
query24_1	501	494	497	494
query25	573	423	367	367
query26	1276	260	146	146
query27	2741	447	273	273
query28	4973	1981	1995	1981
query29	1580	630	479	479
query30	307	232	193	193
query31	1023	949	837	837
query32	149	96	97	96
query33	535	311	278	278
query34	922	863	507	507
query35	751	763	636	636
query36	861	836	730	730
query37	128	111	90	90
query38	1785	1758	1699	1699
query39	796	807	746	746
query39_1	766	742	742	742
query40	220	119	101	101
query41	73	70	68	68
query42	92	90	85	85
query43	345	370	312	312
query44	1361	683	698	683
query45	181	187	168	168
query46	860	977	584	584
query47	2863	3084	2612	2612
query48	287	311	217	217
query49	564	394	290	290
query50	702	277	207	207
query51	10528	10540	10249	10249
query52	82	85	75	75
query53	187	204	150	150
query54	229	204	176	176
query55	69	68	66	66
query56	223	229	200	200
query57	1633	1618	1576	1576
query58	288	249	260	249
query59	2075	2142	2006	2006
query60	287	240	227	227
query61	145	149	146	146
query62	382	331	281	281
query63	192	170	173	170
query64	2723	964	756	756
query65	3325	3260	3271	3260
query66	1776	422	302	302
query67	20285	20064	19903	19903
query68	3021	1012	618	618
query69	405	301	256	256
query70	850	809	778	778
query71	294	240	215	215
query72	2736	2564	2265	2265
query73	532	548	290	290
query74	4636	4518	4387	4387
query75	2333	2288	1907	1907
query76	2325	1010	612	612
query77	343	380	264	264
query78	9960	9780	9165	9165
query79	1003	857	531	531
query80	808	422	335	335
query81	573	325	274	274
query82	574	137	109	109
query83	300	201	182	182
query84	314	117	101	101
query85	854	418	368	368
query86	351	243	230	230
query87	2010	1957	1811	1811
query88	3690	2673	2652	2652
query89	334	277	244	244
query90	1793	182	173	173
query91	166	149	122	122
query92	97	91	79	79
query93	1037	1026	572	572
query94	503	302	275	275
query95	583	329	360	329
query96	668	507	231	231
query97	2419	2462	2317	2317
query98	157	150	156	150
query99	775	768	655	655
Total cold run time: 235161 ms
Total hot run time: 150763 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
ClickBench: Total hot run time: 24.3 s
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit 31dba971849fb187515b97da98ba42518921df37, data reload: false

query1	0.01	0.01	0.01
query2	0.09	0.05	0.05
query3	0.26	0.09	0.09
query4	1.61	0.09	0.10
query5	0.24	0.24	0.24
query6	1.17	0.68	0.70
query7	0.03	0.00	0.00
query8	0.06	0.04	0.04
query9	0.42	0.37	0.35
query10	0.63	0.58	0.61
query11	0.22	0.15	0.14
query12	0.19	0.15	0.15
query13	0.49	0.49	0.49
query14	1.02	1.00	1.03
query15	0.64	0.60	0.60
query16	0.33	0.32	0.37
query17	1.15	1.11	1.18
query18	0.20	0.19	0.20
query19	2.00	1.92	2.00
query20	0.01	0.01	0.01
query21	15.48	0.18	0.13
query22	4.92	0.05	0.06
query23	16.30	0.33	0.12
query24	3.03	0.51	0.46
query25	0.11	0.06	0.05
query26	1.30	0.22	0.16
query27	0.05	0.05	0.06
query28	3.74	0.80	0.36
query29	12.49	4.18	3.27
query30	0.29	0.13	0.10
query31	2.77	0.56	0.33
query32	3.22	0.60	0.51
query33	3.26	3.26	3.16
query34	15.43	3.96	3.40
query35	3.35	3.33	3.30
query36	0.56	0.44	0.43
query37	0.09	0.06	0.06
query38	0.04	0.04	0.03
query39	0.03	0.04	0.03
query40	0.18	0.14	0.14
query41	0.09	0.03	0.03
query42	0.04	0.03	0.03
query43	0.04	0.04	0.04
Total cold run time: 97.58 s
Total hot run time: 24.3 s

@hello-stephen

Copy link
Copy Markdown
Contributor

BE UT Coverage Report

Increment line coverage 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 66.58% (31988/48047)
Line Coverage 51.38% (337484/656803)
Region Coverage 46.75% (273109/584193)
Branch Coverage 48.48% (128721/265490)

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100% (0/0) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 77.24% (35958/46552)
Line Coverage 62.54% (406351/649766)
Region Coverage 59.01% (343472/582083)
Branch Coverage 59.94% (158750/264841)

@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 100.00% (32/32) 🎉
Increment coverage report
Complete coverage report

@morningman
morningman merged commit c4f15f3 into apache:master Oct 25, 2026
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants