Skip to content

perf: avoid registering unused Elasticsearch APIs for ESQL - #29563

Merged
XuPeng-SH merged 2 commits into
mainfrom
codex/ut-race-phase2-20261001
Oct 2, 2026
Merged

XuPeng-SH merged 2 commits into
mainfrom
codex/ut-race-phase2-20261001

Conversation

@XuPeng-SH

Copy link
Copy Markdown
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #29562 (partial contribution; the several-minute CI goal remains open)

What this PR does / why we need it:

ESQL uses only Info and EsqlQuery, but constructing the full Elasticsearch client registers every generated API and keeps those closures in transitive consumer executables. Call the generated requests through the existing elastictransport client, retaining its authentication, retry/replay, endpoint selection and certificate-fingerprint behavior. Keep the existing private HTTP transport, CA handling, connection cache and cleanup owners. Preserve SDK request headers/configuration with an immutable adapter and independent comparisons to the pinned original SDK.

Require a genuine 2xx Info response before publishing the connection. This also rejects HTTP 101, which previously admitted a connection before the SDK product check completed. No new product-check state, retries, cache or scheduler.

Measured locally with Go 1.26.4, race/GOAMD64v1, 8 CPU/16 GiB, p6/link3, the same 477-package light selection and warmed Go caches:

Metric Before After
Total CPU 1437.94 s 1349.68 s (-6.14%)
Repeated link CPU 948.1 s 840.4 s (-11.4%)
Cgroup peak memory, including file cache 7.96 GiB 6.65 GiB (-16.4%)
Sampled anonymous peak 5.55 GiB 5.32 GiB (-4.1%)
Unchanged isolated race executable 321,304,640 B 302,662,200 B (-5.8%)
Constructor allocations 18,679 B / 557 1,759 B / 29

All 395 test-bearing light packages passed on both sides; no cases were removed. Wall time was 778 -> 419 s, but severe baseline disk contention prevents attributing that difference to CI. Actual CI savings are unverified; this PR does not claim a six-minute saving. The test-only SDK reference still compiles typedapi once; no cold-compiler saving claimed. The final six-line QA restoration was validated in its owning package after the broader runs; production/link inputs are unchanged.

Validation: owning package normal/race; 100 race repeats each for info/query/stream cancellation, concurrent query retries and failed-handshake socket release; incremental vet/lint. Retain the original eight empty-401 idle-socket failures and add nonempty wrong/missing-product failures. Preserve private-CA, truncation, 8,192-byte error limit and cache admission/reuse/removal controls. Real SQL probe through a one-CN frontend/planner/operator/reader passed typed CSV/NULL, session reuse, bounded errors, truncated response and disconnect/101 rejection; completed teardown and exit 0. The probe uses a real HTTP fixture, not an external Elasticsearch deployment, and adds no cluster fixture to CI.

Plan and final review use actual gpt-6.1-sol with xhigh reasoning. Evidence and profiles are retained outside the delivery diff. No merge/rebase of main.

@XuPeng-SH
XuPeng-SH requested a review from aunjgr as a code owner October 2, 2026 03:40
@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@XuPeng-SH XuPeng-SH left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

审查版本:ce7f37c2b29229cc583274282602e5c7421a3ad4(base b75086c6fab613b147bff4e474dddac7e237c637)。

结论:上一轮的 SCA 阻断已修复,当前未发现新的代码阻断;完整 CI 仍在运行。

上一轮发现的五处 fmt.Errorf 会使仓库 make err-check 固定失败,与旧 HEAD 的 arm64 SCA 日志一致。最新提交已全部改用现有 moerr,并将格式化中的 %w 改为 %v,保留上层连接错误归类。本地最新 HEAD 的 make err-check 和 foreigntvf 正常 UT 均通过。

设计方向合理:只调用 Info/EsqlQuery 的 generated request,认证、端点选择、重放和重试继续交给同版本 elastictransport;连接缓存及 stream 清理沿用既有 owner。小型不可变头部适配器没有新增产品检查状态机、缓存、调度器或重试层。Info 必须是正确产品的 2xx 才准入;独立 base/head 探针确认 302/304 都在缓存准入前拒绝。

验证与质量:

  • 已完成全部五个文件及实现、测试、文档增量的审查。SDK 对照测试比较真实 HTTP 请求,取消三阶段、并发重放、失败握手 socket 计数覆盖不同 unhappy path;保留原八次空 401 失败及原成功/错误/截断 oracle。
  • 上一 HEAD 的 normal/race 整包以及三阶段取消、并发重试、失败握手各 100 次通过。本次只修改配置错误构造,相关 transport/request/cleanup/fixture 输入未改变,因此这些证据继续适用;最新 HEAD 的正常整包另行重跑通过。
  • 独立构造 benchmark 确认 557 → 29 allocs/op,约 18.7 KB → 1.8 KB。收益足以支撑局部适配器,实际 CI 的 600 秒目标仍未证实,PR 对 #29562 的部分贡献表述合理。

本次遗漏的机制是验证覆盖缺口:normal/race 与增量 vet/lint 没有覆盖 Makefile 的错误构造策略。应把便宜的实际仓库门禁纳入提交前验证,而不是增加重复功能 UT。

当前无人工/技术 review comment,只有 Qodo 暂停提示。最新 SCA/UT/coverage 等 CI 尚未完成,上述结论不代表全 CI 已通过。

XuPeng-SH added a commit that referenced this pull request Oct 2, 2026
## What type of PR is this?

- [ ] API-change
- [x] BUG
- [x] Improvement
- [x] Documentation
- [ ] Feature
- [x] Test and CI
- [ ] Code Refactoring

## Which issue(s) this PR fixes:

Fixes #29399 on `main`; forward-ports the remaining fixes from #29431
(`4.2-dev`).

## What this PR does / why we need it:

Repeated restore can mistake CLONE provenance or a view definition for
legacy CHECK metadata, lose ownership/current grants, or preserve
revoked authorization in an existing connection. Partial restore also
treated a role name as identity: renaming an owner blocked restore,
while reusing its old name could transfer DROP authority to a different
role.

- Preserve structured CHECK recovery; recognize CLONE provenance and
exclude view definitions from legacy table CHECK parsing.
- Recreate objects under historical creator/owner IDs. Partial restore
validates and pins required live principals within their physical
catalog generation. Role renames preserve identity; name reuse cannot
acquire ownership. Table restore locks and retains an existing database
without requiring its historical creator/owner.
- Resolve partial restore's historical logical source once, including
existing view dependency planning, before ownership checks and
destructive DDL. Ownership lookup intersects that source after existing
external-table and unservable-view omissions. Execution reuses the same
objects and classifications; FK/master/publication guards can still
reject or omit candidates. This prevents an irrelevant deleted view
principal from blocking ordinary data restoration, without exempting
servable views. Explicit external-table restore still rejects; skipped
single-view restore preserves the live view.
- Full account restore rebuilds principal catalogs and can rewind their
auto-increment IDs. **Partial restore across rebuilt catalogs rejects
ordinary custom principals before DROP, even if IDs/names match or full
restore legitimately reconstructed them.** Only reserved bootstrap
identities with verified IDs/names and required direct admin grants can
cross that boundary. Use a point in the current catalog generation or
full restore; documented in `docs/ai-skills/backup-restore.md`.
- Keep principal pins and current scoped grant capture/rebinding in the
existing restore transaction. DROP USER/ROLE use private pessimistic RC
transactions to honor those locks even under ordinary optimistic SI.
Partial restore preserves current grants; full/cross-account catalog
rebuilding retains its mapping.
- Apply existing DATA BRANCH authorization to ordinary-user CLONE,
preserving administrator historical/cross-account behavior, subscription
errors and recreated publisher identity mapping.
- Recheck authorization in existing and text/binary prepared connections
across CNs. Within one privilege evaluation, deduplicate only identical
SQL misses while retaining ordered errors, early hits and role/view
scope. An enum-bounded stack buffer satisfies SCA preallocation without
suppression or extra persistent authorization state.

The upstream merge at `54af0d38290c66b61ac78a46aa07a363eb576aae` is
preserved, including #29563 ESQL and #29568 FULLTEXT2/HNSW coordinator
placement. No force push, workflow change or merge-policy bypass.

### Validation

Go 1.26.4 / macOS ARM64, verified native provenance. Latest
source-selection correction (`93405cdc0ea`):

- Authenticated public SQL regression covers snapshot/PITR,
independently deleted view creator/owner, ordinary-table data recovery,
skipped live-view ID/definition/result preservation, and servable-view
missing-principal rejection before DROP. Existing external rejection,
retained/recreated DB and unchanged principal-generation controls
remain.
- Ownership tests cover excluded raw physical metadata, required
servable views/sequences and fail-closed missing ownership. FK lookup
tests verify shared pointers and scope without fresh enumeration.
- After preserving the upstream merge: full frontend **26.886 s**, all
six `TestIssue29399*` public tests **31.475 s**, and configured
incremental golangci-lint **0 issues**. The byte-identical correction
also passed all six tests under race detection before the merge
(**69.920 s**). Go vet and repository molint completed with exit 0;
existing molint recover diagnostics outside changed code are retained.
No linter suppression/configuration weakening.

Unchanged evidence from the whole-PR review is retained:
planner/compiler and V406 maintenance tests; prepared/cache/active-role
controls; normal BVT comparisons including metadata (ownership/CLONE
125/125, builtin full-then-partial 213/213, cache 37/37, revoked-role
39/39). The inherited target merge separately passed compiler/index
owning packages and two-CN FULLTEXT2/HNSW rebuild integration. Its
initial `TestConnMeasuresDelayedBufferedFlush` timing failure remains
recorded; isolated repetitions and subsequent full frontend passed
without weakening assertions.

### Performance and limitations

Partial source selection adds bounded name maps, uses existing view
planning once and avoids repeated partial source enumeration. It adds no
persistent state, catalog format, principal query per object or new
lock. Current-dependent runtime guards can conservatively omit a
prevalidated candidate; this change does not claim exact prediction of
every dynamic FK skip.

Existing matched public microbenchmark: reader p50 median **1.617 →
1.333 ms (~17.6% lower)**; admin **243.5 → 244.3 µs**, with comparable
controls. These local measurements do not recover the old stale-cache
roughly 80 µs latency or establish production throughput. Authorization
code is unchanged by the latest source-selection correction.

The latest correction's design and final overall review use actual
**gpt-6.1-sol / xhigh**, reconciling the whole-PR evidence with the
changed paths. The source-selection correction's remote CI remains
distinct from the target synchronization below; skipped jobs are not
passes.


### Prior target synchronization and CI

Prior synchronization head: `b190162ef097987a71e9252a49266caaee810451`;
target `main`: `401d153150d9076f84aaaf2a32cdcf880b478395`. Normal merge
parents are the preserved live
`93405cdc0eafd1d2ce15a65d75d5afe2d531b36a` and the new target. This
closes the observed strict-baseline BEHIND condition without rebasing,
force-pushing or changing Ready/base state. Only #29570's two
prepared-DECIMAL SQL/result files change relative to the first parent,
byte-identically to the target; every other tracked file is unchanged.
The existing source selection, ownership, current-grant transaction,
authorization implementation and disclosed performance limits are
preserved.

Fresh monitor-local exact-merge binary build passes. The new upstream
prepared-DECIMAL case passes strict JDBC metadata validation
**213/213**, with named database cleanup zero (macOS ARM64 / Go 1.26.4 /
Java 20). Independent read-only mechanical merge review approves and
whitespace/worktree checks are clean. The prior `93405cdc`
frontend/public/race proof above is external local unchanged-Go
evidence, not a fresh whole-suite execution or current-head remote CI
pass. No source-branch cache-certificate or internal-executor fix is
blindly copied to main.

XuPeng-SH approved `93405cdc` at 14:21 UTC after whole-PR follow-up;
this is an actual submitted review, not the local mechanical approval.
Prior-head Connector/J run
[37015828472](https://github.com/matrixorigin/matrixone/actions/runs/37015828472)
attempt 1 fails during ONNX Runtime download (HTTP 504), before the
server/test. Exactly one failed-job rerun request was accepted. Attempt
2 /
[110870725085](https://github.com/matrixorigin/matrixone/actions/runs/37015828472/job/110870725085)
downloads the dependency and actually passes pool-reset tests for all
four Connector/J versions at 14:07:46 UTC. That success belongs to
`93405cdc`, not this new merge head. No healthy jobs or whole ALL CI run
were rerun/cancelled and no build/workflow/tester/business workaround
was added.

That head's Connector/J
[37023553819](https://github.com/matrixorigin/matrixone/actions/runs/37023553819)
actually succeeds at 15:01:50 UTC; ALL CI remains unfinished when it is
superseded by the next target merge. This is historical evidence, not a
result for the current head.

### Prior target synchronization and validation

Prior head: `380bbce20601196b9c9b09ea48089bb666985857`; target `main`:
`5a09e1ffbf40a59f50c55fe89e6f0c23eba143a3`. After main merges #29567,
strict protection marks the previous head BEHIND again. A normal merge
preserves parents `b190162ef097987a71e9252a49266caaee810451` and the new
target, without conflicts, manual overwrites, rebasing or force push.
Its 15-file delta matches the upstream commit exactly, including modes
and blob IDs. All existing PR changes from the approved implementation
remain intact. Inherited prepared runtime-plan statistics admission does
not bypass schema invalidation or text/binary EXECUTE reauthorization;
shared restore source selection, ownership preflight and current-grant
transactions are unchanged.

Fresh monitor-local exact-head proof (macOS ARM64 / Go 1.26.4):

- Full frontend/plan/hashmap **-race passes: 34.982 s / 36.546 s / 3.344
s**.
- All six authenticated `TestIssue29399*` tests pass (**29.908 s**),
including the eight optimistic-SI privilege-removal arms, snapshot/PITR
ownership and source-selection boundaries, principal pins and
invalid-grant rollback. Upstream reordered-join semantics and prepared
workspace visibility tests pass (**13.031 s**), including
integer/bigint/string/composite unique controls. The test-only atomic
output `[no statements]` is not production coverage.
- Exact binary build and version `380bbce206` pass. Configured
incremental lint across all five upstream changed package roots reports
**0 issues**. Worktree and whitespace checks are clean. Independent
read-only merge/integration review approves; it checks inheritance and
interaction, not the general upstream statistics policy.

A fresh OPEN/Ready/head guard was awaited and read before the accepted
normal push. Latest current-head CI is newly triggered and not complete;
no BVT, full coverage, required-context or merge-gate pass is claimed.
Prior-head successes are not substituted for current-head results. No
workflow, tester or source cache-certificate/internal-executor framework
is copied into main. Existing performance limitations and the separate
constant-view issue #29572 remain unchanged.

### Current target synchronization and validation

Current head: `ae4460f455bafa98a5beb301906adbd0abc522b6`; target `main`:
`9078a8bd87af49ea06f52e09d64e7740122aea61` (#29573 vector
UnionOne/marshal). Strict-baseline BEHIND is addressed by a normal merge
with first parent `380bbce20601196b9c9b09ea48089bb666985857`, without
conflict, manual overwrite, rebasing or force push. The four-file delta
is byte/mode-identical to the upstream delta; the original 43-file PR
patch remains identical against the new target. Restore source
selection, ownership/current-grant transactions, principal-generation
restriction, protocol/DAG and authorization implementation are
preserved.

Independent exact-merge local proof (macOS ARM64 / Go 1.26.4, verified
inherited native inputs and absolute CGo paths):

- Complete vector/batch/mergeutil **-race passes (6.392 s / 3.393 s /
3.712 s)**; complete frontend/plan **-race passes (34.427 s / 34.374
s)**.
- All six authenticated `TestIssue29399*` plus authenticated fixture
configuration pass **under race (65.232 s)**, including all eight
optimistic-SI privilege-removal arms. Another 28 objectio/hashbuild
marshal, recovery/area and runtime-filter consumer tests pass **under
race (2.722 s / 2.297 s)**.
- Configured incremental lint in the two upstream changed package roots:
**0 issues**. Exact-head binary build/version, gofmt, whitespace and
worktree checks pass. Native/packaged binary artifacts are preserved;
the exact-head validation binary is separate.
- Independent read-only integration/mechanical review **APPROVE**,
covering ownership/aliasing, NULL reuse, errors, marshal and
restore/clone consumers. This is local correctness evidence for this
merge, not a GitHub approval, full BVT/BigData, Linux/GPU proof or
performance comparison. Test-only atomic `[no statements]` is not
production coverage.

A fresh OPEN/Ready/head/body guard is awaited and read before the
accepted normal push. The source-only SQL-task principal follow-up is
not blindly copied into main's unchanged adapter/authorization path.
Existing performance limitations and separate constant-view issue #29572
remain.

Current exact-head [ALL CI run
37034311275](https://github.com/matrixorigin/matrixone/actions/runs/37034311275),
attempt 1, completes **SUCCESS** at **2026-10-02 17:51:19 UTC**. Actual
Ubuntu UT, arm64 SCA, shared build, UT Coverage, PROXY/PESSIMISTIC
multi-CN BVT, Coverage and CI Required all succeed. The [CI Required
log](https://github.com/matrixorigin/matrixone/actions/runs/37034311275/job/110959138144)
confirms `full` scope, generation `37034311275-1`, all five dependency
groups successful and `coverage_ready=true` / `coverage_status=passed`.
The [Coverage
log](https://github.com/matrixorigin/matrixone/actions/runs/37034311275/job/110952754024)
selects UT and both complementary BVT profiles from that same generation
and publishes the merged result. Current-head Connector/J succeeds;
Iceberg is **SKIPPED**, not a functional test pass. No failed-job or
whole-run rerun/cancellation is performed this round.

The PR remains **OPEN / Ready / MERGEABLE / BLOCKED / APPROVED**. The
retained approval was submitted on the earlier `93405cdc`
implementation; it is not a new review of this target-merge head. All
four discussion threads remain unresolved, with no new human findings.
Completed CI Required and test jobs do not establish that every
review/protection requirement has been satisfied; no
Ready/base/approval/merge or protection policy is changed.

---------

Co-authored-by: XuPeng-SH <[email protected]>

This branch was previously deployed

1 inactive deployment
ci — ce7f37c2 Deployed Oct 2, 2026 by XuPeng-SH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/enhancement kind/test-ci size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants