Skip to content

[Bug]: dispatch.shuffleToAllFunc panic: index out of range on multi-CTE LEFT JOIN + RANK (jinpan invoice_acdoca_link) #25930

Closed

Description

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

826a3e3

Other Environment Information

- Hardware parameters: single-node MO (docker, host port 16001)
- OS type: Linux
- Others: jinpan_001 dataset; Fact+Dim Join suite (1000 SQLs); result join_20260721_010109

Actual Behavior

All 37/37 variants of template invoice_acdoca_link fail immediately (cost_ms=0) with:

(20101) internal error: panic runtime error: index out of range [36] with length 1
  dispatch.shuffleToAllFunc   pkg/sql/colexec/dispatch/sendfunc.go:245
  dispatch.(*Dispatch).Call   pkg/sql/colexec/dispatch/dispatch.go:166
  ... ParallelRun / MergeRun ...

Not the same as #25802 (hashjoin.(*container).finalize nil pointer on bill_collection_p4). Different stack, operator, and SQL template.

Expected Behavior

Query returns rows (or empty set) without panicking the pipeline.

Steps to Reproduce

  1. Load jinpan_001 fact/dim + receipts tables (same schema as AP Regression).
  2. Execute the SQL below (j_batch_001 / @q0004_invoice_acdoca_link).
  3. Observe CN panic / client (20101) with the stack above.
WITH agg AS (
WITH invoice_src AS (
  SELECT z.belnr, z.bukrs, z.gjahr, z.zfph, z.zfpje, z.lifnr
  FROM dwd_dcp.dwd_s4_ztfi0007 z
  WHERE COALESCE(z.zfpje, 0) <> 0
    AND z.belnr IS NOT NULL AND z.belnr <> ''
    AND z.gjahr IN ('2022', '2023', '2024', '2025')
    AND z.bukrs IN ('1000', '1100', '1200', '1300', '2000', '2100', '2200', '3000')
),
acdoca_links AS (
  SELECT DISTINCT a.ebeln, a.belnr, a.rbukrs AS bukrs, a.gjahr
  FROM invoice_src z
  INNER JOIN dwd_dcp.dwd_s4_acdoca a
    ON z.belnr = a.belnr AND z.bukrs = a.rbukrs AND z.gjahr = a.gjahr
  WHERE a.ebeln IS NOT NULL AND a.ebeln <> ''
    AND a.rbukrs IN ('1000', '1100', '1200', '1300', '2000', '2100', '2200', '3000')
),
bseg_links AS (
  SELECT DISTINCT b.ebeln, b.belnr, b.bukrs, b.gjahr
  FROM invoice_src z
  INNER JOIN dwd_dcp.dwd_s4_bseg b
    ON z.belnr = b.belnr AND z.bukrs = b.bukrs AND z.gjahr = b.gjahr
  WHERE b.ebeln IS NOT NULL AND b.ebeln <> ''
    AND b.bukrs IN ('1000', '1100', '1200', '1300', '2000', '2100', '2200', '3000')
)
SELECT
  z.belnr, z.bukrs, z.gjahr, z.zfph, z.zfpje,
  COALESCE(al.ebeln, bl.ebeln) AS ebeln,
  bkpf.budat,
  COALESCE(po_a.ebeln, po_b.ebeln) AS po_filter_hit,
  RANK() OVER (PARTITION BY z.bukrs ORDER BY CAST(z.zfpje AS DECIMAL(23,2)) DESC) AS inv_rank
FROM invoice_src z
LEFT JOIN acdoca_links al ON z.belnr = al.belnr AND z.bukrs = al.bukrs AND z.gjahr = al.gjahr
LEFT JOIN bseg_links bl ON z.belnr = bl.belnr AND z.bukrs = bl.bukrs AND z.gjahr = bl.gjahr
LEFT JOIN dwd_dcp.dwd_s4_bkpf bkpf
  ON z.belnr = bkpf.belnr AND z.bukrs = bkpf.bukrs AND z.gjahr = bkpf.gjahr
LEFT JOIN (
  SELECT DISTINCT ebeln FROM jst_receipts_tables.purchase_order_report
  WHERE ebeln IS NOT NULL AND ebeln <> ''
) po_a ON po_a.ebeln = al.ebeln
LEFT JOIN (
  SELECT DISTINCT ebeln FROM jst_receipts_tables.purchase_order_report
  WHERE ebeln IS NOT NULL AND ebeln <> ''
) po_b ON po_b.ebeln = bl.ebeln
WHERE COALESCE(al.ebeln, bl.ebeln) IS NOT NULL
)
SELECT * FROM agg
LIMIT 200;

Additional information

  • Template hit rate: 37/37 failed across j_batch_001…j_batch_050 (LIMIT 100–1000 variants).
  • Same 1000-SQL suite: 934 other SQLs executed successfully (compare_failed only due to missing golden).
  • Stack (trimmed):
runtime.panicBounds64
dispatch.shuffleToAllFunc
	pkg/sql/colexec/dispatch/sendfunc.go:245
dispatch.(*Dispatch).Call
	pkg/sql/colexec/dispatch/dispatch.go:166
vm.Exec
pipeline.(*Pipeline).Run
compile.(*Scope).Run / ParallelRun / MergeRun
  • Case examples:
    • tools/mo-regression-test/cases/jinpan_001/join/j_batch_001.sql → -- @q0004_invoice_acdoca_link
    • .../j_batch_050.sql → -- @q0986_invoice_acdoca_link

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugseverity/s-1

    Type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions