Skip to content

fix(sql): preserve complete join expression ownership - #29919

Merged
XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
XuPeng-SH:fix/29897-join-expression-ownership
Oct 12, 2026
Merged

XuPeng-SH merged 3 commits into
matrixorigin:mainfrom
XuPeng-SH:fix/29897-join-expression-ownership

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Oct 11, 2026 •

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:

Fixes #29897

What this PR does / why we need it:

The released correlated permission UPDATE panics because decorrelation exports a literal CAST as an inner projection column, making an outer CASE reference both JOIN inputs. HasColExpr treats a conflicting child's -1 as column-free, admits the mixed expression as a hash key, and one-input evaluation reads the wrong vector. On current main the same artificial column also prevents proving the outer correlation key for correlated LIMIT.

Keep genuinely foldable function expressions inline during PROJECT/AGG predicate pullup through the existing function.IsConstant policy. Genuine inner and volatile expressions retain their exports. Complete JOIN-side analysis and one post-remap equality predicate serve admission/orientation, compiler key/residual splitting, shuffle/MARK and row-count-only eligibility. Mixed, unknown and correlated operands use the existing two-input residual/loop evaluation. Remove the compiler's first-column walker and redundant MARK ownership walker; retain pre-remap policies and NULL rules. Ordinary computed one-side hash keys remain eligible.

The existing remote privilege-cache regression assumed CN0's REVOKE completion meant CN1 had already applied it. Its default snapshot policy permits an older locally applied snapshot, so a warm grant can remain valid until replay advances. Reuse public mo_ctl('cn','synccommit','') after catalog mutation boundaries before observing authorization. Keep separate warm text, SQL-prepared and binary sessions, old data transactions, nested authorization and catalog-fault assertions. Batch consecutive replacement/bootstrap mutations. Subtest-owned connections and restoration registered before revoke-and-sync handle partial failure; failed scenarios stop subsequent dependent cases.

The CI repair changes only this test; production snapshot/cache consistency retains its documented contract. The original JOIN correction runs during preparation and adds no per-row validation. No throughput improvement is claimed.

Current validation

Rebased onto pinned main a5b7d1e75fde337400d4f0c71932a0ebbaff0b30. Go 1.27.1, Linux amd64, matching native source/artifact provenance and repository CGo wrapper. UT uses CI's -vet=off with independent static checks.

  • Complete owning packages PASS normally: planner 24.634s, compiler 9.154s, hashjoin 99.508s, loopjoin 0.088s. Same complete packages PASS under race: 57.892s / 10.882s / 251.164s / 1.547s.
  • Complete authenticated two-CN TestPrivilegeCacheTracksRemoteCatalogChanges PASS normally (79.128s) and under race (31.212s), retaining all existing protocol, nested/old-transaction, role, replacement, grant-option and fault cases.
  • Deterministic public white-box/black-box control PASS (43.102s): hold CN1's normal logtail dispatch after a successful receive; verify its frozen applied timestamp is before the writer commit; committed remote REVOKE still allows the exact EXPLAIN ANALYZE query. Observe existing SyncCommit actually enqueue CN1's timestamp waiter, release dispatch, then the same warm session receives the privilege error. Diagnostic overlays/gates and their asynchronous caller cleanup are outside the PR.
  • Incremental go vet, configured golangci-lint and molint cover planner/compiler/hashjoin/loopjoin/issues including the uncommitted test amendment: PASS, 0 introduced lint issues. All 11 molint advisories match expressions on pinned main. Formatting/diff checks PASS.
  • Independent gpt-6.1-sol/xhigh design: APPROVE, session 01a12d4b-e56c-7163-a64f-01b3d9e931fc. Complete overall review and terminal evidence reconciliation: APPROVE, no unresolved material blocker, covering all 14 final file hashes, in session 01a12d5d-e3e9-7043-9a4e-b5902f3829e1.

Normal hashjoin's initial four-minute aggregate guard expired while spill cases were progressing; the serial full-package rerun with the original twelve-minute guard passed. Interrupted Go tool/cache/linker runs and a diagnostic startup with an overlong Unix socket path are not counted as passes or attributed to this PR.

Earlier public evidence and remote CI

Original public UPDATE with content-type/permission metadata and foreign keys produced exact (1,'change',101), (2,'add',102), (3,'publish',103) and retained per-key ROW_NUMBER partitioning. Extended subquery/correlated-limit.sql covered idempotence, NULL/no match, mixed CASE with/without a valid hash key, unmatched LEFT rows, empty right input, correlated aggregate, residual error and subsequent successful SQL: normal mo-tester comparison 55/55 twice, teardown verified. These are earlier runs; their SQL/golden inputs remain unchanged after rebase.

Original-head CI at 7361b0889e (run 38153917185) passed build, ARM64 SCA, UT Coverage, Proxy/pessimistic multi-CN BVT and coverage aggregation. UT failed only the remote-revoke assertion corrected here; the size-label action independently failed its GitHub API TLS connection. New-head CI remains pending after push.

Production increment: +64/-114 (net -50); Go tests +196/-38; BVT SQL +65/result +89; documentation 0. The CI amendment is +58/-36 in the existing permission test, with no new fixture or production mechanism.

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

本轮修复、rebase 和最终评审(commit bf11829efc778c19cb778e4c3a9c2b7fd69d7c81):

  • 确定性对照确认 CI 根因:CN0 的 REVOKE 已提交,但默认普通快照允许 CN1 尚未应用该提交。原测试立即断言拒绝,缺少可见性屏障。冻结 CN1 logtail 后可复现同一 EXPLAIN ANALYZE 仍成功;实际观察到已有 SyncCommit 的目标时间戳等待;释放后同步完成,同一热会话收到权限错误。
  • 修复复用现有 mo_ctl('cn','synccommit',''),覆盖远端目录变更后的观察边界,并保留独立热缓存、旧数据事务、各协议/nested/角色/grant-option/目录故障断言。恢复在撤权前注册,使用独立有界上下文;连接由所属子测试清理,失败后停止后续依赖场景。诊断 overlay 不进入 PR。
  • 已 rebase 到 main a5b7d1e75fde337400d4f0c71932a0ebbaff0b30。完整权限测试 normal/race PASS(79.128s/31.212s);planner/compiler/hashjoin/loopjoin 整包 normal/race 全部 PASS。5 包增量 vet、配置 lint、molint PASS,0 新增诊断,11 条提示均对照 base 确认。正常 spill 检查的初始整包上限过短,按原 12 分钟上限串行补跑完整 hashjoin PASS(99.508s)。
  • gpt-6.1-sol/xhigh 设计和最终整体评审通过,最终核对全部 14 文件:无未解决实质阻断项。最终评审 session 01a12d5d-e3e9-7043-9a4e-b5902f3829e1。CI 修复仅改现有测试,生产运行路径无新增开销;原 JOIN 生产改动净减 50 行。

没有未处理的 inline review comments。原始 correlated-limit 55/55 两轮与原 head 的多 CN BVT 是历史验证;新 head 远端 CI 尚待结果。原 size-label 的 TLS 网络失败将随新提交重新执行。

@XuPeng-SH

XuPeng-SH commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot review · mo-bot-local · done

Commit: bf11829efc778c19cb778e4c3a9c2b7fd69d7c81

Assessment: approve

完成全部 14 文件及相关调用链审查,未发现已确认的未解决缺陷。JOIN 输入归属判断统一到既有表达式分析,重复判断已删除;权限测试修复保留了原有安全断言和缓存行为。

Model: gpt-6-astra / xhigh

Session: 01a12d8f-8e48-7622-ad17-b605f08450ce · slot 1 · generation 0

Validation:

  • 核实指定 HEAD、冻结证据和完整 patch 一致,源码保持干净。

  • 追踪常量提升、JOIN 键与残余条件拆分、MARK/shuffle 的 NULL 规则、行数优化,以及 hashjoin/loopjoin 的错误传播和 Reset/Free。

  • 审查全部新增测试与 SQL 结果,包括原始 UPDATE、重复执行、NULL、无匹配、混合输入、空右表、聚合及残余条件失败后的会话可用性。

  • 确认 SyncCommit 使用既有时间戳应用屏障,不直接清空其他会话权限缓存;独立协议会话、旧事务、角色、嵌套授权和目录故障断言仍保留。

  • 当前 HEAD 的冻结 CI:构建、Ubuntu/x86 UT、ARM64 SCA、覆盖率及 proxy/pessimistic 多 CN BVT 均成功。复用作者记录的 planner/compiler/hashjoin/loopjoin 整包 normal/race 和完整权限回归验证。

  • 本轮仅执行范围一致性检查,未运行 native 测试或使用遗留二进制。完整记录:/home/xupeng/.local/state/mo-bot/jobs/87fd1d9fe140527a54deb6a1/attempt-1/review-record.md。

Limitations:

  • 冻结材料没有关联 issue 的独立正文;依据 PR 复现描述、代码和回归契约核对需求。

  • 未独立重跑 native 测试;CI 材料仅提供检查结论,作者诊断 overlay 和历史 BVT 运行未冒充本轮执行。

  • 未测量吞吐变化。新增分析位于规划/编译阶段;混合条件转为正确的残余或循环连接不代表所有工作负载性能不变。

  • 跳过的 Darwin、升级和 optimistic 作业不构成验证;ARM 静态分析不等同于 ARM 运行时验证。

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

mo-bot review · mo-bot-local · review

Commit: bf11829efc778c19cb778e4c3a9c2b7fd69d7c81

Assessment: approve

完成全部 14 文件及相关调用链审查,未发现已确认的未解决缺陷。JOIN 输入归属判断统一到既有表达式分析,重复判断已删除;权限测试修复保留了原有安全断言和缓存行为。

Model: gpt-6-astra / xhigh

Session: 01a12d8f-8e48-7622-ad17-b605f08450ce · slot 1 · generation 0

Validation:

  • 核实指定 HEAD、冻结证据和完整 patch 一致,源码保持干净。

  • 追踪常量提升、JOIN 键与残余条件拆分、MARK/shuffle 的 NULL 规则、行数优化,以及 hashjoin/loopjoin 的错误传播和 Reset/Free。

  • 审查全部新增测试与 SQL 结果,包括原始 UPDATE、重复执行、NULL、无匹配、混合输入、空右表、聚合及残余条件失败后的会话可用性。

  • 确认 SyncCommit 使用既有时间戳应用屏障,不直接清空其他会话权限缓存;独立协议会话、旧事务、角色、嵌套授权和目录故障断言仍保留。

  • 当前 HEAD 的冻结 CI:构建、Ubuntu/x86 UT、ARM64 SCA、覆盖率及 proxy/pessimistic 多 CN BVT 均成功。复用作者记录的 planner/compiler/hashjoin/loopjoin 整包 normal/race 和完整权限回归验证。

  • 本轮仅执行范围一致性检查,未运行 native 测试或使用遗留二进制。完整记录:/home/xupeng/.local/state/mo-bot/jobs/87fd1d9fe140527a54deb6a1/attempt-1/review-record.md。

Limitations:

  • 冻结材料没有关联 issue 的独立正文;依据 PR 复现描述、代码和回归契约核对需求。

  • 未独立重跑 native 测试;CI 材料仅提供检查结论,作者诊断 overlay 和历史 BVT 运行未冒充本轮执行。

  • 未测量吞吐变化。新增分析位于规划/编译阶段;混合条件转为正确的残余或循环连接不代表所有工作负载性能不变。

  • 跳过的 Darwin、升级和 optimistic 作业不构成验证;ARM 静态分析不等同于 ARM 运行时验证。

@aunjgr aunjgr 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 bf11829 against merge-base a5b7d1e. No blocking finding.

Complete operand ownership, rather than the first column or a conflicting subtree mistaken for a constant, now governs post-remap hash-key admission. Mixed/unknown/correlated forms remain residuals, genuine one-side computed keys remain eligible, and orientation agrees across compiler, shuffle/MARK and row-count-only consumers. Foldable scalar pullup uses the existing constant policy; volatile and genuine inner expressions still retain their exports.

The permission-test fence is correctly limited to test visibility: it synchronizes remote catalog application before asserting authorization, without clearing the warm session caches or changing production consistency. Partial-failure restoration and subtest connection cleanup remain owned.

Reviewed the complete changed hunks and reused the reported complete normal/race package checks, authenticated two-CN tests, deterministic visibility control and public SQL/BVT evidence. Current-head CI is green. No local native suite or throughput benchmark was rerun by me.

@XuPeng-SH

XuPeng-SH commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor Author

mo-bot work · mo-bot-local · done

Commit: bf11829efc778c19cb778e4c3a9c2b7fd69d7c81

Final gate confirms the noop. The sole trigger is Qodo’s account notice; no source repair or remote action is warranted.

This branch had an error being deployed

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

Labels

kind/bug Something isn't working kind/enhancement kind/refactor Code refactor 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.

[Bug]: Correlated UPDATE with string CASE and permission JOIN panics in strCaseFn (v4.2.5)

3 participants