Skip to content

[improvement](hive) Batch Hive metastore partition access - #67186

Open
CalvinKirs wants to merge 14 commits into
apache:masterfrom
CalvinKirs:batch_interface
Open

[improvement](hive) Batch Hive metastore partition access#67186
CalvinKirs wants to merge 14 commits into
apache:masterfrom
CalvinKirs:batch_interface

Conversation

@CalvinKirs

@CalvinKirs CalvinKirs commented Aug 27, 2026

Copy link
Copy Markdown
Member

What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary:

Hive tables with very large partition counts could either issue one HMS partition-object RPC per partition on legacy caller paths or send every partition name in one unbounded getPartitionsByNames request. The first form creates excessive serial RPC latency; the second risks Thrift/HMS message limits and large temporary allocations.

This PR narrows the change to the shared HMS partition-object boundary. Callers continue to submit one logical partition-name list through HmsClient#getPartitions; the existing cache aggregates misses, one HMS batch executor owns bounded chunking, adaptive fallback and strict response validation, and a leaf transport performs one getPartitionsByNames invocation per physical attempt. Query, statistics, write and Hive-backed MTMV callers therefore receive the same batching behavior without implementing their own chunk/retry loops.

Common HMS batch execution

  • hive.hms_partitions_batch_size_per_rpc bounds each physical partition-object request; the default is 5,000.
  • hive.hms_partitions_batch_fallback_timeout_ms bounds the adaptive fallback phase; the default is 30,000 ms. It is checked between attempts and does not interrupt an active HMS RPC.
  • Explicit message/frame/request-size and partition-limit failures halve the effective batch size until success or the minimum batch size of one.
  • The reduced successful size is reused for the remaining partitions in the logical request.
  • Ordinary connection outages, authentication/setup failures, malformed results and local failures are not replayed through the halving ladder.
  • Hive's standard hive.metastore.limit.partition.request / “partitions scanned ... exceeds limit” failure is recognized.
  • With hive.metastore.client.pool.size=0, successful chunks in one logical request reuse one temporary HMS client. A failed physical call taints and destroys that client before a fallback attempt creates another.
  • Hive and Hudi bind and validate the same batch settings through HmsClientConfig.
  • Batch request and transport types remain package-private HMS implementation details.

Strict result integrity

  • Requested names are parsed once per layer into canonical ordered partition-value identities.
  • Duplicate request identities and inconsistent partition-key layouts fail before HMS access.
  • Every physical response is checked for missing, duplicate, unexpected, null and invalid-arity partition objects.
  • HMS response order is not trusted; a valid response is reconstructed in exact request order.
  • Any integrity mismatch fails the whole logical request with bounded diagnostics. Partial results are neither returned nor published to cache.
  • Mixed cache hit/miss requests fetch all misses in one logical delegate call, rebuild caller order, and retain the existing invalidation-generation fence.

Narrow MTMV bulk adapter

  • MTMVRelatedTableIf#getPartitionSnapshots has a compatibility default that retains the existing scalar loop for non-bulk table implementations.
  • The plugin-driven external-table adapter overrides it and calls the connector bulk freshness API once for the requested table/partition union.
  • Hive implements that bulk API with one logical HmsClient#getPartitions call; the common executor then splits it into bounded physical requests.
  • MTMVRefreshContext keeps only a request-scoped table → partition → snapshot cache. It unions mapped base partitions before the existing loops in sync, need-refresh, display, persistence and rewrite paths.
  • Persisted partition-name mismatches are rejected locally before remote freshness loading.
  • MTMVTask preloads the complete need-refresh union before splitting execution groups, so the default one-partition group size cannot regress first/manual/COMPLETE refreshes to singleton HMS requests.
  • Existing MTMV mapping, base-version, MVCC-pin, lock and persisted-snapshot lifecycles remain unchanged. External metadata I/O is outside the task's table locks.

With the default batch size, a cold 120,000-partition logical object request becomes 24 bounded requests instead of one 120,000-name request. A 160,000-partition Hive-backed MTMV union becomes one logical bulk load and 32 bounded physical requests, rather than one object request per mapped partition.

Scope boundaries:

  • This PR targets the master Thrift-HMS path used by Hive/Hudi. Iceberg, Paimon and non-HMS metadata protocols keep their own implementations.
  • 4.0/4.1 backports require separate path-specific changes and validation.
  • Query cancellation/deadline propagation through name listing, authentication, pool/client creation, retry and active wire calls is out of scope.
  • Connector-wide FE metrics and Query Profile metadata spans are out of scope.
  • Cache single-flight/admission/progressive publication, statistics sampling-policy changes and Cloud MTMV preload policy are out of scope.
  • Split-assignment first-split timeout and SplitSource lifecycle behavior are unchanged.
  • The original 120,000-partition real HMS environment has not been rerun on this commit.

Release note

Hive Metastore partition-object access now uses configurable bounded RPC batches, strict response validation, and adaptive fallback for explicit oversized-request failures. Hive-backed MTMV partition freshness is aggregated into bulk logical requests before HMS batching.

Deterministic request-shape evidence

Scenario Previous / unsafe shape This PR
Master 120,000-partition object load 1 unbounded request containing 120,000 names 24 requests, each at most 5,000 names
Legacy scalar caller shape, 120,000 objects Approximately 120,000 object requests 24 bounded object requests
Hive-backed MTMV, 160,000 mapped objects Approximately 160,000 singleton object requests 1 logical bulk load, split into 32 physical requests
Injected server limit above 625 names Large request fails 5000 → 2500 → 1250 → 625, then all objects complete
Pool disabled, successful multi-chunk request A new client per chunk in the initial implementation One temporary client reused for all successful chunks

These rows describe deterministic orchestration and request shape; they are not a substitute for a real 120,000-partition HMS end-to-end rerun.

Validation

  • 111 focused FE-core tests passed: MTMV refresh context, partition utilities, rewrite, task, and plugin-driven MVCC table paths.
  • 72 focused connector tests passed: HMS batching/cache/Thrift integration, Hive freshness, and connector SPI surface.
  • The final no-cache 60-module Maven validate reactor passed with zero Checkstyle violations.
  • git diff --check passed.
  • Effective PR diff against its master base: 27 files, 1,709 additions and 96 deletions, excluding the uncommitted design/review documents.
  • Three independent final review scopes converged with no new P1/P2 findings after fixing task preloading, pool-disabled client reuse, and Hive's standard partition-limit classifier.
  • Focused Maven compilation/tests reused the worktree's existing generated sources because thirdparty/installed is absent; no successful full ./build.sh --fe run is claimed.

@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?

@morrySnow morrySnow changed the title [improvement](fe) Batch Hive metastore partition access [improvement](hive) Batch Hive metastore partition access Aug 27, 2026
Issue Number: None

Related PR: None

Problem Summary: Hive tables with very large partition counts could issue one HMS RPC per partition or one unbounded getPartitionsByNames request. This caused excessive serial RPC latency and exposed Thrift message-size, timeout, memory, cancellation, cache-concurrency, and observability gaps. Add one HMS-owned bounded batch loader with adaptive halving for classified Thrift failures, strict result-integrity validation, request deadline and cancellation, physical RPC metrics, and Query Profile events. Reuse it from query, MTMV, statistics, display, and regular write partition-object paths, and coalesce concurrent cache misses per partition with bounded FIFO load slots.

Hive metastore partition-object access is now bounded, cancellable, observable, and shared across query, MTMV, statistics, display, and write paths.

- Test: Unit Test
    - HMS batch, cache, and pool tests
    - Hive metadata and transaction tests
    - MTMV and connector profile tests
- Behavior changed: Yes (large Hive partition-object reads use bounded HMS batches with adaptive fallback and strict integrity checks)
- Does this need documentation: No
@CalvinKirs

Copy link
Copy Markdown
Member Author

run buildall

@CalvinKirs

Copy link
Copy Markdown
Member 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.

Requesting changes. Three review rounds converged cleanly—all final-round reviewers returned NO_NEW_VALUABLE_FINDINGS—on nine distinct issues: five P1 correctness/compatibility/capacity problems and four P2 lifecycle/observability problems. The review is complete rather than capped.

Critical checkpoint conclusions:

  • Goal and proof: the PR establishes the intended common HMS batching, integrity, cancellation, cache-coordination, and telemetry path, and the added unit tests prove many normal/error paths. The nine inline defects prevent the implementation from safely meeting the full contract.
  • Scope and clarity: this is a justified but broad 58-file cross-cutting change. The raw-loader/cache/SPI decomposition is generally clear; the remaining defects concentrate at ownership and phase boundaries.
  • Concurrency: query/MTMV/display request threads coordinate through per-key in-flight state, FIFO slots, and striped locks while HMS RPCs stay outside locks. Normal owner/waiter cleanup and lock ordering are sound, but refresh can miss a newly registered publisher, cache-disabled traffic bypasses admission, and MTMV local mapping/version capture is not atomic.
  • Lifecycle/static state: task-owned StatementContext cleanup and successful connector replacement are sound. Temporary validation contexts and superseded failed-init contexts leak shared metrics references. No C++ static-initialization concern applies.
  • Configuration: the new HMS batch/fallback properties are validated and wired consistently through Hive and Hudi; they are catalog-scoped rather than dynamic process variables. Disabling partition retention incorrectly disables the pool-derived admission bound.
  • Compatibility: the public connector SPI surface changes without the repository-mandated 7.0 major bump, so the major-only plugin gate permits incompatible 6.x linkage. No storage-format or FE/BE protocol change is present.
  • Parallel paths: all eight production partition-object callers and Hive/Hudi construction were traced. Query/write/statistics sources and sessions are propagated; SHOW/display purpose is not, and the analogous task/display MTMV phase split needs the same ownership fix.
  • Conditions and error handling: strict identity/order validation, typed integrity failures, statement deadlines, and cancellation/pool-taint boundaries are otherwise sound. The generic TTransportException condition is too broad, and the MTMV outside-lock predicate is too broad.
  • Tests and results: changed tests cover batching, fallback state, result integrity, owner/waiter cleanup, cancellation, metrics/profile aggregation, and MTMV bulk caching. Missing decisive coverage is called out inline for refresh registration, disabled-cache zero-pool concurrency, mixed/cloud mapping races, context ownership, DISPLAY, outer logical-event aggregation, and process wait metrics. Per the review prompt, I ran no build or tests. Current CI has green style/security/coverage contexts; FE UT, compile, performance, and automated review are still pending.
  • Observability: event schema/cardinality and profile serialization are generally sound, but context leaks, DISPLAY mislabelling, caller-event misaggregation, and missing process wait metrics make the advertised telemetry inaccurate.
  • Transactions, persistence, writes, and FE/BE variables: no transaction protocol, persisted schema, EditLog payload, storage format, or FE-to-BE variable was added. Replay initialization and Hive write/transaction callers were audited; their accepted issue is the shared context lifecycle leak, not transaction atomicity.
  • Performance: bounded physical batches and single-flight improve the intended large-partition path, but ordinary outages can be amplified through the halving ladder and cache-disabled zero-pool traffic can open unbounded concurrent clients.
  • Other applicable checks: this PR is FE Java only, so BE memory tracking, nullable-column handling, delete bitmaps, and C++ static/TU rules are not applicable. No additional issue survived the final changed-file and missed-path sweep.

No additional user-provided review focus was supplied.

this.rawStoragePropsSupplier =
Objects.requireNonNull(rawStoragePropsSupplier, "rawStoragePropsSupplier");
this.environment = buildEnvironment();
this.metadataAccessMetrics = new ConnectorMetadataAccessMetrics(catalogName);

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] Give the validation metrics reference an owner. This constructor now acquires a shared per-catalog metrics reference even for the temporary context created by forCatalogCreationValidation(). CatalogFactory passes that context inline and retains only the connector, while PluginDrivenExternalCatalog explicitly leaves connectorContext null for this validation connector, so neither initialization nor catalog teardown can call DefaultConnectorContext.close() on it. Each create/replay attempt therefore leaves an entry in SHARED_METRICS; after the live catalog records metrics, DROP also cannot unregister those catalog-labelled series because the leaked reference keeps the count nonzero. Please make validation use a non-acquiring metrics sink or give the temporary context an explicit owner that closes it on every success/failure/fallback path. The same ownership rule is also needed for live initialization: construct into a local context, publish it only after connector creation succeeds, and close it on null/throw so repeated retries cannot overwrite and leak failed contexts.

}
// Write binding gained execution-capability methods in this surface revision. A plugin built against
// major 5 must be refused rather than run against a contract it did not compile against.
// Write binding gained execution-capability methods, while metadata access gained operation control,

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.

[P1] Bump the connector SPI major for this surface change. This PR adds methods and types to the public connector SPI, but the API is still stamped as 6.0. The policy beside connector.plugin.api.version requires a same-commit major bump for any SPI surface addition, and ApiVersionGate checks only major equality. As written, a plugin compiled against these new APIs is labelled 6.0 and can be accepted by an older 6.0 FE, then fail at first use with NoSuchMethodError/NoClassDefFoundError. Please bump the connector API major (and this assertion) to 7.0 in this commit.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks for calling this out. We intentionally will not bump the connector SPI to 7.0 in this PR. The compatibility boundary should be a published connector API version, not every PR that evolves an API which is still unreleased on master. Connector SPI 6.0 was introduced on master on Aug 17, 2026, and no release tag contains that commit, so 6.0 is still the next unpublished surface; this PR updates that same pre-release surface and its frozen baseline before publication. Once 6.0 is released, a subsequent incompatible surface change must bump the major. Bumping the major once per pre-release PR would consume versions without creating a real artifact compatibility boundary. The existing major gate still correctly separates published/older major 5 plugins from the upcoming major 6 API.

try {
invalidateInFlightPartitionLoads(key -> key.matches(dbName, tableName), true);
} finally {
stateLock.unlock();

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.

[P1] Keep registration fenced through the cache clear. The state lock is released before partitionsCache.invalidateIf() bumps the generation. A cold request can therefore register after the in-flight scan, start its HMS RPC, then let this refresh clear the cache and return; because that new batch was never marked invalid and publishOwnedPartitions() uses a direct put, its pre-clear load is cached afterward for the full TTL. The same gap exists in partition/DB/catalog invalidation. Please perform the matching cache invalidation under the same stripe(s), or capture/check a refresh epoch at owner publication, and add the mark/register/clear/publish interleaving to the concurrency tests.

}
for (Throwable current = failure.getCause(); current != null; current = current.getCause()) {
String className = current.getClass().getName();
if (className.endsWith(".TTransportException")) {

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.

[P1] Do not halve batches for every transport outage. This class-name check makes a closed/refused/reset/EOF/timeout TTransportException degradable even though reducing the payload cannot repair the connection. With the defaults, one 5,000-name offset can be replayed 13 times down to size 1 within the 30-second budget, and each logical call sits above Hive's own retry/reconnect proxy and may create/taint another client. That amplifies an HMS outage precisely while it is unhealthy. Please restrict fallback to explicit frame/message/request/partition-limit signals (or a proven oversize transport code), and make ordinary transport failures terminate after the original logical attempt.

int start = 0;
private void loadMissingPartitions(HmsPartitionRequest request, List<String> initialMissNames,
Map<List<String>, HmsPartitionInfo> resultByIdentity) {
if (!partitionsCache.isEffectiveEnabled()) {

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.

[P1] Preserve load admission when partition caching is disabled. This early return skips both single-flight retention and the new window/slot limiter. In the supported hive.metastore.client.pool.size=0 configuration, the constructor deliberately converts zero to one cold-load slot, but every disabled-cache request now bypasses that slot and ThriftHmsClient creates a fresh client per call; N concurrent scans/freshness probes can therefore open N HMS connections. Please keep windowing and slot admission on this path while skipping only cache coordination/publication, and cover zero-pool plus disabled cache concurrently.

MTMVPartitionUtil.addPartition(mtmv, partitionKeyDesc);
}
}
boolean buildContextUnderLock = Config.isNotCloudMode()

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.

[P1] Keep local PCT mappings atomic with their versions in mixed MVs. This condition moves the entire context build outside the sorted table locks whenever any base table is MVCC. If the actual PCT table is a local OlapTable, its mapping is copied here at T1, external preload can then block, and the later locked refreshLocalBaseVersions() refreshes only versions—not partitionMappings. A local partition dropped in that window remains in the mapping and makes the locked version lookup fail; an added partition is omitted from comparison/refresh. The base code built both together under the locks. Please split the capture so external pins/I/O stay outside, while local PCT mappings and versions are rebuilt together under the sorted FE locks. Cloud local-only plans also always take this branch and the refresh helper is a no-op there, so preserve an atomic cloud capture as well. Apply the same fix to the analogous PartitionsProcDir branch and add mixed local-PCT/external-MVCC plus cloud local-only race tests.

}
HiveTableHandle hiveHandle = (HiveTableHandle) handle;
List<HmsPartitionInfo> partitions = hmsClient.getPartitions(
session, HmsPartitionAccessSource.MTMV,

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 display source in freshness telemetry. SHOW PARTITIONS now builds and preloads MTMVRefreshContext, reaches these freshness methods, and is always emitted as MTMV here; the sibling whole-table freshness call is hard-coded the same way. There is no production use of the newly added HmsPartitionAccessSource.DISPLAY, so display traffic is indistinguishable from refresh/rewrite work in both process metrics and Query Profile despite the per-source observability contract. Please thread the logical access purpose into this freshness request and emit DISPLAY for the proc/display path, with a production-chain test.

request, initialMissNames, partitionsCache.invalidationGeneration(), resultByIdentity);
return;
}
for (int offset = 0; offset < initialMissNames.size(); offset += partitionLoadWindowSize) {

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] Emit one logical event for the caller's request. The cache splits one business request into partitionLoadWindowSize windows and each copied request invokes the raw loader, whose finally records a completed logical event. A cold 12,000-name call therefore increments LogicalRequests three times; if the third window fails, the single caller-visible request is reported as two successes plus one failure. The cache-disabled path reports the same call once, so success rates and requested-item metrics depend on cache configuration rather than business semantics. All-hit and pure-waiter calls emit no completed business event, and mixed hit/miss calls report only owner misses. Please move event ownership to the outer cache call, aggregate the shared business-request state, and emit exactly once while retaining physical-attempt counters; test all-hit, mixed, pure-waiter, and multi-window later-failure cases.

.success(success)
.build();
try {
request.getMetadataAccessObserver().record(event);

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] Publish coordination waits to process metrics too. Both in-flight and cold-load-slot wait events are recorded only through the request observer, which is a Query Profile sink and becomes NOOP when profiling is disabled. The catalog observer used by the raw loader never reaches this cache layer, so FE metrics permanently omit both newly advertised wait operations even while reporting their downstream HMS call. Please give the cache the catalog observer and safely publish these events to both sinks, with process-metric coverage when query profiling is disabled.

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17583	3020	3025	3020
q2	2100	270	226	226
q3	10222	897	526	526
q4	4671	247	197	197
q5	7682	574	392	392
q6	140	117	94	94
q7	536	492	389	389
q8	9250	860	894	860
q9	3447	2396	2410	2396
q10	6485	833	706	706
q11	391	193	188	188
q12	610	263	197	197
q13	18132	1515	1184	1184
q14	160	152	135	135
q15	q16	435	398	365	365
q17	1376	910	847	847
q18	3069	2220	2231	2220
q19	1110	863	810	810
q20	360	287	200	200
q21	5262	1666	1890	1666
q22	316	266	232	232
Total cold run time: 93337 ms
Total hot run time: 16850 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3413	3329	3329	3329
q2	503	381	366	366
q3	2213	2368	2199	2199
q4	1175	1150	875	875
q5	2185	2084	2086	2084
q6	171	124	85	85
q7	1012	916	870	870
q8	1590	1391	1384	1384
q9	3121	3052	3054	3052
q10	1832	1787	1618	1618
q11	356	269	248	248
q12	449	428	345	345
q13	1474	1549	1160	1160
q14	177	179	158	158
q15	q16	396	400	368	368
q17	3558	3369	3290	3290
q18	4827	4392	4680	4392
q19	921	816	891	816
q20	1015	955	813	813
q21	3728	3037	3213	3037
q22	402	347	322	322
Total cold run time: 34518 ms
Total hot run time: 30811 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 81114 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 7ab8c5329b97a6ac3e9361e593383e5ac0bf6bd8, data reload: false

query5	4269	418	341	341
query6	399	133	120	120
query7	4934	397	235	235
query8	310	130	125	125
query9	8692	2849	2837	2837
query10	392	215	181	181
query11	5392	1026	924	924
query12	128	71	76	71
query13	1212	411	323	323
query14	5966	2163	2055	2055
query14_1	1951	1935	1913	1913
query15	171	122	113	113
query16	922	361	345	345
query17	805	459	386	386
query18	2320	315	235	235
query19	165	128	109	109
query20	70	66	68	66
query21	206	105	89	89
query22	5471	5328	5327	5327
query23	6726	6139	6044	6044
query23_1	5966	5934	5926	5926
query24	7315	1101	742	742
query24_1	773	759	770	759
query25	407	289	266	266
query26	1227	234	125	125
query27	2799	430	253	253
query28	4690	1488	1450	1450
query29	913	417	327	327
query30	253	156	128	128
query31	811	399	323	323
query32	128	82	73	73
query33	454	209	180	180
query34	983	810	477	477
query35	397	394	334	334
query36	572	569	521	521
query37	122	81	72	72
query38	1001	836	805	805
query39	468	497	473	473
query39_1	461	482	453	453
query40	201	94	101	94
query41	53	51	52	51
query42	71	69	69	69
query43	234	235	209	209
query44	1023	547	545	545
query45	106	105	96	96
query46	781	833	510	510
query47	753	774	705	705
query48	318	297	245	245
query49	559	255	174	174
query50	734	253	191	191
query51	8039	7849	7942	7849
query52	69	67	60	60
query53	195	191	151	151
query54	220	199	170	170
query55	73	57	55	55
query56	217	166	171	166
query57	692	641	689	641
query58	215	187	171	171
query59	1215	1225	1101	1101
query60	268	196	191	191
query61	140	135	139	135
query62	364	218	181	181
query63	170	142	142	142
query64	2970	803	687	687
query65	1689	1632	1602	1602
query66	1973	346	222	222
query67	9817	9614	9606	9606
query68	2909	1172	712	712
query69	347	219	183	183
query70	680	604	615	604
query71	248	178	164	164
query72	2301	1378	1557	1378
query73	637	574	349	349
query74	1980	1203	1138	1138
query75	1164	1087	943	943
query76	2312	730	555	555
query77	244	251	220	220
query78	3966	3569	3076	3076
query79	2699	800	571	571
query80	1559	328	273	273
query81	496	154	134	134
query82	630	121	99	99
query83	270	206	190	190
query84	291	114	91	91
query85	823	357	299	299
query86	470	183	159	159
query87	1020	971	876	876
query88	2830	2086	2103	2086
query89	280	198	175	175
query90	2015	129	127	127
query91	127	120	99	99
query92	95	72	61	61
query93	1443	1065	703	703
query94	617	254	215	215
query95	528	266	229	229
query96	836	572	269	269
query97	1025	1120	1015	1015
query98	174	133	130	130
query99	419	348	310	310
Total cold run time: 178282 ms
Total hot run time: 81114 ms

@hello-stephen

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

query1	0.00	0.00	0.01
query2	0.08	0.04	0.03
query3	0.24	0.11	0.11
query4	1.60	0.09	0.10
query5	0.18	0.16	0.16
query6	1.25	0.67	0.72
query7	0.03	0.00	0.01
query8	0.04	0.02	0.04
query9	0.29	0.21	0.22
query10	0.33	0.35	0.35
query11	0.16	0.11	0.10
query12	0.15	0.12	0.12
query13	0.30	0.30	0.30
query14	0.44	0.45	0.43
query15	0.35	0.34	0.34
query16	0.22	0.23	0.25
query17	0.67	0.68	0.73
query18	0.18	0.15	0.16
query19	1.16	1.08	1.05
query20	0.01	0.01	0.01
query21	15.43	0.14	0.11
query22	5.08	0.05	0.04
query23	16.16	0.25	0.10
query24	3.04	0.32	0.26
query25	0.12	0.04	0.03
query26	0.81	0.16	0.13
query27	0.02	0.02	0.04
query28	3.61	0.54	0.27
query29	12.48	3.13	2.55
query30	0.26	0.12	0.14
query31	2.76	0.36	0.17
query32	3.51	0.32	0.23
query33	1.36	1.39	1.41
query34	15.35	2.15	1.80
query35	1.76	1.70	1.71
query36	0.46	0.30	0.28
query37	0.07	0.05	0.05
query38	0.05	0.03	0.02
query39	0.03	0.02	0.02
query40	0.13	0.09	0.08
query41	0.08	0.02	0.02
query42	0.03	0.02	0.02
query43	0.04	0.03	0.02
Total cold run time: 90.32 s
Total hot run time: 14.48 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 71.59% (315/440) 🎉
Increment coverage report
Complete coverage report

@CalvinKirs

Copy link
Copy Markdown
Member 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.

Request changes. Three review rounds converged with four additional issues: one P1 cancellation/lifecycle gap and three P2 compatibility/performance gaps. I did not duplicate the eight existing issue threads; their unresolved blockers remain part of this verdict. The live PR still matches the authoritative bundle at head 7ab8c5329b97a6ac3e9361e593383e5ac0bf6bd8. Current CI has compile, FE UT, CheckStyle, P0, non-concurrent, vault, and performance checks passing, while External Regression and cloud_p0 are failing.

Critical checkpoint conclusions:

  • Goal and proof: The PR implements batched/cached HMS partition freshness, cooperative cancellation, telemetry, and MTMV bulk snapshot loading, and its unit tests prove many component paths. It does not fully achieve the stated bounded/large-scale behavior because client construction remains outside cancellation/deadline control, the cache-backed scale path repeats canonicalization, and MTMV can eagerly load a huge union before a locally decisive stale gate.
  • Scope and focus: The 58-file connector/HMS/MTMV change is internally related but not yet safely mergeable. The user focus file contained no additional focus request; the full PR was reviewed.
  • Concurrency and thread safety: Enabled-cache owner/waiter futures, permits, publication, retry cleanup, and lock ordering otherwise balance. Existing threads already cover the cache-invalidation fence and disabled-cache admission bypass; the new P1 below covers synchronous client creation before cancellation can act. Heavy external work is generally moved outside FE locks, subject to the existing mixed local/cloud atomicity thread.
  • Error handling: Strict result-integrity failures and cancellation propagation are fail-loud and preserve causes in the inspected paths. The existing broad transport-fallback thread and the new eager-preload ordering can still amplify or surface avoidable HMS failures.
  • Lifecycle: Watchdog ThreadLocal cleanup, interrupt ownership, pooled-client taint/return, statement pins/scopes, and normal connector-context close were traced. Existing metrics-reference ownership remains a live thread; any fix for client creation must destroy a late result after cancellation, deadline, or concurrent close.
  • Configuration and dynamic behavior: Hive and Hudi bind the same positive batch/timeout properties and defaults through catalog construction/replay. No additional dynamic-update divergence survived review.
  • Compatibility and rolling upgrade: Default SPI methods preserve old implementation linkage, and the existing API-major thread includes the unreleased-6.0 context. Separately, the frozen-surface test omits the new reachable session/control/observer/event/abort contracts and metadata return types, so future incompatible drift can evade the gate.
  • Parallel paths: Query, statistics, MTMV, and write callers plus Hive/Hudi construction were checked. Rewrite, task, metadata/global sync, and proc/display MTMV paths were all traced. The existing DISPLAY-source thread remains the only distinct source-label issue.
  • Special conditionals: Excluded-table and PCT-first comparison semantics are intentional. Existing review context covers transport degradability and cache-disabled branching; the new MTMV finding covers preload ordering before the name-set condition.
  • Test coverage: Added tests cover batching, strict ordering, cache coordination, pool wait cancellation, metrics/profile aggregation, context capture, and 160k aggregation. Missing cases are identified inline: blocking client creation, frozen reachable SPI contracts, cache-backed parse counts, and large name-set mismatch with zero freshness calls.
  • Test results: This review-only environment expressly prohibited builds/tests, so none were run here. No regression .out files changed. Live FE UT/compile/style checks pass, but External Regression and cloud_p0 currently fail.
  • Observability: Process metrics and Query Profile coverage were inspected. Existing threads cover metric reference ownership, fragmented logical events, missing process wait metrics, and DISPLAY attribution; no additional observability issue survived.
  • Transaction and persistence: MTMV refresh snapshot generation, manual/COMPLETE refresh, current-relation resolution, and per-partition persistence inputs were traced. No new EditLog schema is introduced; the existing MTMV mapping/version atomicity thread remains applicable.
  • Data writes and crash behavior: No new BE/storage data-write path is introduced. MTMV refresh scheduling and snapshot capture were checked; no distinct crash leak or partial-write issue survived beyond the live atomicity/lifecycle threads.
  • FE/BE variables: No new FE-to-BE variable or protocol field is introduced.
  • Memory safety and nullable handling: The change is Java/FE-only; BE allocator, C++ lifetime, and nullable-column checkpoints are not applicable. Java ownership and large temporary allocations were reviewed, with the repeated identity allocation issue called out inline.
  • Data correctness: Strict partition identity, duplicate, missing, unexpected, and ordering checks are coherent. Existing threads cover cache freshness fencing and MTMV atomicity; the dismissed display snapshot split predates this PR.
  • Performance: Batching removes per-partition RPCs, but the cache-backed request performs 3N parses on all hits and 6N+C when fully cold, and MTMV may issue a 160k-name freshness load before a set mismatch already proves staleness.
  • Other issues and completion: All candidates are accepted, deduplicated, or dismissed with code evidence. Round 3 ended with NO_NEW_VALUABLE_FINDINGS from both normal full reviews and the independent risk review, so this review is complete.

waitMillis = Math.min(waitMillis, operationRemainingMillis);
}
try {
return clientPool.borrowObject(waitMillis);

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.

[P1] Bound HMS client creation with the operation control. On an empty pool, Commons Pool 2.2 runs HmsClientFactory.create() synchronously inside borrowObject(waitMillis) before the timed idle-object wait, so waitMillis does not bound createFreshClient(); the pool-disabled branch calls it directly as well. Kerberos login, DNS, or socket construction can therefore remain stuck after KILL/deadline, before HmsRemoteCallTracking installs its watchdog and before the next checkActive(). Please make creation cancellable/deadline-aware (and destroy any client that completes late) for both branches, with blocking-provider KILL/deadline tests.

return ConnectorStatementScope.NONE;
}

/** Returns cooperative cancellation and deadline control for connector metadata operations. */

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] Freeze the new session/control API in the plugin surface. ConnectorPluginSurfaceTest.FROZEN_TYPES does not include ConnectorSession or the new control/observer/event/abort types, so the regenerated baseline records ConnectorContext#getMetadataAccessObserver() but not these two session methods or the callable contracts they expose. The separate metadata baseline also omits return types. That leaves later removal/re-signing of this new 6.0 surface invisible to the stated compatibility speed bump. This is independent of whether 6.0 is still unpublished: please freeze these reachable SPI types (or recursively freeze reachable SPI contracts), regenerate the baseline, and assert the new methods are present.

operationControl.checkActive();
}
String partitionName = partitionNames.get(i);
HmsPartitionIdentity.ParsedPartitionName parsed = HmsPartitionIdentity.parse(partitionName);

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] Retain parsed identities across the cache-backed request. This builder validates every partition name with HmsPartitionIdentity.parse() and then discards the result. The normal cold-cache path reparses all names during cache lookup, registration, copied-window construction, raw validation, and final reconstruction—6N+C parse/unescape passes for a fully cold sole owner (roughly 720k canonicalizations for 120k names); even all hits take 3N. The added 120k test covers only the raw loader, so it misses this decorator cost. Please carry immutable parsed keys/values on the request and share/slice them through windows and validation, with a cache-backed large-request parse-count/performance test.

throws AnalysisException {
MTMV mtmv = context.getMtmv();
Set<String> partitionNames = mtmv.getPartitionNames();
context.preloadSnapshots(partitionNames, tables, excludeTables);

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] Check the persisted partition set before eager freshness loading. This preload fetches partition-detail freshness for the entire mapped PCT union before isSyncWithPartitions() compares the current names with the persisted getPctSnapshots() set. With a coarse mapping over 160k Hive partitions, adding or dropping one partition already proves the MTMV stale locally, but this order now issues the full HMS freshness request first (and can fail before returning that deterministic stale result); the pre-PR path performed the set gate before fetching snapshots. Please make the comparison two-phase—reject name-set mismatches first, then preload only mappings that still need version checks—and add large mismatch coverage asserting no partition-freshness call.

@CalvinKirs

Copy link
Copy Markdown
Member 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 the authoritative 58-file bundle and all live/raw review comments through three convergence rounds. Two additional non-duplicate issues remain, alongside the unresolved live blockers, so I am requesting changes.

Key checkpoints: the cross-layer scope matches the stated bounded/cancellable HMS-load and MTMV-freshness goal, and the new request, loader, control, telemetry, and refresh-context helpers generally keep responsibilities clear. Strict response validation/order, typed cancellation, cache/pool cleanup, connector construction, statement-scope closure, and the main query/statistics/scan/write/refresh/rewrite/display paths were traced. The remaining new gaps are (1) rewrite eagerly loading locally rejectable candidates while planner locks are held and (2) equivalent waiters serially replaying a shared integrity failure. Existing threads already fence the other identified concurrency, invalidation, compatibility, metrics, and eager-loading concerns. Hive/Hudi configuration validation and SPI forwarding were checked; this patch changes no storage/EditLog format, transaction protocol, FE/BE wire value, or BE memory/nullability path.

No local build or tests were run because the review bundle forbids them. Current checks show FE UT, compile, P0, nonconcurrent, and vault passing; External Regression and cloud_p0 are failing, with no public failure detail available from the linked TeamCity endpoints. The changed unit tests cover most raw/cache/control and MTMV batch paths, but not the two concurrent/production-chain cases called out inline.

Comment thread fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRewriteUtil.java Outdated
### What problem does this PR solve?

Issue Number: None

Related PR: apache#67186

Problem Summary: The shared Hive metastore partition batch path still had lifecycle, concurrency, compatibility, and MTMV freshness edge cases found during review. Blocking HMS client construction could outlive cancellation, parsed identities were repeatedly rebuilt in cache windows, equivalent waiters could replay terminal integrity failures, and rewrite or refresh paths could preload metadata before deterministic stale gates. This change makes client creation operation-controlled, reuses immutable parsed identities, scopes waiter retries, applies persisted-set gates before freshness loading, and completes SPI and metrics lifecycle coverage.

### Release note

Hive metastore partition batching now has stronger cancellation, concurrent failure sharing, MTMV freshness gating, and connector SPI compatibility checks.

### Check List (For Author)

- Test: Unit Test
    - Targeted FE unit tests for HMS cache concurrency, pool control, batch loading, MTMV rewrite and refresh, metrics, and Connector SPI surface
- Behavior changed: Yes. Equivalent cache waiters share terminal integrity failures, narrower waiters retry independently, and MTMV rewrite skips freshness loads for locally rejected candidates.
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: apache#67186

Problem Summary: The new connector metadata access source import was placed before lexicographically earlier HMS and connector SPI imports in three Hive connector classes, causing the full FE CheckStyle workflow to fail. Reorder those imports according to the Doris CustomImportOrder rule.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - cd fe && mvn clean checkstyle:check
- Behavior changed: No
- Does this need documentation: No
@CalvinKirs

Copy link
Copy Markdown
Member Author

/review

@github-actions

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: Your access token could not be refreshed because your refresh token was revoked. Please log out and sign in again.
Workflow run: https://github.com/apache/doris/actions/runs/33137288710

Please inspect the workflow logs and rerun the review after the underlying issue is resolved.

@CalvinKirs

Copy link
Copy Markdown
Member Author

run buildall

@CalvinKirs

Copy link
Copy Markdown
Member 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.

Requesting changes for four distinct current-head issues: unbounded outstanding HMS client creators, MTMV persistence losing union batching on first/incomplete or mapping-changed baselines, cloud version RPCs under FE table locks, and nested wait spans inflating the legacy metadata-time total.

Checkpoint conclusions:

  • Goal, focus, and scope: the common bounded HMS path is broadly wired across query, statistics, MTMV, display, transaction, and write callers; no extra user focus was supplied. The first-refresh persistence case still misses the central batching goal.
  • Correctness, conditions, and parallel paths: strict identity/order validation and migrated Hive/Hudi caller paths were checked, including cache-enabled/disabled, pooled/unpooled, first/incomplete/changed MTMV snapshots, local/external/cloud, and success/failure/cancellation branches.
  • Concurrency and lifecycle: cache owner/waiter, invalidation, slot, retry, and publication paths were reviewed. The asynchronous creation fix has no bound on interrupt-ignoring creator tasks.
  • Configuration and compatibility: new property defaults/validation, source/control defaults, connector SPI freezes, and the unreleased-6.0 compatibility context were checked. No new FE-BE wire dependency was introduced.
  • Observability and performance: detailed operation counters remain useful, but the legacy query total double-counts nested waits. The first/incomplete MTMV path can turn a 160k disjoint mapping into roughly 160k logical one-name freshness requests.
  • Transactions, persistence, writes, and atomicity: transaction/write callers use the common API; snapshot persistence has the separate preload-mode bug below, and cloud recapture performs remote work inside metadata locks. Existing live atomicity threads were treated as duplicate fences.
  • Tests/results: reviewed the changed unit tests and the PR's reported 250-partition manual profile. No build or test command was run in this review, as required by the review task; the PR also states the 120k end-to-end case was not rerun. Missing focused coverage is called out inline.

A complete 63-file final sweep and a second full convergence round found no additional distinct issues beyond these four and existing review threads.

Comment thread fe/fe-core/src/main/java/org/apache/doris/common/profile/SummaryProfile.java Outdated
Comment thread fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRefreshContext.java Outdated
Comment thread fe/fe-core/src/main/java/org/apache/doris/mtmv/MTMVRefreshContext.java Outdated
@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17566	3068	3029	3029
q2	2102	254	237	237
q3	10223	868	526	526
q4	4672	258	200	200
q5	7674	590	392	392
q6	137	119	96	96
q7	521	526	393	393
q8	9232	920	945	920
q9	3511	2432	2442	2432
q10	6499	884	758	758
q11	402	201	182	182
q12	625	262	201	201
q13	18119	1539	1167	1167
q14	163	157	145	145
q15	q16	447	407	376	376
q17	1310	883	854	854
q18	3171	2293	2285	2285
q19	1117	929	833	833
q20	372	306	204	204
q21	4864	1820	1917	1820
q22	344	277	234	234
Total cold run time: 93071 ms
Total hot run time: 17284 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3395	3344	3325	3325
q2	541	413	393	393
q3	2229	2393	2216	2216
q4	1232	1198	923	923
q5	2254	2165	2142	2142
q6	172	119	88	88
q7	1088	962	897	897
q8	1641	1452	1440	1440
q9	3213	3186	3159	3159
q10	1890	1832	1665	1665
q11	363	277	263	263
q12	460	442	350	350
q13	1484	1537	1195	1195
q14	172	183	161	161
q15	q16	419	407	367	367
q17	3693	3458	3289	3289
q18	4927	4535	4949	4535
q19	960	895	874	874
q20	1028	1033	850	850
q21	3990	3238	3283	3238
q22	418	362	333	333
Total cold run time: 35569 ms
Total hot run time: 31703 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 83713 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 1cd171d3667c98af0dd494649fece917b5cb921a, data reload: false

query5	4299	447	343	343
query6	396	143	137	137
query7	4887	419	235	235
query8	303	128	124	124
query9	8676	3019	2998	2998
query10	393	237	191	191
query11	5417	1064	919	919
query12	138	75	72	72
query13	1184	448	330	330
query14	6092	2299	2143	2143
query14_1	2048	2034	2032	2032
query15	178	122	114	114
query16	951	385	362	362
query17	830	453	388	388
query18	2333	330	246	246
query19	163	142	113	113
query20	74	70	71	70
query21	212	104	90	90
query22	5358	5436	5360	5360
query23	6849	6320	6255	6255
query23_1	6229	6414	6096	6096
query24	7305	1118	797	797
query24_1	810	809	813	809
query25	449	319	272	272
query26	1236	240	137	137
query27	2779	424	265	265
query28	4674	1510	1518	1510
query29	943	465	372	372
query30	252	158	131	131
query31	830	410	345	345
query32	134	76	80	76
query33	476	237	196	196
query34	974	839	524	524
query35	404	400	350	350
query36	579	606	547	547
query37	124	80	71	71
query38	1023	859	818	818
query39	506	488	491	488
query39_1	473	491	481	481
query40	209	92	76	76
query41	53	57	55	55
query42	74	70	75	70
query43	242	247	213	213
query44	1021	550	578	550
query45	114	109	97	97
query46	793	804	532	532
query47	781	762	715	715
query48	320	315	218	218
query49	554	253	186	186
query50	727	273	195	195
query51	8004	8045	8124	8045
query52	68	70	59	59
query53	191	204	146	146
query54	238	281	153	153
query55	73	58	57	57
query56	216	185	163	163
query57	709	632	639	632
query58	197	174	165	165
query59	1243	1252	1117	1117
query60	244	191	186	186
query61	122	168	134	134
query62	381	222	179	179
query63	168	153	139	139
query64	2684	699	612	612
query65	1711	1571	1652	1571
query66	1774	263	217	217
query67	9865	9767	9849	9767
query68	3014	1265	739	739
query69	345	225	202	202
query70	675	617	614	614
query71	250	178	166	166
query72	2469	1791	1660	1660
query73	654	576	340	340
query74	2015	1217	1172	1172
query75	1217	1142	992	992
query76	2367	744	562	562
query77	270	265	218	218
query78	3935	3634	3252	3252
query79	2351	869	606	606
query80	1652	362	322	322
query81	497	161	138	138
query82	641	133	101	101
query83	335	215	189	189
query84	293	111	91	91
query85	843	370	315	315
query86	396	174	179	174
query87	1045	992	904	904
query88	2806	2140	2125	2125
query89	292	199	178	178
query90	1943	132	133	132
query91	135	126	104	104
query92	82	71	71	71
query93	1500	1171	725	725
query94	663	287	245	245
query95	534	329	233	233
query96	838	612	272	272
query97	1120	1094	1042	1042
query98	166	132	135	132
query99	416	351	315	315
Total cold run time: 178917 ms
Total hot run time: 83713 ms

@hello-stephen

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

query1	0.00	0.01	0.00
query2	0.08	0.04	0.04
query3	0.24	0.11	0.11
query4	1.60	0.11	0.10
query5	0.17	0.16	0.16
query6	1.24	0.71	0.73
query7	0.04	0.01	0.00
query8	0.06	0.03	0.03
query9	0.30	0.22	0.22
query10	0.36	0.36	0.35
query11	0.17	0.11	0.11
query12	0.14	0.12	0.12
query13	0.31	0.31	0.32
query14	0.46	0.48	0.47
query15	0.37	0.36	0.36
query16	0.24	0.22	0.23
query17	0.71	0.74	0.69
query18	0.18	0.16	0.15
query19	1.24	1.19	1.15
query20	0.02	0.01	0.01
query21	15.43	0.18	0.13
query22	5.02	0.05	0.04
query23	16.19	0.25	0.11
query24	3.00	0.30	0.24
query25	0.11	0.03	0.03
query26	0.78	0.17	0.12
query27	0.04	0.03	0.03
query28	3.59	0.56	0.28
query29	12.44	3.19	2.59
query30	0.25	0.11	0.12
query31	2.76	0.39	0.18
query32	3.50	0.31	0.24
query33	1.40	1.41	1.65
query34	15.40	2.27	1.82
query35	1.83	1.78	1.78
query36	0.48	0.30	0.31
query37	0.06	0.04	0.04
query38	0.05	0.03	0.03
query39	0.03	0.02	0.03
query40	0.11	0.08	0.07
query41	0.08	0.04	0.03
query42	0.03	0.02	0.02
query43	0.03	0.03	0.03
Total cold run time: 90.54 s
Total hot run time: 14.96 s

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 70.45% (379/538) 🎉
Increment coverage report
Complete coverage report

### What problem does this PR solve?

Issue Number: None

Related PR: apache#67186

Problem Summary: Review found four remaining correctness and resource-control gaps in the shared HMS partition batch work. Nested coordination spans double-counted legacy profile time, non-cooperative HMS client creation could grow unbounded daemon threads, MTMV snapshot persistence skipped union preloading for first or changed baselines, and cloud MTMV version refreshes could issue remote calls while FE table locks were held. Count only top-level HMS access in legacy totals, retain bounded client-creation admission until real creator exit, split persistence preloading from comparison gating, and preload cloud MTMV versions before locks while revalidating locked structure from raw local caches.

### Release note

Improve HMS partition batch profiling, cancellation resource bounds, MTMV snapshot batching, and cloud lock behavior.

### Check List (For Author)

- Test: Unit Test
    - SummaryProfileTest, ThriftHmsClientPoolControlTest, MTMVRefreshContextBatchTest, MTMVPartitionUtilTest, MTMVRewriteUtilTest, PreloadExternalMetadataTest (46 tests)
    - MTMVTaskTest and PartitionsProcDirTest (18 tests)
    - cd fe && mvn clean checkstyle:check
- Behavior changed: Yes. Legacy profile totals no longer double-count nested waits, HMS creators are bounded, persistence uses ungated union preloading, and cloud version RPCs run before FE table locks.
- Does this need documentation: No

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

Requesting changes for nine distinct current-head issues. Review convergence is capped/incomplete: the maximum third round found the outer Kerberos authentication gap (the ninth inline comment), so the review protocol does not allow a fourth round to prove clean convergence. All nine findings were independently validated and deduplicated against bundled and live review threads.

Critical checkpoint conclusions:

  • Goal and proof: the PR broadly implements shared bounded HMS partition loading, cancellation/deadlines, strict integrity, telemetry, and MTMV freshness preloading. The added unit tests prove many component paths, but the nine gaps below prevent the end-to-end contract from being complete.
  • Scope and focus: the 66-file FE connector/core scope is broad but related and reasonably decomposed. No additional user focus was supplied; the full PR was reviewed.
  • Concurrency and locks: cache owner/waiter publication, FIFO admission, invalidation stripes, permits, and MTMV table-lock order were traced; no additional deadlock or stale-publication issue survived current-head fixes. Remote MTMV work is generally outside FE locks. Three separate pre-wire/authentication phases still cannot abort promptly.
  • Lifecycle and memory ownership: creator slots, late-client destruction, pooled-client return, connector contexts/observers, statement scopes, and MTMV task cleanup were checked. Prepared statements retain the new refresh context across execution resets, and background parsed executors are detached from connector cancellation. This is FE Java only; BE allocator, C++ static-initialization, and nullable-column checks do not apply.
  • Configuration and dynamic behavior: Hive/Hudi batch, fallback, timeout, pool, and cache properties are consistently validated and catalog-scoped; no separate dynamic-update defect survived.
  • Compatibility: SPI defaults, forwarding, and frozen-surface tests were checked. The existing unreleased-6.0 SPI-major discussion is a hard duplicate fence. No storage format, EditLog schema, or FE-BE wire protocol is changed.
  • Parallel paths: scan, statistics, freshness, write, transaction, task, display, rewrite, scheduled insert, streaming insert, pooled/unpooled, Hive/Hudi, cloud/non-cloud, and prepared execution paths were traced. The sessionless name-list path and parsed background tasks miss the new control propagation.
  • Conditions, error handling, and data correctness: strict partition identity/order/result checks and oversize-only fallback are coherent. The remaining defects are wrong exception boundaries, cancellation swallowing, and MTMV mapping/freshness state from different pins or executions.
  • Test coverage: changed FE unit tests cover batching, fallback, integrity, cache coordination, creation/pool waits, metrics/profile, and successful MTMV preload. Missing negative coverage maps directly to the inline comments: name-list control, optional-MV failure, planner abort propagation, pin interleaving, parsed background cancellation, reconnect/relogin/outer-auth blocking, and prepared re-execution.
  • Test results: no build or test command was run because the review prompt expressly prohibits it. No regression result file changed; the PR also states the 120k end-to-end case was not rerun.
  • Observability: logical/physical/wait event aggregation, shared catalog metrics, source labels, profile serialization, and cleanup were checked; existing telemetry threads remain duplicate fences and no new observability-only issue survived.
  • Transactions and persistence: shared connector transaction binding and MTMV persistence-union preloading were traced. Existing persistence/atomicity threads fence prior issues; no new EditLog or failover defect was found.
  • Data writes and crash behavior: connector rewrite/write transaction flow is otherwise coherent, but detached cancellation can let a cancelled background rewrite/insert continue before coordinator creation. No BE crash or storage atomicity path is added.
  • FE-BE variables: no new transmitted variable or scattered thrift send path is introduced.
  • Performance: central batching/cache reuse materially improves the large-partition path. The full sessionless name list and duplicate/unpinned MTMV materialization remain problematic as described inline; no other distinct CPU, memory, or RPC amplification issue survived.
  • Other/completion: all ledger candidates are accepted, explicitly duplicated, or dismissed with code evidence; all 66 changed paths match the authoritative diff. Because Round 3 produced a new accepted issue, this review is truthfully capped/incomplete rather than claiming full convergence.

}
List<String> partNames = hmsClient.listPartitionNames(
handle.getDbName(), handle.getTableName(), MAX_PARTITIONS_FOR_STATS);
handle.getDbName(), handle.getTableName(), ALL_PARTITIONS);

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.

[P1] Keep the full name listing under the new operation control. This path first calls the sessionless listPartitionNames(..., -1), whose Thrift implementation uses ConnectorOperationControl.NONE; the session is only applied to the later sampled getPartitions call. On a cold very-large table, KILL or the statement deadline therefore cannot stop the largest HMS RPC in this statistics path (and an already-cancelled cached request still copies/shuffles the full list). Please add a session-aware name-list path and use it here and in the parallel scan/write/freshness callers, with blocking cold-list cancellation/deadline coverage.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Resolved by scope reduction in 9487b21. Query-level cancellation/deadline propagation has been removed from this PR, including ConnectorOperationControl and all session/control wiring. The PR description now explicitly lists name listing and the complete HMS cancellation lifecycle as out of scope.

}
try {
statementContext.putPreloadedMtmvRefreshContext(mtmv, MTMVRefreshContext.buildContext(mtmv));
} catch (AnalysisException e) {

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.

[P1] Preserve the optional-MV failure boundary here. buildContext can materialize an external PCT snapshot and throw an unchecked DorisConnectorException, but this new unconditional cloud stage catches only AnalysisException. A query over a healthy base table can now fail because an otherwise optional candidate MTMV references an unavailable connector; the later rewrite hook historically degrades such a candidate to no rewrite. Please rethrow ConnectorOperationAbortedException, but isolate/log ordinary connector failures per candidate, with a cloud collect-stage failure test.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 9487b21. The optional cloud MTMV candidate boundary now catches AnalysisException and DorisConnectorException per candidate, logs the failure, and continues base-table analysis. PreloadExternalMetadataTest covers this connector-failure path.

}
Set<TableNameInfo> excludeTables = forceConsistent
? ImmutableSet.of() : mtmv.getQueryRewriteConsistencyRelaxedTables();
refreshContext.preloadSnapshots(mtmvNeedComparePartitions,

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.

[P1] Do not let the async-MV hook swallow operation aborts from this preload. The table boundary deliberately rethrows ConnectorOperationAbortedException, but it passes this AnalysisException-only catch and is then caught by createAsyncMaterializationContext's catch (Exception), which returns an empty MV list. If KILL/deadline fires here before a coordinator exists, planning can continue into a local base plan despite the executor's cancel flag. Please explicitly rethrow operation aborts at the hook boundary and add CANCELLED and DEADLINE_EXCEEDED planner-hook tests.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Resolved by scope reduction in 9487b21. ConnectorOperationAbortedException and query-level cancellation/deadline propagation were removed from this PR, so there is no operation-abort exception for this hook to swallow.

*/
public ExternalMetadataPreloadResult executePreload(StatementContext statementContext) {
long preloadStartTime = TimeUtils.getStartTimeMs();
preloadCloudMtmvRefreshContexts(statementContext);

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.

[P1] Build this cloud context from the statement's exact external snapshot. This call runs before normal snapshot loading, so getAndCopyPartitionItems(empty) materializes an unrecorded latest pin; later freshness uses the statement pin (or materializes latest again), while locked revalidation keeps the old external mapping. A partition added between those reads can be absent from the mapping yet compared against a newer generation, allowing an incomplete MTMV rewrite. Please install/reuse the candidate table pin before building the context and add an interleaving test proving mapping, freshness, and scan share it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 9487b21. Before building each cloud MTMV refresh context, the preload stage now installs/reuses the PCT table snapshot through StatementContext.loadSnapshots. The added test verifies snapshot loading precedes MTMVRefreshContext.buildContext, keeping mapping/freshness/scan on the statement pin.

long startMillis = ctx.getStartTime() > 0 ? ctx.getStartTime() : System.currentTimeMillis();
long deadlineMillis = startMillis + ctx.getExecTimeoutS() * 1000L;
// The connection may execute another statement later; bind cancellation to this session's statement.
StmtExecutor originatingExecutor = ctx.getExecutor();

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.

[P1] Do not capture null cancellation state for parsed-statement background tasks. ConnectorRewriteGroupTask, InsertTask, and StreamingInsertTask construct StmtExecutor(ctx, StatementBase), whose constructor never registers itself on ctx; their cancel paths mark only that executor. A connector session built during source/sink planning therefore captures null here and its cache/pool/retry waits continue until the unrelated deadline. Register every parsed executor before connector planning (centrally or at each task) and cover cancellation while background rewrite/insert metadata is blocked.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Resolved by scope reduction in 9487b21. Connector session cancellation capture and the StmtExecutor cancellation state added by this PR were removed. Background-task cancellation propagation is no longer claimed by this PR and is explicitly out of scope.


@Override
public void reconnect() throws MetaException {
HmsRemoteCallTracking.checkReconnectActive();

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.

[P1] Track the pre-wire reconnect as an interruptible unsafe phase. Between these two checks, super.reconnect may close the old transport and block in URI resolution/Kerberos/transport open, but neither retryingAfterWireFailure nor clientUnsafeAfterReconnectFailure is set. The watchdog therefore records only a generic abort and cannot return KILL/deadline until setup finishes. Mark reconnect active before entering super; if cancellation interrupts it mid-transition, taint that client. Add a blocking socket-lifetime pre-first-wire reconnect test.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Resolved by scope reduction in 9487b21. The reconnect cancellation/watchdog lifecycle was removed together with query-level HMS cancellation support. TrackingHiveMetaStoreClient now tracks only physical getPartitionsByNames attempts for observability.

if (finished || abort != null) {
return;
}
if ((retryingAfterWireFailure || clientUnsafeAfterReconnectFailure) && !wireCallActive) {

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.

[P1] Treat initial proxy authentication as a pre-wire setup phase. Hive 3.1.3 calls reloginExpiringKeytabUser() before reconnect and before method.invoke reaches the tracked raw client. While a due keytab renewal blocks on UGI/KDC, all three phase flags are false, so this branch only records a generic abort and KILL/deadline cannot return until login finishes. Model that phase explicitly (or use bounded asynchronous abandonment while retaining the borrowed client until exit) and add blocking first-attempt keytab KILL/deadline tests.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Resolved by scope reduction in 9487b21. The query cancellation watchdog and its phase model were removed. Authentication cancellation is no longer claimed and is explicitly outside this PR scope.

// Record mtmv and valid partitions map because this is time-consuming behavior
private final Map<BaseTableInfo, Collection<Partition>> mvCanRewritePartitionsMap = new HashMap<>();
// Cloud MTMV versions are loaded before planner table locks and revalidated from their local caches later.
private final Map<BaseTableInfo, MTMVRefreshContext> preloadedMtmvRefreshContexts = new HashMap<>();

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.

[P1] Clear this execution-scoped context map when a prepared statement resets MVCC state. PREPARE and EXECUTE reuse the same StatementContext; resetMvccSnapshots clears normal pins and the preload completion marker, but not this map. The next EXECUTE reruns preload, skips buildContext here, and can retain prior external partitionItems plus freshness caches while its scan uses a fresh pin, allowing a stale MTMV rewrite. Clear/rebuild the map under the execution's exact pin and add PREPARE-to-first-EXECUTE and two-EXECUTE external-change tests.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 9487b21. StatementContext.resetMvccSnapshots now clears preloadedMtmvRefreshContexts together with the other execution-scoped snapshot state. StatementContextTest verifies a preloaded MTMV context is removed on reset.

T result;
try {
return doAs(() -> action.call(pooled.client));
result = doAs(() -> {

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.

[P1] Install operation control before entering the outer Kerberos doAs. The action that starts HmsRemoteCallTracking.withTracker runs only after AuthAction.execute; Hive/Hudi authentication calls getUGI first, whose synchronized keytab first-use/refresh can block on another login or the KDC. KILL/deadline therefore has no watchdog here even though no wire call has started. Put this authenticated setup under the bounded control lifecycle (retaining the borrowed client until any abandoned auth task exits), recheck inside the callable, and add blocking Hive/Hudi keytab first-use/refresh tests.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Resolved by scope reduction in 9487b21. The asynchronous/watchdog cancellation lifecycle around outer Kerberos authentication was removed. Authentication cancellation is no longer claimed and is explicitly outside this PR scope.

### What problem does this PR solve?

Issue Number: None

Related PR: apache#67186

Problem Summary: The HMS partition batching change had also introduced connector-wide query cancellation and deadline APIs. That lifecycle propagation substantially enlarged the change and remained incomplete across metadata entry points and blocking HMS client setup paths. Remove that SPI and lifecycle code so this change stays focused on the common HMS partition batching implementation. Keep bounded chunks, adaptive halving for size-limit failures, strict response integrity, cache single-flight loading, observability, and MTMV snapshot preload consistency.

### Release note

Hive HMS partition batching no longer adds connector-level query cancellation or deadline APIs. Existing batching, fallback, integrity validation, cache sharing, and metadata access metrics remain unchanged.

### Check List (For Author)

- Test: Unit Test
    - ./run-fe-ut.sh --run HmsPartitionBatchLoaderTest,CachingHmsClientTest,PreloadExternalMetadataTest,StatementContextTest,ConnectorSessionImplTest,PluginDrivenMvccExternalTableTest,HiveConnectorMetadataFileListStatsTest
    - ./run-fe-ut.sh --run HmsClientConfigBatchTest,ConnectorMetadataSurfaceTest,ConnectorPluginSurfaceTest,SummaryProfileTest,ConnectorMetadataAccessMetricsTest,MTMVPartitionUtilTest,MTMVRefreshContextBatchTest,MTMVRewriteUtilTest,MTMVTaskTest
    - ./build.sh --fe was attempted but stopped while downloading unixODBC because the downloaded archive was empty and failed MD5 validation
- Behavior changed: Yes. Query cancellation and deadline propagation are removed from this PR; HMS partition batching behavior is retained.
- Does this need documentation: No

@924060929 924060929 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.

[P2] Separate logical partition access, batch execution, and HMS transport. A shared path for cache reuse, bounded batching, fallback, response validation, and metrics is the right direction. The problem is that the current implementation combines those responsibilities through HmsPartitionRequest and the HmsClient decorator chain, leaving several architecture issues:

  1. HmsPartitionRequest is described as immutable request data, but it also carries a PartitionChunkConsumer, a shared mutable BatchExecutionState, and a logicalAccessOwner flag. Its behavior therefore depends on which decorator copied it and which layer is currently executing it; it is both a request DTO and an execution context.
  2. Cache publication is implemented as a reverse callback through the transport path. CachingHmsClient installs the consumer, calls its delegate, ThriftHmsClient enters HmsPartitionBatchLoader, and the loader invokes the consumer to publish entries and complete owner work back in CachingHmsClient. This creates a logical dependency cycle between cache/access and transport/batching instead of a one-way pipeline.
  3. The HmsClient.getPartitions(HmsPartitionRequest) bridge now has an implicit behavioral contract that is stronger than its type contract. CachingHmsClient assumes that its delegate invokes the chunk consumer exactly once for every validated chunk, while the default implementation simply calls the legacy three-argument method and never invokes it. The cache consequently works correctly only with delegates that know this hidden decorator protocol, and the post-call unpublished checks are compensating for that abstraction leak.
  4. There are two orchestration layers: CachingHmsClient splits misses into load windows and coordinates owners/waiters, while HmsPartitionBatchLoader splits those windows again and manages adaptive batch state. Logical and physical metrics then cross both layers through the shared request state. This is why cache configuration, batching, fallback, single-flight completion, partial publication, and metric aggregation have to be reasoned about together.
  5. The transport is not a leaf abstraction. ThriftHmsClient.getPartitions(request) owns the batch executor entry point rather than exposing a single raw getPartitionsByNames operation, so replacing the transport or testing cache/invalidation behavior independently requires recreating the batching callback protocol.

Please keep the dependency direction one-way:

HmsPartitionAccess (cache lookup/publication, single-flight, invalidation fencing, admission, logical metrics) -> HmsPartitionBatchExecutor (chunking, halving, integrity validation, execution state, physical metrics, progressive delivery) -> HmsPartitionTransport (one getPartitionsByNames RPC).

The externally supplied request should contain only immutable logical inputs. Fallback size/timing and physical-event aggregation should live in an internal execution object owned by the batch executor. Progressive publication of fully validated chunks is useful and can remain, but pass that sink directly from the access orchestrator to the executor; do not carry it through HmsPartitionRequest and ThriftHmsClient.

This does not require removing the current cache, single-flight, fallback, or progressive-publication behavior. It changes their ownership boundaries so that each layer can be verified independently. Please preserve focused tests for all-hit and mixed hit/miss requests, overlapping owners/waiters, multi-window loads, a later-chunk failure after earlier chunks were published, and invalidation during a load. Those tests should verify that only the access layer publishes cache entries/completes owners, the executor alone aggregates physical attempts, and the transport performs only the requested single RPC.

@hello-stephen

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

------ Round 1 ----------------------------------
============================================
q1	17565	3077	3074	3074
q2	2125	268	239	239
q3	10197	896	526	526
q4	4669	261	204	204
q5	7675	585	394	394
q6	139	118	96	96
q7	540	525	408	408
q8	9254	894	967	894
q9	3480	2444	2384	2384
q10	6535	919	719	719
q11	401	200	179	179
q12	619	264	197	197
q13	18130	1534	1171	1171
q14	159	153	141	141
q15	q16	445	399	377	377
q17	1286	869	853	853
q18	3116	2278	2262	2262
q19	1259	845	798	798
q20	376	288	201	201
q21	5534	1676	1849	1676
q22	326	286	231	231
Total cold run time: 93830 ms
Total hot run time: 17024 ms

----- Round 2, with runtime_filter_mode=off -----
============================================
q1	3441	3371	3373	3371
q2	540	413	392	392
q3	2293	2519	2191	2191
q4	1214	1185	917	917
q5	2228	2148	2183	2148
q6	172	126	88	88
q7	1058	991	876	876
q8	1633	1452	1439	1439
q9	3210	3203	3173	3173
q10	1866	1858	1674	1674
q11	378	283	262	262
q12	464	434	357	357
q13	1493	1558	1180	1180
q14	186	182	164	164
q15	q16	398	408	360	360
q17	3654	3338	3300	3300
q18	4960	4511	5054	4511
q19	946	873	862	862
q20	1009	969	863	863
q21	3946	3275	3319	3275
q22	410	349	319	319
Total cold run time: 35499 ms
Total hot run time: 31722 ms

@hello-stephen

Copy link
Copy Markdown
Contributor
TPC-DS: Total hot run time: 83585 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 c98592f00fb28ad538b42653bb3a2aa3f105848a, data reload: false

query5	4255	420	354	354
query6	400	140	131	131
query7	4912	434	234	234
query8	313	133	123	123
query9	8725	3058	3056	3056
query10	425	247	188	188
query11	5406	1060	932	932
query12	123	76	74	74
query13	1205	430	317	317
query14	6032	2287	2156	2156
query14_1	2065	2103	2070	2070
query15	173	121	115	115
query16	1029	348	401	348
query17	840	476	373	373
query18	2342	347	249	249
query19	169	152	111	111
query20	77	71	70	70
query21	209	107	91	91
query22	5507	5408	5423	5408
query23	6896	6312	6065	6065
query23_1	6206	6134	6401	6134
query24	7270	1135	782	782
query24_1	828	804	802	802
query25	446	309	277	277
query26	1239	240	136	136
query27	2772	416	261	261
query28	4712	1521	1527	1521
query29	987	452	379	379
query30	252	153	134	134
query31	817	404	334	334
query32	150	84	80	80
query33	482	229	199	199
query34	1014	829	489	489
query35	414	411	358	358
query36	585	614	541	541
query37	128	83	77	77
query38	1008	864	824	824
query39	525	526	483	483
query39_1	489	484	492	484
query40	215	98	83	83
query41	63	61	60	60
query42	77	76	75	75
query43	249	248	215	215
query44	1013	572	591	572
query45	114	107	96	96
query46	809	825	515	515
query47	771	781	733	733
query48	326	313	234	234
query49	554	250	192	192
query50	782	272	200	200
query51	8266	8277	8022	8022
query52	69	69	61	61
query53	199	207	159	159
query54	249	165	152	152
query55	79	66	56	56
query56	221	185	170	170
query57	753	696	613	613
query58	207	175	161	161
query59	1239	1265	1115	1115
query60	259	195	194	194
query61	128	123	116	116
query62	400	206	178	178
query63	173	142	147	142
query64	2746	697	614	614
query65	1767	1633	1546	1546
query66	1767	262	200	200
query67	10166	9894	10064	9894
query68	2749	1241	744	744
query69	351	226	200	200
query70	703	618	615	615
query71	243	176	172	172
query72	2417	1823	1617	1617
query73	646	635	359	359
query74	1583	1268	1135	1135
query75	1196	1130	987	987
query76	2274	758	541	541
query77	267	283	221	221
query78	3992	3860	3253	3253
query79	2866	806	596	596
query80	1598	329	295	295
query81	520	161	138	138
query82	1020	131	102	102
query83	286	214	193	193
query84	294	109	94	94
query85	831	366	313	313
query86	478	178	183	178
query87	1043	998	932	932
query88	2869	2117	2137	2117
query89	289	195	176	176
query90	1977	125	135	125
query91	136	121	103	103
query92	99	76	71	71
query93	1652	1087	689	689
query94	680	274	230	230
query95	557	323	234	234
query96	858	583	286	286
query97	1072	1079	1057	1057
query98	166	140	133	133
query99	433	347	316	316
Total cold run time: 180652 ms
Total hot run time: 83585 ms

@924060929 924060929 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.

[P2] Keep the MTMV integration as a narrow, engine-agnostic bulk-snapshot adapter. The MTMV requirement here is only to avoid calling the underlying related table once per mapped base partition. Before this change, MTMV already computes the complete mapping and then reads partition snapshots in per-partition loops. That can be batched without changing MTMV's lock, pin, planner, refresh, rewrite, display, and persistence lifecycles, and without any Hive/HMS branch in MTMV code.

The current implementation instead spreads preload ownership across MTMVRefreshContext, MTMVTask, PartitionsProcDir, MTMVRewriteUtil, StatementContext, and PreloadExternalMetadata, with separate lock/cached/cloud paths and execution-scoped context cleanup. This makes the Hive batching change responsible for new MTMV snapshot and lifecycle semantics; the review issues around preload ordering, persisted-set modes, cloud version loading, and prepared-statement reset are consequences of that enlarged boundary rather than requirements of HMS batching.

Please consider reducing this to the following generic adapter path:

  1. MTMVRelatedTableIf#getPartitionSnapshots should be the only MTMV-facing abstraction. Give it a default loop over getPartitionSnapshot, and let implementations that have an efficient bulk mechanism override it. MTMV should always call this bulk-shaped method; a separate supportsPartitionSnapshotBatchLoading branch is unnecessary when the default already preserves compatibility and would leak an implementation/performance capability back into orchestration.
  2. PluginDrivenMvccExternalTable should translate the generic MTMV snapshot request to connector freshness semantics. Hive may implement that connector call with HMS batching, while snapshot-id or local implementations use their own pinned/local representation. MTMVRefreshContext should cache only generic MTMVRelatedTableIf -> partition name -> MTMVSnapshotIf values, never Hive/HMS objects, timestamps, batch sizes, or fallback state.
  3. Given a set of MV partition names, the context can collect the union of mapped base-partition names per PCT table, call getPartitionSnapshots once per table, validate the returned identities, and cache the result. Existing per-partition comparisons then read this cache.
  4. Invoke that helper only where MTMV already owns the complete set: before the loops in getMTMVNeedRefreshPartitions, isMTMVSync, getPartitionsUnSyncTables, and generatePartitionSnapshots; after rewrite's local grace/query/persisted-set filters; and, if necessary, once for all needRefreshPartitions before MTMVTask splits them into execution groups.
  5. Keep the existing partition mapping, baseVersions, MVCC-pin, locking, and persisted-snapshot semantics unchanged. With this shape, the new StatementContext preload map, planner preload rule, lock-dependent context construction, refreshLocalState* variants, and task-level statement-context lifecycle are not needed for this feature.

This intentionally leaves any pre-existing external I/O-under-lock or cross-stage MTMV snapshot-consistency optimization out of scope; those can be addressed independently. The acceptance test for this PR can stay focused: a large external-table-backed MTMV operation should issue one logical bulk snapshot/freshness request, an HMS implementation may split it into bounded physical RPCs, first/changed mappings and later persistence should reuse the operation-local generic snapshot cache, and non-Hive MTMV behavior should remain unchanged.

@hello-stephen

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

query1	0.01	0.01	0.00
query2	0.08	0.05	0.04
query3	0.25	0.10	0.10
query4	1.60	0.10	0.10
query5	0.17	0.16	0.17
query6	1.24	0.73	0.67
query7	0.03	0.00	0.00
query8	0.05	0.03	0.03
query9	0.29	0.21	0.22
query10	0.36	0.35	0.37
query11	0.17	0.12	0.12
query12	0.15	0.12	0.13
query13	0.32	0.32	0.31
query14	0.46	0.47	0.46
query15	0.36	0.36	0.36
query16	0.22	0.24	0.23
query17	0.69	0.74	0.70
query18	0.19	0.16	0.16
query19	1.33	1.22	1.20
query20	0.02	0.01	0.01
query21	15.44	0.15	0.11
query22	5.08	0.05	0.04
query23	16.18	0.26	0.10
query24	3.03	0.34	0.26
query25	0.11	0.04	0.03
query26	0.74	0.18	0.13
query27	0.04	0.03	0.04
query28	3.57	0.60	0.27
query29	12.40	3.24	2.57
query30	0.27	0.10	0.12
query31	2.75	0.37	0.18
query32	3.52	0.32	0.24
query33	1.54	1.55	1.42
query34	15.43	2.28	1.80
query35	1.80	1.81	1.75
query36	0.46	0.31	0.29
query37	0.07	0.04	0.04
query38	0.05	0.04	0.03
query39	0.03	0.03	0.02
query40	0.12	0.08	0.08
query41	0.08	0.02	0.03
query42	0.03	0.03	0.02
query43	0.04	0.03	0.03
Total cold run time: 90.77 s
Total hot run time: 14.89 s

@924060929 924060929 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.

[P2] Split independent features from the bounded HMS batching change. The core behavior can be implemented and verified as one logical partition-name request entering a batch executor, which validates/reorders bounded responses and calls a one-RPC transport. The current PR additionally changes three largely independent policies, substantially increasing the proof and compatibility surface:

  1. Connector-wide telemetry. ConnectorMetadataAccessEvent/Observer/Source, ConnectorContext and ConnectorSession propagation, per-catalog metric ownership, SummaryProfile, and source tags in query/statistics/write callers are not required for those callers to receive batching: the existing three-argument HmsClient#getPartitions can enter the common loader transparently. Detailed source-labelled process/profile telemetry is useful, but it is a separate connector-framework feature with its own SPI and lifecycle contract.
  2. Cache concurrency policy. Before this PR, CachingHmsClient already collected all misses and made one logical delegate call under an invalidation-generation fence. Bounded physical RPCs can therefore be added below the cache without introducing per-partition owners/waiters, FIFO admission, retry sharing, or progressive chunk publication. Those are valuable single-flight/capacity improvements, but they introduce independent concurrency and invalidation semantics and are the reason the cache now needs a reverse callback through the transport path.
  3. Statistics sampling semantics. Selecting a small partition-name sample before materializing partition objects changes the statistics estimation algorithm and can reduce work from N objects to K objects; it is not the same optimization as splitting N objects into bounded RPCs. It should have its own before/after and estimation-compatibility validation rather than being coupled to the batch executor.

Please keep this PR focused on the pieces needed for safe batching: batch-size configuration, a one-way access/executor/transport boundary, strict missing/duplicate/unexpected/order validation, fallback only for explicit oversize failures, Hive/Hudi binding to the shared HMS client, and minimal cache miss reassembly/publication under the existing invalidation fence. Connector-wide observability, cache single-flight/progressive publication, and sample-before-materialization can then be reviewed independently. The MTMV caller can remain a thin engine-agnostic bulk-snapshot adapter as described in the separate MTMV review, without pulling planner/statement/lock lifecycle changes into this patch.

### What problem does this PR solve?

Issue Number: None

Related PR: apache#67186

Problem Summary: Separate logical access, physical batch execution, and leaf HMS transport so cache publication is explicit and requests remain immutable. Preserve one adaptive execution across cache windows, let exact in-flight waiters attach without consuming an admission slot, bound new owners by the slot limiter, skip ineligible cloud MTMV preload candidates, and restrict size fallback to classified Thrift failures.

### Release note

None

### Check List (For Author)

- Test: Unit Test

    - 238 focused FE unit tests passed.

    - ./build.sh --fe was attempted but third-party setup downloaded an empty unixODBC archive and failed MD5 validation before FE build.

- Behavior changed: Yes (HMS batching concurrency and cloud MTMV preload eligibility are corrected)

- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: Large Hive partition requests need bounded HMS batches without duplicate concurrent loads, while MTMV rewrite must preload metadata without retaining unbounded statement state or performing external I/O under planner locks. Finalize the shared batch path with atomic per-table request registration, waiter-safe retry behavior, source-aware SPI compatibility, bounded cloud MTMV preload state, stable rewrite epochs, display-specific freshness checks, and stricter oversized-frame classification.

### Release note

Hive partition metadata access uses bounded batches, adaptive fallback, shared concurrent loads, and query-profile telemetry across query, MTMV, statistics, and display paths. Cloud MTMV preload now has a configurable snapshot budget and fails closed to the base plan when the budget is exceeded.

### Check List (For Author)

- Test: Unit Test
    - 108 focused FE unit tests for HMS batching/cache concurrency, connector SPI compatibility, MTMV metadata preload, and statement context
    - Full FE build was attempted but stopped before Maven because the unixODBC third-party archive download returned an empty file
- Behavior changed: Yes (HMS partition metadata requests are bounded and coalesced; cloud MTMV preload has a snapshot budget)
- Does this need documentation: No
@CalvinKirs

Copy link
Copy Markdown
Member Author

/review

@CalvinKirs

Copy link
Copy Markdown
Member Author

run buildall

### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: An interrupted active HMS partition-load owner could publish a nested InterruptedException that identical waiters treated as a shared remote failure. Detect interruption through the complete cause chain so waiters retry under their own operation context. Also freeze source-aware ConnectorMetadata overloads as default methods and fix the FE test import order required by Checkstyle.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - CachingHmsClientTest passed 38/38 in five consecutive focused runs
    - ConnectorPluginSurfaceTest and PreloadExternalMetadataTest passed in the focused 47-test run
    - Maven Checkstyle passed for the 60-module relevant FE reactor
- Behavior changed: Yes (waiters retry an active owner's local interruption instead of inheriting it)
- Does this need documentation: No
@CalvinKirs

Copy link
Copy Markdown
Member Author

/review

@CalvinKirs

Copy link
Copy Markdown
Member Author

run buildall

@github-actions

Copy link
Copy Markdown
Contributor

Codex automated review failed and did not complete.

Error: Codex completed, but no new pull request review was submitted for the current head SHA.
Workflow run: https://github.com/apache/doris/actions/runs/33172314039

Please inspect the workflow logs and rerun the review after the underlying issue is resolved.

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

Round 2 converged with one remaining non-duplicate issue: cloud MTMV preload applies remote work and its all-or-nothing snapshot budget before USE_MV/NO_USE_MV selection, so excluded candidates can suppress the requested rewrite.

Checkpoint summary:

  • Goal/tests: the batching, cache coordination, MTMV freshness, and observability changes are covered by focused production-path tests in the diff; I did not run builds or tests because this review harness prohibits execution.
  • Scope/compatibility/config: all 70 FE paths were reviewed; the connector SPI surface and return types are frozen by baselines, and the new HMS/session settings validate at construction.
  • Concurrency/lifecycle/observability: single-flight registration, invalidation, publication, slot release, context metric ownership, profile capture, and logical/physical event accounting are coherent at the reviewed head.
  • Parallel paths/performance: scan, batch scan, write, statistics, Hive freshness, task/display refresh, and cloud rewrite paths were traced; batching/fallback and pre-lock metadata placement are otherwise bounded.
  • Persistence/transactions/data writes/FE-BE: MTMV persistence uses the ungated union preload, Hive writes preserve exact partition actions, and this FE-only change introduces no BE variable or wire-format contract.

Existing live threads were treated as duplicate fences; no additional distinct issue survived the final sweep.

ConnectContext connectContext = statementContext.getConnectContext();
Map<MTMV, Set<MTMVRelatedTableIf>> eligibleMtmvs = new LinkedHashMap<>();
Set<MTMVRelatedTableIf> pctTables = new LinkedHashSet<>();
for (MTMV mtmv : statementContext.getCandidateMTMVs()) {

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] Apply USE_MV/NO_USE_MV before cloud preload and budget accounting. This collect-stage loop runs before Analyzer extracts those hints, while the actual hint filter is only applied later in getMaterializationContextByHint. Consequently bare NO_USE_MV and NO_USE_MV(A) still perform snapshot/version RPCs, and USE_MV(A) can lose A when A alone fits the limit but hinted-out candidates make this all-or-nothing union exceed it; the later cloud rewrite then rejects A because no context was preloaded. Share the same hint eligibility before collecting PCT tables/loading snapshots, and add zero-load NO_USE_MV plus filtered-budget USE_MV(A) tests.

### What problem does this PR solve?

Issue Number: None

Related PR: apache#67186

Problem Summary: Large Hive partition loads need bounded HMS requests, reliable fallback and shared caller semantics. This follow-up isolates per-MTMV preload failures, avoids throwaway cloud partition mappings for pinned external PCT tables, applies MV hints before cloud preload budget accounting, guarantees replaced connector contexts are released even when connector close fails, and consolidates package-private HMS batch helpers without changing their behavior.

### Release note

Hive HMS partition access uses bounded batches with adaptive fallback, shared cold-load coordination, strict result validation and profile/metric visibility. Cloud MTMV preload now respects USE_MV and NO_USE_MV before remote work and budget accounting.

### Check List (For Author)

- Test: Unit Test and local synthetic performance test
    - 244 focused FE tests passed
    - 60-module FE Maven validate/checkstyle passed
- Behavior changed: Yes (excluded MTMV candidates no longer consume cloud preload work or budget)
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: apache#67186

Problem Summary: The shared HMS partition batch implementation needed three final lifecycle fixes. Nested USE_MV and NO_USE_MV hints inside subqueries, CTEs, and views were not available when cloud metadata preload ran; prepared statements could accumulate reparsed view hints across executions; background task contexts did not expose their final executor to connector Profile observers; and metrics keyed only by catalog name could collide while a dropped catalog and a same-name replacement overlapped. This change collects raw MV hints during relation collection and resets that generation before each top-level collection, binds final background executors to their contexts, and isolates metric ownership and labels by catalog ID plus name. It also keeps the total non-documentation addition at 6,000 lines by consolidating redundant tests and comments without changing batch behavior.

### Release note

Hive HMS partition access now reports background-task metadata time consistently, handles nested MV hints without prepared-statement accumulation, and keeps metrics isolated across same-name catalog recreation.

### Check List (For Author)

- Test: Unit Test and Maven validate
    - 244 focused FE tests from all 15 changed test classes passed
    - 74-module FE Maven validate/checkstyle passed with zero violations
    - 120,000-partition unit case verified 24 batches of 5,000 with complete ordered results
- Behavior changed: Yes (nested MV hints participate in cloud preload selection and catalog metrics include catalog_id)
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: apache#67186

Problem Summary: Planner retries could reuse a connector statement scope that had already been closed by the previous attempt, retain stale MVCC rewrite state, or allow SET_VAR hints to re-enable cloud version caches during an E-230 recovery attempt. Background streaming and MTMV retries could also leave their ConnectContext installed on pooled worker threads. This change resets connector and MVCC state before every retry, keeps the two cloud version-cache TTLs disabled for the complete recovery attempt, clears stale MV rewrite partitions, and restores worker thread-local contexts with deterministic StatementContext closure. It also removes redundant test-only code so the total non-documentation addition remains below 6,000 lines.

### Release note

Hive metadata retries now rebuild per-attempt connector state, and background task contexts are closed and restored deterministically.

### Check List (For Author)

- Test: Unit Test and Maven validate
    - All 296 tests from the 17 changed FE test classes passed
    - The complete 74-module FE Maven validate/checkstyle reactor passed
    - Focused retry and context lifecycle tests passed
- Behavior changed: Yes (retry attempts use fresh connector/MVCC state and E-230 recovery keeps cloud version caches disabled for the attempt)
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: apache#67186

Problem Summary: Connector metadata observers could create unbounded process-metric series by emitting distinct operation names. Statement-scope cleanup also stopped after a plugin resource threw Error, leaving later resources unclosed. Bound per-catalog operation cardinality with an overflow bucket and continue cleanup before rethrowing the first Error.

### Release note

None

### Check List (For Author)

- Test: Unit Test
    - 307 focused FE tests from all changed test classes
    - Full FE Maven validate / Checkstyle
- Behavior changed: Yes (connector metadata metric cardinality is bounded and statement cleanup drains resources before rethrowing Error)
- Does this need documentation: No
### What problem does this PR solve?

Issue Number: None

Related PR: apache#67186

Problem Summary: The bounded connector metadata metrics used a public-valid
operation name for overflow aggregation, so a legitimate operation could be
mixed with overflow traffic. An Error raised while closing the newly installed
MTMV refresh statement scope could also bypass the task failure transition and
retain its task context. Use a private collision-free metric label and route the
MTMV cleanup failure through JobException after clearing both context references.
Restore focused lifecycle coverage for both cases.

### Release note

None

### Check List (For Author)

- Test:
    - Unit Test: 307 tests across all 18 changed test classes passed
    - Maven validate: all 74 FE modules passed with zero Checkstyle violations
- Behavior changed: Yes (metric overflow attribution and MTMV cleanup failure handling)
- Does this need documentation: No
@CalvinKirs

Copy link
Copy Markdown
Member Author

/review

@CalvinKirs

Copy link
Copy Markdown
Member Author

run buildall

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

Automated review status: complete and converged after three rounds on 41d91f39d5a2843631eee2e400abf7b70a3179eb. I found two distinct P2 observability/result-contract issues; both are attached inline.

Critical checkpoint conclusions:

  • Goal and proof: the PR implements bounded/batched HMS partition loading, single-flight cache publication, source-aware metadata metrics, and pre-lock cloud-MTMV seed/pin handling. The added unit tests cover the main helpers, concurrency, freshness, hint, and reset behavior, but they do not prove the two production paths called out inline.
  • Scope and clarity: broad, but the changes form a coherent connector-metadata/MTMV lifecycle update. The remaining gaps cross existing boundaries rather than being isolated helper mistakes.
  • Concurrency: owner/waiter registration, invalidation generations, FIFO admission, interruption, failure publication, executor/thread-local cleanup, and MTMV lock ordering were traced. No new stale-write, deadlock, permit leak, or lock-order issue survived beyond existing review threads.
  • Lifecycle/static initialization: connector metric references, context replacement/failure cleanup, statement scopes, background ConnectContext restoration, prepared execution, and retry resets were checked. No additional leak, premature release, circular lifecycle, or Java initialization problem was found; cross-TU C++ initialization is not applicable.
  • Configuration: catalog batch/fallback controls and the separate session cloud-preload budget are validated and consumed at their intended creation/execution scopes. No missing dynamic FE-process reload path was found; the independent cloud/generic controls expose the result-accounting issue inline.
  • Compatibility: source-aware SPI defaults/forwarding and frozen surface baselines were reviewed. No new storage/wire-format or rolling-upgrade issue was found beyond already-existing compatibility threads.
  • Parallel paths and conditions: all production partition-detail callers, Hive/Hudi, pooled/pool-disabled, cache-enabled/disabled, default/custom provider, QUERY/WRITE/STATISTICS/MTMV/DISPLAY, adaptive fallback, hint filters, excluded candidates, and retry paths were enumerated. The statistics-update lookup is the sole raw bypass and is reported inline.
  • Tests and results: modified tests cover batching/order/integrity, concurrency/invalidation, metrics, snapshot generations, persistence, hints, prepared execution, and retry cleanup. End-to-end negative/profile tests for the two findings are missing. No tests or builds were run in this review environment, as required by the supplied review contract; no generated expected-result changes are present.
  • Observability: logical/process/query aggregation and metric ownership were reviewed. The two remaining defects are precisely missing WRITE/retry telemetry and a false skipped/zero-time cloud-preload result.
  • Transactions, persistence, and writes: commit/undo, MTMV persistence unions, master/task cleanup, local mapping/version refresh, and crash/error paths were traced. No new atomicity or persisted-state defect was found; the write-side defect is observability, not data mutation.
  • FE/BE variables: no new variable requires FE-to-BE protocol propagation.
  • Performance: batch sizing, adaptive degradation, single-flight overlap, admission limits, snapshot budgeting, and avoidance of remote work under FE locks were reviewed. No additional nonduplicate performance regression survived.
  • Other/user focus: there was no additional user-provided focus. Every candidate is now accepted, dismissed with code evidence, or fenced by an existing live thread; Round 3 produced no new finding, so this review is not capped/incomplete.

public List<Partition> getPartitionsByNames(String dbName, String tableName, List<String> partitionNames)
throws TException {
return HmsRemoteCallTracking.trackWireAttempt(
() -> super.getPartitionsByNames(dbName, tableName, partitionNames));

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] Keep partition-statistics writes inside the new HMS access boundary. HiveConnectorTransaction.UpdateStatisticsTask reaches ThriftHmsClient.updatePartitionStatistics, whose direct client.getPartitionsByNames(...) call enters this override without HmsRemoteCallTracking.withTracker; CURRENT is therefore null and every RetryingMetaStoreClient attempt is invisible. These commit/undo lookups consequently emit neither a WRITE logical event/query-profile span nor physical retry counts, even though the parallel write-planning lookup is source-aware. Carry the session/WRITE source into statistics updates and route this singleton read through the same access/tracker boundary, with a production-chain retry-count test.


private ExternalMetadataPreloadResult executePreload(StatementContext statementContext, List<Hint> hints) {
long preloadStartTime = TimeUtils.getStartTimeMs();
preloadCloudMtmvRefreshContexts(statementContext, hints);

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] Report cloud-MTMV seed work as an executed preload stage. This call can load snapshots and install refresh contexts under the separate cloud snapshot budget, but the following generic table-preload gate can still return ExternalMetadataPreloadResult.skipped (notably with the default enable_preload_external_metadata=false). collectAndLockTable then records no preload timing and logs that preload was skipped even though remote work just completed. Compose the cloud and table outcomes so any performed work preserves the total elapsed time/executed state, and add a default-generic-off cloud test that asserts the returned result and planner profile.

### What problem does this PR solve?

Issue Number: None

Related PR: None

Problem Summary: Hive tables with very large partition counts could either issue one metadata request per partition or send one unbounded getPartitionsByNames request. This change adds one common bounded HMS batch executor with strict response validation and adaptive fallback only for explicit oversized-request failures. It also adds a narrow MTMV bulk-snapshot adapter so mapped Hive partition freshness is loaded once per table and reused across refresh execution groups, while retaining the existing MTMV mapping, locking, and snapshot lifecycles.

### Release note

Hive Metastore partition-object requests are sent in configurable bounded batches, with adaptive fallback for explicit oversized-request failures.

### Check List (For Author)

- Test: Unit Test
    - 111 focused FE core MTMV/MVCC tests passed
    - 72 focused HMS, Hive, and connector SPI tests passed
    - Maven validate passed across the relevant 60-module FE reactor with zero Checkstyle violations
- Behavior changed: Yes (large HMS partition-object requests are bounded and Hive-backed MTMV freshness uses bulk lookup)
- Does this need documentation: No
@CalvinKirs

Copy link
Copy Markdown
Member Author

run buildall

@hello-stephen

Copy link
Copy Markdown
Contributor

FE UT Coverage Report

Increment line coverage 68.63% (70/102) 🎉
Increment coverage report
Complete coverage report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants