Skip to content

[Bug]: Jinpan AP Window queries repeatedly exceed 7200-second execution limit #28109

Closed

Description

@Ariznawlll

Description

Multiple independent Window-function query shapes in the Jinpan AP workload reach the configured 7200-second limit on the dev multi-CN environment. This issue intentionally excludes q1004_adv_window_frame_running, which is already tracked in #26066.

Environment

Reproduction

Run the Advanced Join phase against the jinpan_001 dataset. The following Window-function cases each ran for the full 7200 seconds and were then terminated by the runner:

  • q1045_adv_window_frame_running
  • q1127_adv_window_frame_running
  • q1143_adv_inventory_ratio_win
  • q1225_adv_inventory_ratio_win
  • q1250_adv_window_frame_running
  • q1348_adv_inventory_ratio_win
  • q1430_adv_inventory_ratio_win
  • q1824_adv_window_frame_running
  • q1922_adv_inventory_ratio_win
  • q1947_adv_window_frame_running

Actual behavior

Each listed query exceeded two hours of execution time. The runner emitted:

Execution timeout after 7200s; skips remaining SQL in the current file and continues with the next file...

The completed Advanced Join shards contain repeated occurrences of this signature. No CN OOMKilled, exit 137, Go panic, or fatal error was found in the corresponding investigation windows.

Expected behavior

Window queries over this AP dataset should complete within a bounded, operationally acceptable duration. A broad set of Window query shapes repeatedly consuming the entire two-hour test budget is a performance defect, even though the runner can cancel and continue.

Scope and related issues

Evidence

Regression coverage

After a fix, add a bounded Jinpan/big-data performance regression for representative window_frame_running and inventory_ratio_win cases, with recorded execution duration and no two-hour timeout.

Activity

  1. added
    kind/bug
    on Sep 4, 2026
  2. added
    severity/s0
    and removed on Sep 4, 2026
  3. aptend commented on Sep 7, 2026

    @aptend
    Contributor

    Latest main code-path update (2026-09-07)

    Reviewed against main@bcd5ed833b5400fe95f322e4028adb2bde3de0a4. The reported run used the diverged 4.2 dev build 4f62825d3; current main contains Window changes that were absent from that execution path.

    Relevant merged changes:

    The ten reported cases split into two repeated SQL shapes:

    1. q1045/q1127/q1250/q1824/q1947 ... window_frame_running

      These use cumulative SUM plus ROWS 2 PRECEDING ... CURRENT ROW AVG. Both frames match current-main fast paths. Aggregate frame work changes from repeated-prefix/window refill toward O(N); sorting and repartitioning remain. These cases should be materially different from the old dev run.

    2. q1143/q1225/q1348/q1430/q1922 ... inventory_ratio_win

      These use SUM(...) OVER (PARTITION BY werks) plus RANK. RANK is covered by the newer direct path, but the full-partition SUM is not. It still reaches the generic evaluator, which refills the complete partition for every requested output row; full consumption remains O(sum(partition_size^2)). A full-partition aggregate fast path is still needed.

    This is static code-path evidence. Before closing or splitting the issue, replay one representative of each shape on the same jinpan_001 data with latest main and record EXPLAIN ANALYZE, elapsed time, and profile. The running-ROWS representative should no longer be dominated by repeated aggregate Fill; the inventory-ratio representative remains the expected unresolved control.

  4. added theissue type on Sep 23, 2026
  5. added this to the MO-202609 milestone on Sep 23, 2026
  6. assigned and unassigned on Oct 26, 2026
  7. Ariznawlll commented on Oct 28, 2026

    @Ariznawlll
    CollaboratorAuthor

    结论

    q1143、q1225 本轮均在 1800 秒超时,测试不通过。 累计 ROWS 优化有实际生效证据,但普通整分区 SUM 仍走重复 Fill 的泛型路径,未被现有快速路径覆盖。已转回 @aptend。

    关键证据

    原始 SQL 2026-10-27 执行窗口(UTC) 结果
    q1143 / j_batch_008.sql 14:49:44–15:19:44 1800 秒超时
    q1225 / j_batch_012.sql 16:15:32–16:45:32 1800 秒超时
    • 两条实际热点均为 Window -> processAggregateFuncRange -> sumAvgDecExec.Fill -> Decimal256.Add256。q1143 协调 CN nightly-regression-dis-tp-cn-f2g85,15:00–15:05 UTC 的 Window 子树占 88.67%,末段仍为 88.51%;q1225 的 nightly-regression-dis-tp-cn-vtcl4,16:25–16:30 占 91.88%,末段仍为 91.79%。占比为对应 CN 采样窗口内的 CPU 比例。
    • 核心 SUM(...) OVER (PARTITION BY werks) 是普通整分区 SUM,不符合累计 ROWS、有限滑动 ROWS/RANGE 的快速路径条件。当前实现对每个输出行重新 Fill 完整分区;分批输出及 LIMIT 500/2000 没有消除重复聚合。
    • 同 issue 的 running ROWS 对照 q1045/q1127/q1250 分别 312.534 / 311.132 / 312.326 秒完成;q1045 profile 直接出现 processCumulativeAggregateFuncRange,证明累计优化路径实际执行。不同 SQL 不作为严格 A/B 加速比。
    • 两条超时后主 statement 分别约 0.213 / 0.216 秒返回 context canceled 并回滚;不等于全部远端资源已同步清理。Pyroscope:process_cpu:cpu:nanoseconds:cpu:nanoseconds,service_name=mo-ap-regression-commit-861a2c4-20261027-40469797177/main,pod 与窗口如上。

    待解决点

    • 为普通整分区 SUM/AVG 补每分区一次聚合、跨输出批复用,并覆盖 DECIMAL、NULL、分批输出和取消回归。
    • 补同规模完整 EXPLAIN / 有界 EXPLAIN ANALYZE;现有 artifact 未找到计划,实际 HASH 选择、节点基数和 DOP 未确认,原环境后续已无可用实例。
    • q1824、q1947、q1348、q1430、q1922 本轮未执行;execution-only 缺少可比 golden,结果正确性待验证。本轮 1800 秒超时不能证明仍超过历史 7200 秒阈值。
  8. Ariznawlll commented on Oct 28, 2026

    @Ariznawlll
    CollaboratorAuthor

    结论

    测试不通过。补充核对原 run 的其余五条超时查询后,q1020、q1061、q1102、q1184、q1266 与此前 q1143、q1225 具有相同的主要瓶颈:普通整分区 DECIMAL SUM 没有按分区计算一次并复用,仍逐输出行重复 Fill 分区。 七条均达到本轮 1800 秒客户端预算,归入本 issue 的同一优化/回归集合;无需将五个包装变体再拆成五个独立原因。q1021 的主要热点是 OR-EXISTS 的 LoopJoin 条件扫描,属于 #28110,机制不同。

    现有证据支持“同一主要瓶颈”,并不排除 UNION、排序、JOIN 放大或物化的附加成本。本结论来自原运行日志、逐条 CPU profile、原 SQL 和指定源码交叉核对,不是新重测通过/失败的结论,也不是完整 EXPLAIN 的替代品。

    关键证据

    运行与版本

    七条原 SQL 的核心相同,差异在包装与 LIMIT

    逐条从固定资产读取 SQL,去掉空白差异后,字段、四表 JOIN/ON、WHERE 的核心 SELECT 完全一致,核心 SHA256:fa1b25b9b6eead857cc0e23d83e9b9ceaf04ac0269e6bb9b16525b0e92418494。q1020 包含相同核心两份,其余各一份。共同查询 dwd_dcp.dwd_s4_ztmm019 z,INNER JOIN dwd_s4_t001w w,LEFT JOIN dwd_s4_makt mk / dwd_s4_mara ma,过滤 z.zsl > 0。关键表达式:

    ROUND(CAST(z.zzqzje AS DECIMAL(23,2)) /
      NULLIF(SUM(CAST(z.zzqzje AS DECIMAL(23,2)))
        OVER (PARTITION BY z.werks), 0), 6) AS werks_share,
    RANK() OVER (PARTITION BY z.werks
      ORDER BY CAST(z.zzqzje AS DECIMAL(23,2)) DESC) AS val_rank

    以下时间均为 2026 年北京时间;每条仅对应原 run 中的一次执行。失败没有有效完成耗时,1800 秒表示实测触发的客户端超时预算。

    原 SQL / 固定资产文件 包装 / LIMIT 实际开始 → 客户端超时 状态
    q1020_adv_inventory_ratio_win / batch001 两支 UNION ALL / 200 10/27 20:07:41 → 20:37:41 1800s timeout
    q1061_adv_inventory_ratio_win / batch004 派生表 tagged / 500 10/27 21:20:03 → 21:50:03 1800s timeout
    q1102_adv_inventory_ratio_win / batch006 双层包装、diversity_35 hint / 1000 10/27 22:07:11 → 22:37:11 1800s timeout
    q1143_adv_inventory_ratio_win / batch008 直接 SELECT / 2000 10/27 22:49:44 → 23:19:44 1800s timeout
    q1184_adv_inventory_ratio_win / batch010 直接 SELECT / 200 10/27 23:32:47 → 10/28 00:02:47 1800s timeout
    q1225_adv_inventory_ratio_win / batch012 派生表 w、WHERE 1=1 / 500 10/28 00:15:32 → 00:45:32 1800s timeout
    q1266_adv_inventory_ratio_win / batch014 单次引用 WITH base / 1000 10/28 00:58:16 → 01:28:16 1800s timeout

    逐条 profile,而非只根据 SQL 形状推测同因

    Pyroscope datasource pyroscope,profile type process_cpu:cpu:nanoseconds:cpu:nanoseconds;selector:

    {service_name="mo-ap-regression-commit-861a2c4-20261027-40469797177/main",
     pod="nightly-regression-dis-tp-cn-<下表后缀>"}
    

    以下是各协调 CN 在指定窗口的 CPU 样本子树并集,嵌套帧不重复累加;占比不是整条 SQL wall time 比例。

    SQL 协调 CN 后缀 采样北京时间 泛型窗口 CPU秒 / 总CPU秒 泛型窗口占比 Decimal Fill占比
    q1020 vtcl4 10/27 20:20–20:23 337.72 / 367.18 91.98% 79.38%
    q1061 682fq 10/27 21:30–21:33 168.52 / 184.47 91.35% 79.35%
    q1102 f2g85 10/27 22:20–22:23 168.62 / 188.24 89.58% 75.59%
    q1143 f2g85 10/27 23:00–23:05 563.58 / 635.60 88.67% —
    q1184 vtcl4 10/27 23:45–23:48 168.66 / 183.81 91.76% 79.23%
    q1225 vtcl4 10/28 00:25–00:30 281.03 / 305.87 91.88% —
    q1266 682fq 10/28 01:10–01:13 337.02 / 370.74 90.90% 77.15%

    七条均能看到同一热点链:

    Window.Call -> processFuncRange -> processAggregateFuncRange
      -> sumAvgDecExec.Fill -> decimalStateAdd / Decimal256.Add256
    

    q1143/q1225 的末段采样仍分别有 88.51% / 91.79% 落在该窗口聚合子树。新增五条采样窗口没有 LoopJoin.Call CPU 样本;这只说明这些窗口的主要热点不同于 q1021,不能据此断言物理计划完全没有 LoopJoin。

    源码适用范围解释了“包含修复,仍然慢”

    固定版本的 窗口分派及 Fill 循环 显示:累计路径要求符合条件的 ROWS 且结束于 CURRENT ROW,滑动 ROWS/RANGE 各有有限边界等守卫;现有整分区一次计算分支只接受部分 ordered-set 函数,不包含这里的普通 SUM。于是该表达式进入按输出行 j、帧内行 k 重复 Fill 的通用路径。有限输出仍可能产生 K×P 成本;完整消费可达 sum(P²)。

    #26913 的分批懒输出和 HASH 分区选择不等于普通整分区 SUM 的结果复用;本版本 批大小 为 8192,外层 LIMIT 也不保证将首批窗口内部工作裁成该 LIMIT。q1020 的 UNION ALL 修复不能消除分支内部已有的窗口聚合瓶颈;本次没有完整计划,不额外断言分支调度方式或 HASH 是否实际选中。

    运行中的正面对照:同轮 running ROWS 的 q1045 / q1127 / q1250 分别完成于 312534.15 / 311131.94 / 312326.19 ms;q1045 的 CPU profile 直接出现 processCumulativeAggregateFuncRange。这说明累计优化路径确有执行证据,不能简单归因于“修复代码全没生效”;不同 SQL 不构成严格 A/B 加速比。

    超时后的取消响应

    SQL 主 statement_id 客户端超时后至服务端 fail/context canceled
    q1020 01a17d42-531d-79aa-b3a7-b9987c8c2542 约 0.221s
    q1061 01a17d84-93d3-7a85-81e8-033633e9c4e4 约 0.275s
    q1102 01a17daf-bad3-745f-b544-90d3efa4de25 约 0.211s
    q1143 01a17dd6-b01a-7742-b4e9-398de4c11688 约 0.213s
    q1184 01a17dfe-1c5f-7d99-9fa2-03e995b32613 约 0.240s
    q1225 01a17e25-3dc5-761f-bfc1-36b1e1df5aa7 约 0.216s
    q1266 01a17e4c-5f26-7ef0-99bf-4a53c795743a 约 0.362s

    这些主 statement 有界响应取消,本轮没有观察到它们超时后继续长期不退出;这不能证明所有远端 pipeline/资源同步清理完毕。执行慢和取消不响应需要分开判断。

    待解决点

    1. 为普通整分区 SUM/AVG 等适用聚合增加每分区一次计算、跨输出批复用/广播,重点覆盖这里的 DECIMAL;保留 NULL、空输入、分区边界、分批输出及取消语义。七种包装应作为同因回归集合,不能只验证其中一条。
    2. 在同版本、同规模数据环境补取原 SQL 的完整 EXPLAIN VERBOSE、涉及表的 table_stats(行数/NDV/偏斜等),确认分区规模、JOIN 放大、排序与完整节点基数。当前只有实际算子热点与源码守卫证据,尚不能量化全部次要成本。
    3. 目标原 case 中 q1824、q1947、q1348、q1430、q1922 本轮未执行;不能外推其状态。原 run 的 1800 秒预算也未验证历史 issue 的 7200 秒阈值。无有效 golden,已完成对照仅为 execution-only,未验收完整结果正确性。
    4. 更正恢复进度(2026-10-28): 恢复 run40624634916 的 attempt 1 曾因容量阻塞取消,但 attempt 2 已于北京时间 12:43 完成部署与三阶段数据加载;该 run 输入为 load,focused query job 为 skipped。此前将 attempt 1 当作最终状态的描述有误。现已接续 定向 query run40635601332,复用该环境,仅采集 plan/table_stats 并重放 q1021、q1143、q1225。新 query 尚无结果,上述七条同因分析仍仅依据原 run40469797177;不把加载成功计为问题 SQL 通过。

    定向任务进度补充:首个 focused run40635348515 的 CN 完整 VCS SHA、Pod Ready、Proxy 三次探针均通过,但在导入 runner 的 Python cryptography/CFFI 依赖时失败,尚未执行 plan/业务 SQL。已仅修复测试客户端依赖隔离后复用同环境触发上述 run40635601332;产品与资产版本未变,最终 SQL 状态以该 run 的实际 case 证据为准。

  9. Ariznawlll commented on Oct 28, 2026

    @Ariznawlll
    CollaboratorAuthor

    结论

    测试不通过。本轮定向重测已结束,q1143、q1225原SQL均再次1800秒超时,q1225不再是结果未决。 两条在同一协调CN、相同关键统计估计下仍走通用整分区SUM,CPU热点分别为 92.18% / 92.25%;同session重放前计划与初始计划逐行一致,主要瓶颈仍是普通整分区DECIMAL SUM的重复Fill。两条取消后的客户端连接级退出检查均通过。

    关键证据

    本轮 focused run40635601332 / job122641727266 的 attempt1 已结束:重放步骤真实失败,job于北京时间 2026-10-28 14:34:55 收尾。失败原因是目标原SQL超时,不是plan/table_stats或客户端依赖失败。复用原namespace mo-ap-regression-commit-861a2c4-20261028-40624634916,test_phase=focused, skip_load=true,没有重建或重新load。

    • 产品官方main:861a2c4cb68961d8b6b01f18e0aa6ac52a3a505f;三个CN实际Go vcs.revision均完整匹配,full_sha_verified=true。旧run运行二进制核验限制不追溯改变。
    • 控制:05c69be7886efa6efb5136c395aa40b7dc5e7eb3;原SQL资产:3b53e658b0029b4f5c6615017fb48419b7743be8。
    • 三条SQL的初始诊断、同session重放前EXPLAIN/stats均完成;9/9 Ready及所有gate、Proxy三次SELECT1均通过。
    • 最终证据artifact:jinpan-focused-plan-stats-40635601332,ID 12797242206,约2.51MiB;包含 runtime.json、execution/summary.json、每条 original.sql、plan.jsonl、各表 *.stats.jsonl、result.status.json 和summary。以下精确耗时来自实际case文件,不是workflow步骤总耗时。
    SQL 实际开始 → 客户端超时(北京时间10/28) statement_elapsed_ms 状态 connection_id 退出确认
    q1143 13:34:02.691645 → 14:04:02.691962 1800000.28 timeout / StatementDeadlineExpired 3922 client_query_exit_confirmed=true
    q1225 14:04:04.764764 → 14:34:04.765104 1800000.31 timeout / StatementDeadlineExpired 4885 client_query_exit_confirmed=true

    原SQL和实际重算SHA256:

    同session计划已对齐,初始统计差异不是这两条分别超时的必要条件

    两条执行session都落在CN nightly-regression-dis-tp-cn-s86d5(node 34616636-3462-3639-6336-633131353262)。session分别为 01a18100-49c8-7568-8dac-04aa74162a47、01a1811b-caf3-7716-a493-f69623e31296。各自完整EXPLAIN与初始计划逐行完全相同(40/41行):

    Project LIMIT2000 / LIMIT500
      Window[10] RANK
        Partition[9] werks
          Window[8] SUM(CAST(zzqzje AS DECIMAL128(23,2))) PARTITION BY werks
            Partition[7] werks
              LEFT JOIN mara(matnr), shuffle REUSE
                LEFT JOIN makt(matnr), shuffle range(z.matnr)
                  INNER JOIN t001w(werks)
                    Scan ztmm019 WHERE zsl>0
    
    表(dwd_dcp前缀) 同session table_cnt(两条相同) 同session关键NDV(两条相同)
    dwd_s4_ztmm019 11795301 werks=64;matnr≈101119.39
    dwd_s4_t001w 136 werks≈134.64
    dwd_s4_makt 836764 matnr≈529344.38
    dwd_s4_mara 836764 matnr≈807662.67
    • 初始不同CN/session曾看到makt.matnr NDV≈828396.36与529344.38;但真正执行前两条都看到529344.38,且仍均超时。因此不能把初始CN间NDV差异当作两条失败的充分解释;也不排除其他统计准确性问题。
    • sampling_ratio均1.0,关键字段null_cnt均0;源zsl/zzqzje为DECIMAL64,SUM显式DECIMAL128,表达式另有DECIMAL256。NDV仍是估计,源码存在table_cnt×0.99截断,sampling_ratio1不等于精确COUNT DISTINCT。
    • Window与JOIN后outcnt仍估为11795301,LIMIT在最外层;降低LIMIT没有改变主要结构。SUM是无ORDER BY的普通整分区窗口,不是预聚合一次后回填。
    • 原始统计11795301÷64约18.43万行/werks,只是平均量级,不是过滤JOIN后实测大小或倾斜证明。zsl>0计划选择率1但零值比例未知;makt多mandt/spras且仅按matnr连接有放大风险,实际倍数未计数。不擅自补过滤改变SQL语义。

    本次真实CPU profile确认了通用聚合路径

    Pyroscope datasource pyroscope;profile type process_cpu:cpu:nanoseconds:cpu:nanoseconds;先确认ProfileTypes/Series有数据,selector:

    {service_name="mo-ap-regression-commit-861a2c4-20261028-40624634916/main",
     pod="nightly-regression-dis-tp-cn-s86d5"}
    

    百分比为该CN对应窗口的CPU样本子树并集,嵌套帧不重复累加,不是整条SQL墙钟时间占比。

    SQL 采样北京时间 / UTC generic聚合CPU秒 / 总CPU秒 generic聚合占比 Decimal Fill占比
    q1143 13:45–13:48 / 05:45–05:48 168.48 / 182.78 92.18% 79.64%
    q1225 14:15–14:18 / 06:15–06:18 168.20 / 182.34 92.25% 80.28%
    Order.Call -> Projection.Call -> Window.Call
      -> processFuncRange -> processAggregateFuncRange -> sumAvgDecExec.Fill
    

    两条实际仍在此路径;旧run窗口主热点为88.67%/91.88%,新旧主机制一致,不当作严格A/B加速比。本版 window分派/Fill循环 的普通整分区SUM不属于已覆盖的累计/有限滑动快路径。本次采样没有LoopJoin CPU样本,不等于计划中完全无此算子。

    取消和退出确认已补齐

    SQL 主statement_id 服务端fail/context canceled(北京时间) 相对客户端finished_at
    q1143 01a18100-4bc4-7dab-a41f-1aef2b8d6a03 14:04:02.960084 +268.122ms
    q1225 01a1811b-cb1d-73dd-801e-4e147cf550cc 14:34:05.028128 +263.024ms

    Loki为精确namespace窗口UTC06:02–06:04附近、06:33–06:36。客户端超时关闭自有连接,随后只读SHOW FULL PROCESSLIST检查对应conn_id;两条均 client_query_exit_confirmed=true, abort_remaining=false,按脚本语义连接已消失或Sleep,没有KILL。本轮未见这两个主statement长期不响应取消;这不证明所有远端pipeline/资源同步清理完毕。timeout rows=0不是成功空结果。

    q1143 同session重放前完整 EXPLAIN VERBOSE(与初始计划逐行一致)
    Project[11] (cost=11795301.00 outcnt=2000.00 selectivity=0.0002 dop=0 blockNum=1447 rowsize=100.00)
      Output: z.werks, z.matnr, z.zsl, z.zzqzje, w.name1, mk.maktx, round((cast(cast(z.zzqzje AS DECIMAL128(23, 2)) AS DECIMAL256) / CASE WHEN (SUM(cast(z.zzqzje as decimal(23, 2))) over (partition by z.werks range unbounded preceding) = cast(0 AS DECIMAL256)) THEN (null) ELSE SUM(cast(z.zzqzje as decimal(23, 2))) over (partition by z.werks range unbounded preceding) END), 6), RANK() over (partition by z.werks order by cast(z.zzqzje as decimal(23, 2)) desc range unbounded preceding)
      Limit: 2000
      ->  Window[10] (cost=11795301.00 outcnt=11795301.00 selectivity=1.0000 dop=0 blockNum=1447 rowsize=100.00)
            Output: z.matnr, z.werks, z.zsl, z.zzqzje, w.name1, mk.maktx, SUM(cast(z.zzqzje as decimal(23, 2))) over (partition by z.werks range unbounded preceding), RANK() over (partition by z.werks order by cast(z.zzqzje as decimal(23, 2)) desc range unbounded preceding)
            Window Function: rank(); Partition By: z.werks; Order By: cast(z.zzqzje AS DECIMAL128(23, 2))
            ->  Partition[9] (cost=11795301.00 outcnt=11795301.00 selectivity=1.0000 dop=0 blockNum=1447 rowsize=100.00)
                  Output: z.matnr, z.werks, z.zsl, z.zzqzje, w.name1, mk.maktx, SUM(cast(z.zzqzje as decimal(23, 2))) over (partition by z.werks range unbounded preceding)
                  Sort Key: z.werks INTERNAL
                  ->  Window[8] (cost=11795301.00 outcnt=11795301.00 selectivity=1.0000 dop=0 blockNum=1447 rowsize=100.00)
                        Output: z.matnr, z.werks, z.zsl, z.zzqzje, w.name1, mk.maktx, SUM(cast(z.zzqzje as decimal(23, 2))) over (partition by z.werks range unbounded preceding)
                        Window Function: sum(cast(z.zzqzje AS DECIMAL128(23, 2))); Partition By: z.werks
                        ->  Partition[7] (cost=11795301.00 outcnt=11795301.00 selectivity=1.0000 dop=0 blockNum=1447 rowsize=100.00)
                              Output: z.matnr, z.werks, z.zsl, z.zzqzje, w.name1, mk.maktx
                              Sort Key: z.werks INTERNAL
                              ->  Join[6] (cost=13468965.00 outcnt=11795301.00 selectivity=1.0000 dop=0 blockNum=1447 hashmapSize=836764.00 rowsize=100.00)
                                    Output: z.matnr, z.werks, z.zsl, z.zzqzje, w.name1, mk.maktx
                                    Join Type: LEFT
                                    Join Cond: (z.matnr = ma.matnr) shuffle: REUSE
                                    ->  Join[4] (cost=12632201.00 outcnt=11795301.00 selectivity=1.0000 dop=0 blockNum=1447 hashmapSize=836764.00 rowsize=100.00)
                                          Output: z.matnr, z.werks, z.zsl, z.zzqzje, w.name1, mk.maktx
                                          Join Type: LEFT
                                          Join Cond: (z.matnr = mk.matnr) shuffle: range(z.matnr)
                                          ->  Join[2] (cost=11795437.00 outcnt=11795301.00 selectivity=1.0000 dop=0 blockNum=1447 hashmapSize=136.00 rowsize=100.00)
                                                Output: z.matnr, z.werks, z.zsl, z.zzqzje, w.name1
                                                Join Type: INNER
                                                Join Cond: (z.werks = w.werks)
                                                ->  Table Scan[0] on dwd_dcp.dwd_s4_ztmm019 (cost=11795301.00 outcnt=11795301.00 selectivity=1.0000 dop=0 blockNum=1447 rowsize=692.17)
                                                      Output: z.matnr, z.werks, z.zsl, z.zzqzje
                                                      Table: 'dwd_s4_ztmm019' (0:'matnr', 1:'werks', 2:'zsl', 3:'zzqzje') shuffle: hash(__mo_fake_pk_col)
                                                      Filter Cond: (z.zsl > 0.000)
                                                ->  Table Scan[1] on dwd_dcp.dwd_s4_t001w (cost=136.00 outcnt=136.00 selectivity=1.0000 dop=0 blockNum=2 rowsize=1644.49)
                                                      Output: w.werks, w.name1
                                                      Table: 'dwd_s4_t001w' (0:'werks', 1:'name1') shuffle: hash(__mo_fake_pk_col)
                                          ->  Table Scan[3] on dwd_dcp.dwd_s4_makt (cost=836764.00 outcnt=836764.00 selectivity=1.0000 dop=0 blockNum=104 rowsize=202.53)
                                                Output: mk.matnr, mk.maktx
                                                Table: 'dwd_s4_makt' (0:'matnr', 1:'maktx') shuffle: hash(__mo_fake_pk_col)
                                    ->  Table Scan[5] on dwd_dcp.dwd_s4_mara (cost=836764.00 outcnt=836764.00 selectivity=1.0000 dop=0 blockNum=104 rowsize=6349.44)
                                          Output: ma.matnr
                                          Table: 'dwd_s4_mara' (0:'matnr') shuffle: hash(__mo_fake_pk_col)
    
    q1225 同session重放前完整 EXPLAIN VERBOSE(与初始计划逐行一致)
    Project[11] (cost=11795301.00 outcnt=500.00 selectivity=0.0000 dop=0 blockNum=1447 rowsize=100.00)
      Output: z.werks, z.matnr, z.zsl, z.zzqzje, w.name1, mk.maktx, round((cast(cast(z.zzqzje AS DECIMAL128(23, 2)) AS DECIMAL256) / CASE WHEN (SUM(cast(z.zzqzje as decimal(23, 2))) over (partition by z.werks range unbounded preceding) = cast(0 AS DECIMAL256)) THEN (null) ELSE SUM(cast(z.zzqzje as decimal(23, 2))) over (partition by z.werks range unbounded preceding) END), 6), RANK() over (partition by z.werks order by cast(z.zzqzje as decimal(23, 2)) desc range unbounded preceding)
      Limit: 500
      ->  Window[10] (cost=11795301.00 outcnt=11795301.00 selectivity=1.0000 dop=0 blockNum=1447 rowsize=100.00)
            Output: z.matnr, z.werks, z.zsl, z.zzqzje, w.name1, mk.maktx, SUM(cast(z.zzqzje as decimal(23, 2))) over (partition by z.werks range unbounded preceding), RANK() over (partition by z.werks order by cast(z.zzqzje as decimal(23, 2)) desc range unbounded preceding)
            Window Function: rank(); Partition By: z.werks; Order By: cast(z.zzqzje AS DECIMAL128(23, 2))
            ->  Partition[9] (cost=11795301.00 outcnt=11795301.00 selectivity=1.0000 dop=0 blockNum=1447 rowsize=100.00)
                  Output: z.matnr, z.werks, z.zsl, z.zzqzje, w.name1, mk.maktx, SUM(cast(z.zzqzje as decimal(23, 2))) over (partition by z.werks range unbounded preceding)
                  Sort Key: z.werks INTERNAL
                  ->  Window[8] (cost=11795301.00 outcnt=11795301.00 selectivity=1.0000 dop=0 blockNum=1447 rowsize=100.00)
                        Output: z.matnr, z.werks, z.zsl, z.zzqzje, w.name1, mk.maktx, SUM(cast(z.zzqzje as decimal(23, 2))) over (partition by z.werks range unbounded preceding)
                        Window Function: sum(cast(z.zzqzje AS DECIMAL128(23, 2))); Partition By: z.werks
                        ->  Partition[7] (cost=11795301.00 outcnt=11795301.00 selectivity=1.0000 dop=0 blockNum=1447 rowsize=100.00)
                              Output: z.matnr, z.werks, z.zsl, z.zzqzje, w.name1, mk.maktx
                              Sort Key: z.werks INTERNAL
                              ->  Join[6] (cost=13468965.00 outcnt=11795301.00 selectivity=1.0000 dop=0 blockNum=1447 hashmapSize=836764.00 rowsize=100.00)
                                    Output: z.matnr, z.werks, z.zsl, z.zzqzje, w.name1, mk.maktx
                                    Join Type: LEFT
                                    Join Cond: (z.matnr = ma.matnr) shuffle: REUSE
                                    ->  Join[4] (cost=12632201.00 outcnt=11795301.00 selectivity=1.0000 dop=0 blockNum=1447 hashmapSize=836764.00 rowsize=100.00)
                                          Output: z.matnr, z.werks, z.zsl, z.zzqzje, w.name1, mk.maktx
                                          Join Type: LEFT
                                          Join Cond: (z.matnr = mk.matnr) shuffle: range(z.matnr)
                                          ->  Join[2] (cost=11795437.00 outcnt=11795301.00 selectivity=1.0000 dop=0 blockNum=1447 hashmapSize=136.00 rowsize=100.00)
                                                Output: z.matnr, z.werks, z.zsl, z.zzqzje, w.name1
                                                Join Type: INNER
                                                Join Cond: (z.werks = w.werks)
                                                ->  Table Scan[0] on dwd_dcp.dwd_s4_ztmm019 (cost=11795301.00 outcnt=11795301.00 selectivity=1.0000 dop=0 blockNum=1447 rowsize=692.17)
                                                      Output: z.matnr, z.werks, z.zsl, z.zzqzje
                                                      Table: 'dwd_s4_ztmm019' (0:'matnr', 1:'werks', 2:'zsl', 3:'zzqzje') shuffle: hash(__mo_fake_pk_col)
                                                      Filter Cond: true, (z.zsl > 0.000)
                                                ->  Table Scan[1] on dwd_dcp.dwd_s4_t001w (cost=136.00 outcnt=136.00 selectivity=1.0000 dop=0 blockNum=2 rowsize=1644.49)
                                                      Output: w.werks, w.name1
                                                      Table: 'dwd_s4_t001w' (0:'werks', 1:'name1') shuffle: hash(__mo_fake_pk_col)
                                                      Filter Cond: true
                                          ->  Table Scan[3] on dwd_dcp.dwd_s4_makt (cost=836764.00 outcnt=836764.00 selectivity=1.0000 dop=0 blockNum=104 rowsize=202.53)
                                                Output: mk.matnr, mk.maktx
                                                Table: 'dwd_s4_makt' (0:'matnr', 1:'maktx') shuffle: hash(__mo_fake_pk_col)
                                    ->  Table Scan[5] on dwd_dcp.dwd_s4_mara (cost=836764.00 outcnt=836764.00 selectivity=1.0000 dop=0 blockNum=104 rowsize=6349.44)
                                          Output: ma.matnr
                                          Table: 'dwd_s4_mara' (0:'matnr') shuffle: hash(__mo_fake_pk_col)
    

    待解决点

    • 给普通整分区SUM增加按分区一次计算、跨输出批复用,保留DECIMAL、NULL、分批及取消语义;累计ROWS修复不能替代此验收。
    • 完整EXPLAIN和本次profile已取得,但缺少成功执行的EXPLAIN ANALYZE、实际JOIN放大倍数及分区频数;NDV估计差异继续核实,不refresh/patch统计来掩盖失败。
    • 本次各SQL仅一次重放,其他历史inventory/ROWS原case未选择,不能外推;1800秒未覆盖历史7200秒阈值,无golden不代表完整正确性。三条已结束,不自动重跑、不加大超时、不重新load。
  10. aptend commented on Oct 29, 2026

    @aptend
    Contributor

    Jinpan AP verification update after #31585 (merged as 6d9f7127118de74a6831785ded85563d31b140a6):

    • q1143_adv_inventory_ratio_win completed in 51.63 s and returned 2,000 rows in the optimized replay. It timed out after 1,800 s in the earlier run.
    • The replay used the pre-rebase candidate 2f114269a109aecb622c15be6bfd8814b3f76686; the merged revision has not yet been replayed on Jinpan. Each result is from a single execution on a different commit/environment, so this is not a controlled speedup measurement.
    • The replay verified completion and row count only; no golden-result comparison was performed. Q1225 timed out in the earlier run and was not retested in the optimized replay. The other window queries in this issue were not retested either.

    The issue remains open pending a merged-revision replay, result comparison, and coverage of the other affected query shapes.

  11. assigned and unassigned on Oct 29, 2026
  12. Ariznawlll commented on Nov 3, 2026

    @Ariznawlll
    CollaboratorAuthor

    结论

    测试通过。本次覆盖原 issue 的 10 条窗口 SQL 的大数据执行和本地真实数据抽样正确性对照;全量大数据未逐行与 MySQL 比对。

    关键证据

    • big-data 定向运行 使用产品官方 main@650a4bb3a4666f22ddfd19d60783d17cb8d47675,3 CN / 1 TN,10 条原 SQL 均完成。q1045/q1127/q1250/q1824/q1947 分别耗时 335.60/302.74/335.22/303.01/329.77 秒;q1143/q1225/q1348/q1430/q1922 分别耗时 50.59/49.98/49.29/51.64/50.07 秒。这是各一次执行及行数验证,不是全量 golden。
    • 本地在从 COS 原始 CSV 抽取的字段上比较 MatrixOne main@d61a7206c16b30baa4efc525eb6067c4364035aa(本机二进制,非官方发布镜像)与 MySQL 8.0.45;逐表输入一致,10 条原 SQL 连续 3 轮全行一致。为消除窗口并列顺序不确定性,原始 ACDOCA 样本按窗口排序键保留一行,最终 9 行;本地窗口 SQL 分别返回 2 或 30 行。此前真实大数据 ACDOCA 约 1.05 亿行、库存约 1180 万行;本地抽样不能替代大数据全量对照。
    • 未去重的真实样本中,5 条 ROWS 窗口查询两库结果不同,13 条参与行中 9 条属于窗口排序并列;原 SQL 未指定并列顺序。保留并列行、仅在控制实验中补全排序键后,5 条 SQL 连续 3 轮逐行一致;这支持并列顺序解释,不代表已证明所有并列路径正确。
    • 人工边界 fixture 已与 DuckDB 对照;本次本地测试数据库和自建进程均清理。结果汇总和每条 SQL 状态见 大数据 artifact。

    待解决点

    • 回归入口仍为草稿:资产 PR #1899、调度 PR #1900;须先合入资产再合入调度。
    • 原 SQL 含未稳定排序的 LIMIT 和窗口并列值;大数据执行未进行全量独立结果对照,且当前验证不覆盖并列窗口的全部合法次序。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions