Registry Mirror
Skip to content

Conversation

@sandiandian

Copy link
Copy Markdown
Contributor

add cicd pipeline
Fix: remove qingcloud platform-specific unit-tests

@tuhaihe tuhaihe added priority: Medium This issue may be useful, and needs some attention. type: Pipeline labels Jul 14, 2023
@tuhaihe

tuhaihe commented Jul 14, 2023

Copy link
Copy Markdown
Member

Hi, @sandiandian can you update your PR's title to make it more clear? You can take the following template 'Title Module' as a reference: https://github.com/cloudberrydb/cloudberrydb/blob/d6605e473e30549b6dcd9ae019edeee6932fa3a2/.gitmessage#L1-L11

@sandiandian sandiandian changed the title Ci test Add cicd pipeine Jul 17, 2023
@sandiandian sandiandian changed the title Add cicd pipeine Add cicd pipeline Jul 17, 2023
@tuhaihe
tuhaihe requested review from my-ship-it and tuhaihe July 19, 2023 04:11
@tuhaihe
tuhaihe merged commit 8e01ac8 into main Jul 19, 2023
@tuhaihe
tuhaihe deleted the ci_test branch July 19, 2023 04:12
avamingli pushed a commit to avamingli/cloudberrydb that referenced this pull request Jan 21, 2025
## Problem
An error occurs in python lib when a plpython function is executed.
After our analysis, in the user's cluster, a plpython UDF 
was running with the unstable network, and got a timeout error:
`failed to acquire resources on one or more segments`.
Then a plpython UDF was run in the same session, and the UDF
failed with GC error.

Here is the core dump:
```
2023-11-24 10:15:18.945507 CST,,,p2705198,th2081832064,,,,0,,,seg-1,,,,,"LOG","00000","3rd party error log:
    #0 0x7f7c68b6d55b in frame_dealloc /home/cc/repo/cpython/Objects/frameobject.c:509:5
    #1 0x7f7c68b5109d in gen_send_ex /home/cc/repo/cpython/Objects/genobject.c:108:9
    #2 0x7f7c68af9ddd in PyIter_Next /home/cc/repo/cpython/Objects/abstract.c:3118:14
    #3 0x7f7c78caa5c0 in PLy_exec_function /home/cc/repo/gpdb6/src/pl/plpython/plpy_exec.c:134:11
    #4 0x7f7c78cb5ffb in plpython_call_handler /home/cc/repo/gpdb6/src/pl/plpython/plpy_main.c:387:13
    #5 0x562f5e008bb5 in ExecMakeTableFunctionResult /home/cc/repo/gpdb6/src/backend/executor/execQual.c:2395:13
    #6 0x562f5e0dddec in FunctionNext_guts /home/cc/repo/gpdb6/src/backend/executor/nodeFunctionscan.c:142:5
    #7 0x562f5e0da094 in FunctionNext /home/cc/repo/gpdb6/src/backend/executor/nodeFunctionscan.c:350:11
    apache#8 0x562f5e03d4b0 in ExecScanFetch /home/cc/repo/gpdb6/src/backend/executor/execScan.c:84:9
    apache#9 0x562f5e03cd8f in ExecScan /home/cc/repo/gpdb6/src/backend/executor/execScan.c:154:10
    #10 0x562f5e0da072 in ExecFunctionScan /home/cc/repo/gpdb6/src/backend/executor/nodeFunctionscan.c:380:9
    apache#11 0x562f5e001a1c in ExecProcNode /home/cc/repo/gpdb6/src/backend/executor/execProcnode.c:1071:13
    apache#12 0x562f5dfe6377 in ExecutePlan /home/cc/repo/gpdb6/src/backend/executor/execMain.c:3202:10
    apache#13 0x562f5dfe5bf4 in standard_ExecutorRun /home/cc/repo/gpdb6/src/backend/executor/execMain.c:1171:5
    apache#14 0x562f5dfe4877 in ExecutorRun /home/cc/repo/gpdb6/src/backend/executor/execMain.c:992:4
    apache#15 0x562f5e857e69 in PortalRunSelect /home/cc/repo/gpdb6/src/backend/tcop/pquery.c:1164:4
    apache#16 0x562f5e856d3f in PortalRun /home/cc/repo/gpdb6/src/backend/tcop/pquery.c:1005:18
    apache#17 0x562f5e84607a in exec_simple_query /home/cc/repo/gpdb6/src/backend/tcop/postgres.c:1848:10
```

## Reproduce
We can use a simple procedure to reproduce the above problem:
- set timeout GUC: `gpconfig -c gp_segment_connect_timeout -v 5` and `gpstop -ari`
- prepare function:
```
CREATE EXTENSION plpythonu;
CREATE OR REPLACE FUNCTION test_func() RETURNS SETOF int AS
$$
plpy.execute("select pg_backend_pid()")

for i in range(0, 5):
    yield (i)

$$ LANGUAGE plpythonu;
```
- exit from the current psql session.
- stop the postmaster of segment: `gdb -p "the pid of segment postmaster"`
- enter a psql session.
- call `SELECT test_func();` and get error
```
gpadmin=# select test_func();
ERROR:  function "test_func" error fetching next item from iterator (plpy_elog.c:121)
DETAIL:  Exception: failed to acquire resources on one or more segments
CONTEXT:  Traceback (most recent call last):
PL/Python function "test_func"
```
- quit gdb and make postmaster runnable.
- call  `SELECT test_func();` again and get panic
```
gpadmin=# SELECT test_func();
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!> 
```

## Analysis
- There is an SPI call in test_func(): `plpy.execute()`. 
- Then coordinator will start a subtransaction by PLy_spi_subtransaction_begin();
- Meanwhile, if the segment cannot receive the instruction from the coordinator,
  the subtransaction beginning procedure return fails.
- BUT! The Python processor does not know whether an error happened and
  does not clean its environment.
- Then the next plpython UDF in the same session will fail due to the wrong
  Python environment.

## Solution
- Use try-catch to catch the exception caused by PLy_spi_subtransaction_begin()
- set the python error indicator by PLy_spi_exception_set()


Co-authored-by: Chen Mulong <chenmulong@gmail.com>
avamingli pushed a commit to avamingli/cloudberrydb that referenced this pull request Jan 21, 2025
## Problem
An error occurs in python lib when a plpython function is executed.
After our analysis, in the user's cluster, a plpython UDF 
was running with the unstable network, and got a timeout error:
`failed to acquire resources on one or more segments`.
Then a plpython UDF was run in the same session, and the UDF
failed with GC error.

Here is the core dump:
```
2023-11-24 10:15:18.945507 CST,,,p2705198,th2081832064,,,,0,,,seg-1,,,,,"LOG","00000","3rd party error log:
    #0 0x7f7c68b6d55b in frame_dealloc /home/cc/repo/cpython/Objects/frameobject.c:509:5
    #1 0x7f7c68b5109d in gen_send_ex /home/cc/repo/cpython/Objects/genobject.c:108:9
    #2 0x7f7c68af9ddd in PyIter_Next /home/cc/repo/cpython/Objects/abstract.c:3118:14
    #3 0x7f7c78caa5c0 in PLy_exec_function /home/cc/repo/gpdb6/src/pl/plpython/plpy_exec.c:134:11
    #4 0x7f7c78cb5ffb in plpython_call_handler /home/cc/repo/gpdb6/src/pl/plpython/plpy_main.c:387:13
    #5 0x562f5e008bb5 in ExecMakeTableFunctionResult /home/cc/repo/gpdb6/src/backend/executor/execQual.c:2395:13
    #6 0x562f5e0dddec in FunctionNext_guts /home/cc/repo/gpdb6/src/backend/executor/nodeFunctionscan.c:142:5
    #7 0x562f5e0da094 in FunctionNext /home/cc/repo/gpdb6/src/backend/executor/nodeFunctionscan.c:350:11
    apache#8 0x562f5e03d4b0 in ExecScanFetch /home/cc/repo/gpdb6/src/backend/executor/execScan.c:84:9
    apache#9 0x562f5e03cd8f in ExecScan /home/cc/repo/gpdb6/src/backend/executor/execScan.c:154:10
    #10 0x562f5e0da072 in ExecFunctionScan /home/cc/repo/gpdb6/src/backend/executor/nodeFunctionscan.c:380:9
    apache#11 0x562f5e001a1c in ExecProcNode /home/cc/repo/gpdb6/src/backend/executor/execProcnode.c:1071:13
    apache#12 0x562f5dfe6377 in ExecutePlan /home/cc/repo/gpdb6/src/backend/executor/execMain.c:3202:10
    apache#13 0x562f5dfe5bf4 in standard_ExecutorRun /home/cc/repo/gpdb6/src/backend/executor/execMain.c:1171:5
    apache#14 0x562f5dfe4877 in ExecutorRun /home/cc/repo/gpdb6/src/backend/executor/execMain.c:992:4
    apache#15 0x562f5e857e69 in PortalRunSelect /home/cc/repo/gpdb6/src/backend/tcop/pquery.c:1164:4
    apache#16 0x562f5e856d3f in PortalRun /home/cc/repo/gpdb6/src/backend/tcop/pquery.c:1005:18
    apache#17 0x562f5e84607a in exec_simple_query /home/cc/repo/gpdb6/src/backend/tcop/postgres.c:1848:10
```

## Reproduce
We can use a simple procedure to reproduce the above problem:
- set timeout GUC: `gpconfig -c gp_segment_connect_timeout -v 5` and `gpstop -ari`
- prepare function:
```
CREATE EXTENSION plpythonu;
CREATE OR REPLACE FUNCTION test_func() RETURNS SETOF int AS
$$
plpy.execute("select pg_backend_pid()")

for i in range(0, 5):
    yield (i)

$$ LANGUAGE plpythonu;
```
- exit from the current psql session.
- stop the postmaster of segment: `gdb -p "the pid of segment postmaster"`
- enter a psql session.
- call `SELECT test_func();` and get error
```
gpadmin=# select test_func();
ERROR:  function "test_func" error fetching next item from iterator (plpy_elog.c:121)
DETAIL:  Exception: failed to acquire resources on one or more segments
CONTEXT:  Traceback (most recent call last):
PL/Python function "test_func"
```
- quit gdb and make postmaster runnable.
- call  `SELECT test_func();` again and get panic
```
gpadmin=# SELECT test_func();
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!> 
```

## Analysis
- There is an SPI call in test_func(): `plpy.execute()`. 
- Then coordinator will start a subtransaction by PLy_spi_subtransaction_begin();
- Meanwhile, if the segment cannot receive the instruction from the coordinator,
  the subtransaction beginning procedure return fails.
- BUT! The Python processor does not know whether an error happened and
  does not clean its environment.
- Then the next plpython UDF in the same session will fail due to the wrong
  Python environment.

## Solution
- Use try-catch to catch the exception caused by PLy_spi_subtransaction_begin()
- set the python error indicator by PLy_spi_exception_set()


Co-authored-by: Chen Mulong <chenmulong@gmail.com>
avamingli pushed a commit to avamingli/cloudberrydb that referenced this pull request Jan 22, 2025
## Problem
An error occurs in python lib when a plpython function is executed.
After our analysis, in the user's cluster, a plpython UDF 
was running with the unstable network, and got a timeout error:
`failed to acquire resources on one or more segments`.
Then a plpython UDF was run in the same session, and the UDF
failed with GC error.

Here is the core dump:
```
2023-11-24 10:15:18.945507 CST,,,p2705198,th2081832064,,,,0,,,seg-1,,,,,"LOG","00000","3rd party error log:
    #0 0x7f7c68b6d55b in frame_dealloc /home/cc/repo/cpython/Objects/frameobject.c:509:5
    #1 0x7f7c68b5109d in gen_send_ex /home/cc/repo/cpython/Objects/genobject.c:108:9
    #2 0x7f7c68af9ddd in PyIter_Next /home/cc/repo/cpython/Objects/abstract.c:3118:14
    #3 0x7f7c78caa5c0 in PLy_exec_function /home/cc/repo/gpdb6/src/pl/plpython/plpy_exec.c:134:11
    #4 0x7f7c78cb5ffb in plpython_call_handler /home/cc/repo/gpdb6/src/pl/plpython/plpy_main.c:387:13
    #5 0x562f5e008bb5 in ExecMakeTableFunctionResult /home/cc/repo/gpdb6/src/backend/executor/execQual.c:2395:13
    #6 0x562f5e0dddec in FunctionNext_guts /home/cc/repo/gpdb6/src/backend/executor/nodeFunctionscan.c:142:5
    #7 0x562f5e0da094 in FunctionNext /home/cc/repo/gpdb6/src/backend/executor/nodeFunctionscan.c:350:11
    apache#8 0x562f5e03d4b0 in ExecScanFetch /home/cc/repo/gpdb6/src/backend/executor/execScan.c:84:9
    apache#9 0x562f5e03cd8f in ExecScan /home/cc/repo/gpdb6/src/backend/executor/execScan.c:154:10
    #10 0x562f5e0da072 in ExecFunctionScan /home/cc/repo/gpdb6/src/backend/executor/nodeFunctionscan.c:380:9
    apache#11 0x562f5e001a1c in ExecProcNode /home/cc/repo/gpdb6/src/backend/executor/execProcnode.c:1071:13
    apache#12 0x562f5dfe6377 in ExecutePlan /home/cc/repo/gpdb6/src/backend/executor/execMain.c:3202:10
    apache#13 0x562f5dfe5bf4 in standard_ExecutorRun /home/cc/repo/gpdb6/src/backend/executor/execMain.c:1171:5
    apache#14 0x562f5dfe4877 in ExecutorRun /home/cc/repo/gpdb6/src/backend/executor/execMain.c:992:4
    apache#15 0x562f5e857e69 in PortalRunSelect /home/cc/repo/gpdb6/src/backend/tcop/pquery.c:1164:4
    apache#16 0x562f5e856d3f in PortalRun /home/cc/repo/gpdb6/src/backend/tcop/pquery.c:1005:18
    apache#17 0x562f5e84607a in exec_simple_query /home/cc/repo/gpdb6/src/backend/tcop/postgres.c:1848:10
```

## Reproduce
We can use a simple procedure to reproduce the above problem:
- set timeout GUC: `gpconfig -c gp_segment_connect_timeout -v 5` and `gpstop -ari`
- prepare function:
```
CREATE EXTENSION plpythonu;
CREATE OR REPLACE FUNCTION test_func() RETURNS SETOF int AS
$$
plpy.execute("select pg_backend_pid()")

for i in range(0, 5):
    yield (i)

$$ LANGUAGE plpythonu;
```
- exit from the current psql session.
- stop the postmaster of segment: `gdb -p "the pid of segment postmaster"`
- enter a psql session.
- call `SELECT test_func();` and get error
```
gpadmin=# select test_func();
ERROR:  function "test_func" error fetching next item from iterator (plpy_elog.c:121)
DETAIL:  Exception: failed to acquire resources on one or more segments
CONTEXT:  Traceback (most recent call last):
PL/Python function "test_func"
```
- quit gdb and make postmaster runnable.
- call  `SELECT test_func();` again and get panic
```
gpadmin=# SELECT test_func();
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!> 
```

## Analysis
- There is an SPI call in test_func(): `plpy.execute()`. 
- Then coordinator will start a subtransaction by PLy_spi_subtransaction_begin();
- Meanwhile, if the segment cannot receive the instruction from the coordinator,
  the subtransaction beginning procedure return fails.
- BUT! The Python processor does not know whether an error happened and
  does not clean its environment.
- Then the next plpython UDF in the same session will fail due to the wrong
  Python environment.

## Solution
- Use try-catch to catch the exception caused by PLy_spi_subtransaction_begin()
- set the python error indicator by PLy_spi_exception_set()


Co-authored-by: Chen Mulong <chenmulong@gmail.com>
avamingli pushed a commit that referenced this pull request Jan 23, 2025
## Problem
An error occurs in python lib when a plpython function is executed.
After our analysis, in the user's cluster, a plpython UDF 
was running with the unstable network, and got a timeout error:
`failed to acquire resources on one or more segments`.
Then a plpython UDF was run in the same session, and the UDF
failed with GC error.

Here is the core dump:
```
2023-11-24 10:15:18.945507 CST,,,p2705198,th2081832064,,,,0,,,seg-1,,,,,"LOG","00000","3rd party error log:
    #0 0x7f7c68b6d55b in frame_dealloc /home/cc/repo/cpython/Objects/frameobject.c:509:5
    #1 0x7f7c68b5109d in gen_send_ex /home/cc/repo/cpython/Objects/genobject.c:108:9
    #2 0x7f7c68af9ddd in PyIter_Next /home/cc/repo/cpython/Objects/abstract.c:3118:14
    #3 0x7f7c78caa5c0 in PLy_exec_function /home/cc/repo/gpdb6/src/pl/plpython/plpy_exec.c:134:11
    #4 0x7f7c78cb5ffb in plpython_call_handler /home/cc/repo/gpdb6/src/pl/plpython/plpy_main.c:387:13
    #5 0x562f5e008bb5 in ExecMakeTableFunctionResult /home/cc/repo/gpdb6/src/backend/executor/execQual.c:2395:13
    #6 0x562f5e0dddec in FunctionNext_guts /home/cc/repo/gpdb6/src/backend/executor/nodeFunctionscan.c:142:5
    #7 0x562f5e0da094 in FunctionNext /home/cc/repo/gpdb6/src/backend/executor/nodeFunctionscan.c:350:11
    #8 0x562f5e03d4b0 in ExecScanFetch /home/cc/repo/gpdb6/src/backend/executor/execScan.c:84:9
    #9 0x562f5e03cd8f in ExecScan /home/cc/repo/gpdb6/src/backend/executor/execScan.c:154:10
    #10 0x562f5e0da072 in ExecFunctionScan /home/cc/repo/gpdb6/src/backend/executor/nodeFunctionscan.c:380:9
    #11 0x562f5e001a1c in ExecProcNode /home/cc/repo/gpdb6/src/backend/executor/execProcnode.c:1071:13
    #12 0x562f5dfe6377 in ExecutePlan /home/cc/repo/gpdb6/src/backend/executor/execMain.c:3202:10
    #13 0x562f5dfe5bf4 in standard_ExecutorRun /home/cc/repo/gpdb6/src/backend/executor/execMain.c:1171:5
    #14 0x562f5dfe4877 in ExecutorRun /home/cc/repo/gpdb6/src/backend/executor/execMain.c:992:4
    #15 0x562f5e857e69 in PortalRunSelect /home/cc/repo/gpdb6/src/backend/tcop/pquery.c:1164:4
    #16 0x562f5e856d3f in PortalRun /home/cc/repo/gpdb6/src/backend/tcop/pquery.c:1005:18
    #17 0x562f5e84607a in exec_simple_query /home/cc/repo/gpdb6/src/backend/tcop/postgres.c:1848:10
```

## Reproduce
We can use a simple procedure to reproduce the above problem:
- set timeout GUC: `gpconfig -c gp_segment_connect_timeout -v 5` and `gpstop -ari`
- prepare function:
```
CREATE EXTENSION plpythonu;
CREATE OR REPLACE FUNCTION test_func() RETURNS SETOF int AS
$$
plpy.execute("select pg_backend_pid()")

for i in range(0, 5):
    yield (i)

$$ LANGUAGE plpythonu;
```
- exit from the current psql session.
- stop the postmaster of segment: `gdb -p "the pid of segment postmaster"`
- enter a psql session.
- call `SELECT test_func();` and get error
```
gpadmin=# select test_func();
ERROR:  function "test_func" error fetching next item from iterator (plpy_elog.c:121)
DETAIL:  Exception: failed to acquire resources on one or more segments
CONTEXT:  Traceback (most recent call last):
PL/Python function "test_func"
```
- quit gdb and make postmaster runnable.
- call  `SELECT test_func();` again and get panic
```
gpadmin=# SELECT test_func();
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
!> 
```

## Analysis
- There is an SPI call in test_func(): `plpy.execute()`. 
- Then coordinator will start a subtransaction by PLy_spi_subtransaction_begin();
- Meanwhile, if the segment cannot receive the instruction from the coordinator,
  the subtransaction beginning procedure return fails.
- BUT! The Python processor does not know whether an error happened and
  does not clean its environment.
- Then the next plpython UDF in the same session will fail due to the wrong
  Python environment.

## Solution
- Use try-catch to catch the exception caused by PLy_spi_subtransaction_begin()
- set the python error indicator by PLy_spi_exception_set()


Co-authored-by: Chen Mulong <chenmulong@gmail.com>
reshke added a commit to reshke/cloudberrydb that referenced this pull request Nov 14, 2026
A replicated data-modifying CTE with ORDER BY reaches the sorted receiver with motionType GATHER_SINGLE, sendSorted set, and a non-NULL merge heap. It tripped the nodeMotion.c:441 assertion, which only allowed GATHER. Permit GATHER_SINGLE while retaining the sendSorted and heap checks.

GDB backtrace (verbatim):
#0  0x000079fa0d69ebec in pthread_kill () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x000079fa0d64527e in raise () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x000079fa0d6288ff in abort () from /lib/x86_64-linux-gnu/libc.so.6
#3  0x0000646474bc5726 in ExceptionalCondition (conditionName=conditionName@entry=0x6464754da9a0 "motion->motionType == MOTIONTYPE_GATHER && motion->sendSorted && hp != NULL", fileName=fileName@entry=0x646475445062 "nodeMotion.c", lineNumber=lineNumber@entry=441) at assert.c:42
#4  0x0000646474ef5260 in execMotionSortedReceiver (node=0x6464a0549f48) at nodeMotion.c:441
#5  ExecMotion (pstate=0x6464a0549f48) at nodeMotion.c:152
#6  0x0000646474e9cd8d in ExecProcNodeGPDB (node=0x6464a0549f48) at execProcnode.c:672
apache#7  ExecProcNodeFirst (node=0x6464a0549f48) at execProcnode.c:633
apache#8  0x0000646474e91e6a in ExecProcNode (node=0x6464a0549f48) at ../../../src/include/executor/executor.h:305
apache#9  ExecutePlan (queryDesc=queryDesc@entry=0x6464a0453610, use_parallel_mode=<optimized out>, use_parallel_mode@entry=false, operation=operation@entry=CMD_SELECT, sendTuples=sendTuples@entry=true, numberTuples=numberTuples@entry=0, direction=direction@entry=ForwardScanDirection, dest=0x6464a0453580, execute_once=true) at execMain.c:2899
#10 0x0000646474e928a3 in standard_ExecutorRun (queryDesc=0x6464a0453610, direction=ForwardScanDirection, count=0, execute_once=true) at execMain.c:1037
apache#11 0x0000646474e92ffd in ExecutorRun (queryDesc=queryDesc@entry=0x6464a0453610, direction=direction@entry=ForwardScanDirection, count=count@entry=0, execute_once=execute_once@entry=true) at execMain.c:845
apache#12 0x00006464751738a8 in ProcessQuery (portal=portal@entry=0x6464a04ad358, stmt=stmt@entry=0x6464a05671f8, params=<optimized out>, queryEnv=0x0, dest=dest@entry=0x6464a0453580, qc=qc@entry=0x7fff171201c0, sourceText=<optimized out>) at pquery.c:251
apache#13 0x0000646475174022 in PortalRunMulti (portal=portal@entry=0x6464a04ad358, isTopLevel=isTopLevel@entry=true, setHoldSnapshot=setHoldSnapshot@entry=true, dest=dest@entry=0x6464a0453580, altdest=0x6464757f90a0 <donothingDR>, qc=qc@entry=0x7fff171201c0) at pquery.c:1497
apache#14 0x0000646475174247 in FillPortalStore (portal=portal@entry=0x6464a04ad358, isTopLevel=isTopLevel@entry=true) at pquery.c:1241
apache#15 0x00006464751759dd in PortalRun (portal=portal@entry=0x6464a04ad358, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, dest=dest@entry=0x6464a0567308, altdest=altdest@entry=0x6464a0567308, qc=0x7fff171203e0) at pquery.c:975
apache#16 0x000064647517025e in exec_simple_query (query_string=0x6464a04138c8 "WITH ins AS (INSERT INTO rep_order_assert VALUES (1),(1) RETURNING v) SELECT v FROM ins ORDER BY v;") at postgres.c:2008
apache#17 0x0000646475172a87 in PostgresMain (dbname=<optimized out>, username=<optimized out>) at postgres.c:5933
apache#18 0x00006464750a4aab in BackendRun (port=0x6464a044eec0) at postmaster.c:5095
apache#19 BackendStartup (port=0x6464a044eec0) at postmaster.c:4805
apache#20 ServerLoop () at postmaster.c:2107
apache#21 0x00006464750a5a8b in PostmasterMain (argc=argc@entry=7, argv=argv@entry=0x6464a040cee0) at postmaster.c:1750
apache#22 0x0000646474bd9f3d in main (argc=7, argv=0x6464a040cee0) at main.c:260
reshke added a commit to reshke/cloudberrydb that referenced this pull request Nov 14, 2026
A replicated data-modifying CTE with ORDER BY reaches the sorted receiver with motionType GATHER_SINGLE, sendSorted set, and a non-NULL merge heap. It tripped the nodeMotion.c:441 assertion, which only allowed GATHER. Permit GATHER_SINGLE while retaining the sendSorted and heap checks.

GDB backtrace (verbatim):
#0  0x000079fa0d69ebec in pthread_kill () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x000079fa0d64527e in raise () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x000079fa0d6288ff in abort () from /lib/x86_64-linux-gnu/libc.so.6
#3  0x0000646474bc5726 in ExceptionalCondition (conditionName=conditionName@entry=0x6464754da9a0 "motion->motionType == MOTIONTYPE_GATHER && motion->sendSorted && hp != NULL", fileName=fileName@entry=0x646475445062 "nodeMotion.c", lineNumber=lineNumber@entry=441) at assert.c:42
#4  0x0000646474ef5260 in execMotionSortedReceiver (node=0x6464a0549f48) at nodeMotion.c:441
#5  ExecMotion (pstate=0x6464a0549f48) at nodeMotion.c:152
#6  0x0000646474e9cd8d in ExecProcNodeGPDB (node=0x6464a0549f48) at execProcnode.c:672
apache#7  ExecProcNodeFirst (node=0x6464a0549f48) at execProcnode.c:633
apache#8  0x0000646474e91e6a in ExecProcNode (node=0x6464a0549f48) at ../../../src/include/executor/executor.h:305
apache#9  ExecutePlan (queryDesc=queryDesc@entry=0x6464a0453610, use_parallel_mode=<optimized out>, use_parallel_mode@entry=false, operation=operation@entry=CMD_SELECT, sendTuples=sendTuples@entry=true, numberTuples=numberTuples@entry=0, direction=direction@entry=ForwardScanDirection, dest=0x6464a0453580, execute_once=true) at execMain.c:2899
#10 0x0000646474e928a3 in standard_ExecutorRun (queryDesc=0x6464a0453610, direction=ForwardScanDirection, count=0, execute_once=true) at execMain.c:1037
apache#11 0x0000646474e92ffd in ExecutorRun (queryDesc=queryDesc@entry=0x6464a0453610, direction=direction@entry=ForwardScanDirection, count=count@entry=0, execute_once=execute_once@entry=true) at execMain.c:845
apache#12 0x00006464751738a8 in ProcessQuery (portal=portal@entry=0x6464a04ad358, stmt=stmt@entry=0x6464a05671f8, params=<optimized out>, queryEnv=0x0, dest=dest@entry=0x6464a0453580, qc=qc@entry=0x7fff171201c0, sourceText=<optimized out>) at pquery.c:251
apache#13 0x0000646475174022 in PortalRunMulti (portal=portal@entry=0x6464a04ad358, isTopLevel=isTopLevel@entry=true, setHoldSnapshot=setHoldSnapshot@entry=true, dest=dest@entry=0x6464a0453580, altdest=0x6464757f90a0 <donothingDR>, qc=qc@entry=0x7fff171201c0) at pquery.c:1497
apache#14 0x0000646475174247 in FillPortalStore (portal=portal@entry=0x6464a04ad358, isTopLevel=isTopLevel@entry=true) at pquery.c:1241
apache#15 0x00006464751759dd in PortalRun (portal=portal@entry=0x6464a04ad358, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, dest=dest@entry=0x6464a0567308, altdest=altdest@entry=0x6464a0567308, qc=0x7fff171203e0) at pquery.c:975
apache#16 0x000064647517025e in exec_simple_query (query_string=0x6464a04138c8 "WITH ins AS (INSERT INTO rep_order_assert VALUES (1),(1) RETURNING v) SELECT v FROM ins ORDER BY v;") at postgres.c:2008
apache#17 0x0000646475172a87 in PostgresMain (dbname=<optimized out>, username=<optimized out>) at postgres.c:5933
apache#18 0x00006464750a4aab in BackendRun (port=0x6464a044eec0) at postmaster.c:5095
apache#19 BackendStartup (port=0x6464a044eec0) at postmaster.c:4805
apache#20 ServerLoop () at postmaster.c:2107
apache#21 0x00006464750a5a8b in PostmasterMain (argc=argc@entry=7, argv=argv@entry=0x6464a040cee0) at postmaster.c:1750
apache#22 0x0000646474bd9f3d in main (argc=7, argv=0x6464a040cee0) at main.c:260
tuhaihe pushed a commit to reshke/cloudberrydb that referenced this pull request Nov 20, 2026
A replicated data-modifying CTE with ORDER BY reaches the sorted receiver with motionType GATHER_SINGLE, sendSorted set, and a non-NULL merge heap. It tripped the nodeMotion.c:441 assertion, which only allowed GATHER. Permit GATHER_SINGLE while retaining the sendSorted and heap checks.

GDB backtrace (verbatim):
#0  0x000079fa0d69ebec in pthread_kill () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x000079fa0d64527e in raise () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x000079fa0d6288ff in abort () from /lib/x86_64-linux-gnu/libc.so.6
#3  0x0000646474bc5726 in ExceptionalCondition (conditionName=conditionName@entry=0x6464754da9a0 "motion->motionType == MOTIONTYPE_GATHER && motion->sendSorted && hp != NULL", fileName=fileName@entry=0x646475445062 "nodeMotion.c", lineNumber=lineNumber@entry=441) at assert.c:42
#4  0x0000646474ef5260 in execMotionSortedReceiver (node=0x6464a0549f48) at nodeMotion.c:441
#5  ExecMotion (pstate=0x6464a0549f48) at nodeMotion.c:152
#6  0x0000646474e9cd8d in ExecProcNodeGPDB (node=0x6464a0549f48) at execProcnode.c:672
apache#7  ExecProcNodeFirst (node=0x6464a0549f48) at execProcnode.c:633
apache#8  0x0000646474e91e6a in ExecProcNode (node=0x6464a0549f48) at ../../../src/include/executor/executor.h:305
apache#9  ExecutePlan (queryDesc=queryDesc@entry=0x6464a0453610, use_parallel_mode=<optimized out>, use_parallel_mode@entry=false, operation=operation@entry=CMD_SELECT, sendTuples=sendTuples@entry=true, numberTuples=numberTuples@entry=0, direction=direction@entry=ForwardScanDirection, dest=0x6464a0453580, execute_once=true) at execMain.c:2899
#10 0x0000646474e928a3 in standard_ExecutorRun (queryDesc=0x6464a0453610, direction=ForwardScanDirection, count=0, execute_once=true) at execMain.c:1037
apache#11 0x0000646474e92ffd in ExecutorRun (queryDesc=queryDesc@entry=0x6464a0453610, direction=direction@entry=ForwardScanDirection, count=count@entry=0, execute_once=execute_once@entry=true) at execMain.c:845
apache#12 0x00006464751738a8 in ProcessQuery (portal=portal@entry=0x6464a04ad358, stmt=stmt@entry=0x6464a05671f8, params=<optimized out>, queryEnv=0x0, dest=dest@entry=0x6464a0453580, qc=qc@entry=0x7fff171201c0, sourceText=<optimized out>) at pquery.c:251
apache#13 0x0000646475174022 in PortalRunMulti (portal=portal@entry=0x6464a04ad358, isTopLevel=isTopLevel@entry=true, setHoldSnapshot=setHoldSnapshot@entry=true, dest=dest@entry=0x6464a0453580, altdest=0x6464757f90a0 <donothingDR>, qc=qc@entry=0x7fff171201c0) at pquery.c:1497
apache#14 0x0000646475174247 in FillPortalStore (portal=portal@entry=0x6464a04ad358, isTopLevel=isTopLevel@entry=true) at pquery.c:1241
apache#15 0x00006464751759dd in PortalRun (portal=portal@entry=0x6464a04ad358, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, dest=dest@entry=0x6464a0567308, altdest=altdest@entry=0x6464a0567308, qc=0x7fff171203e0) at pquery.c:975
apache#16 0x000064647517025e in exec_simple_query (query_string=0x6464a04138c8 "WITH ins AS (INSERT INTO rep_order_assert VALUES (1),(1) RETURNING v) SELECT v FROM ins ORDER BY v;") at postgres.c:2008
apache#17 0x0000646475172a87 in PostgresMain (dbname=<optimized out>, username=<optimized out>) at postgres.c:5933
apache#18 0x00006464750a4aab in BackendRun (port=0x6464a044eec0) at postmaster.c:5095
apache#19 BackendStartup (port=0x6464a044eec0) at postmaster.c:4805
apache#20 ServerLoop () at postmaster.c:2107
apache#21 0x00006464750a5a8b in PostmasterMain (argc=argc@entry=7, argv=argv@entry=0x6464a040cee0) at postmaster.c:1750
apache#22 0x0000646474bd9f3d in main (argc=7, argv=0x6464a040cee0) at main.c:260
tuhaihe pushed a commit to reshke/cloudberrydb that referenced this pull request Nov 21, 2026
A replicated data-modifying CTE with ORDER BY reaches the sorted receiver with motionType GATHER_SINGLE, sendSorted set, and a non-NULL merge heap. It tripped the nodeMotion.c:441 assertion, which only allowed GATHER. Permit GATHER_SINGLE while retaining the sendSorted and heap checks.

GDB backtrace (verbatim):
#0  0x000079fa0d69ebec in pthread_kill () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x000079fa0d64527e in raise () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x000079fa0d6288ff in abort () from /lib/x86_64-linux-gnu/libc.so.6
#3  0x0000646474bc5726 in ExceptionalCondition (conditionName=conditionName@entry=0x6464754da9a0 "motion->motionType == MOTIONTYPE_GATHER && motion->sendSorted && hp != NULL", fileName=fileName@entry=0x646475445062 "nodeMotion.c", lineNumber=lineNumber@entry=441) at assert.c:42
#4  0x0000646474ef5260 in execMotionSortedReceiver (node=0x6464a0549f48) at nodeMotion.c:441
#5  ExecMotion (pstate=0x6464a0549f48) at nodeMotion.c:152
#6  0x0000646474e9cd8d in ExecProcNodeGPDB (node=0x6464a0549f48) at execProcnode.c:672
apache#7  ExecProcNodeFirst (node=0x6464a0549f48) at execProcnode.c:633
apache#8  0x0000646474e91e6a in ExecProcNode (node=0x6464a0549f48) at ../../../src/include/executor/executor.h:305
apache#9  ExecutePlan (queryDesc=queryDesc@entry=0x6464a0453610, use_parallel_mode=<optimized out>, use_parallel_mode@entry=false, operation=operation@entry=CMD_SELECT, sendTuples=sendTuples@entry=true, numberTuples=numberTuples@entry=0, direction=direction@entry=ForwardScanDirection, dest=0x6464a0453580, execute_once=true) at execMain.c:2899
#10 0x0000646474e928a3 in standard_ExecutorRun (queryDesc=0x6464a0453610, direction=ForwardScanDirection, count=0, execute_once=true) at execMain.c:1037
apache#11 0x0000646474e92ffd in ExecutorRun (queryDesc=queryDesc@entry=0x6464a0453610, direction=direction@entry=ForwardScanDirection, count=count@entry=0, execute_once=execute_once@entry=true) at execMain.c:845
apache#12 0x00006464751738a8 in ProcessQuery (portal=portal@entry=0x6464a04ad358, stmt=stmt@entry=0x6464a05671f8, params=<optimized out>, queryEnv=0x0, dest=dest@entry=0x6464a0453580, qc=qc@entry=0x7fff171201c0, sourceText=<optimized out>) at pquery.c:251
apache#13 0x0000646475174022 in PortalRunMulti (portal=portal@entry=0x6464a04ad358, isTopLevel=isTopLevel@entry=true, setHoldSnapshot=setHoldSnapshot@entry=true, dest=dest@entry=0x6464a0453580, altdest=0x6464757f90a0 <donothingDR>, qc=qc@entry=0x7fff171201c0) at pquery.c:1497
apache#14 0x0000646475174247 in FillPortalStore (portal=portal@entry=0x6464a04ad358, isTopLevel=isTopLevel@entry=true) at pquery.c:1241
apache#15 0x00006464751759dd in PortalRun (portal=portal@entry=0x6464a04ad358, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, dest=dest@entry=0x6464a0567308, altdest=altdest@entry=0x6464a0567308, qc=0x7fff171203e0) at pquery.c:975
apache#16 0x000064647517025e in exec_simple_query (query_string=0x6464a04138c8 "WITH ins AS (INSERT INTO rep_order_assert VALUES (1),(1) RETURNING v) SELECT v FROM ins ORDER BY v;") at postgres.c:2008
apache#17 0x0000646475172a87 in PostgresMain (dbname=<optimized out>, username=<optimized out>) at postgres.c:5933
apache#18 0x00006464750a4aab in BackendRun (port=0x6464a044eec0) at postmaster.c:5095
apache#19 BackendStartup (port=0x6464a044eec0) at postmaster.c:4805
apache#20 ServerLoop () at postmaster.c:2107
apache#21 0x00006464750a5a8b in PostmasterMain (argc=argc@entry=7, argv=argv@entry=0x6464a040cee0) at postmaster.c:1750
apache#22 0x0000646474bd9f3d in main (argc=7, argv=0x6464a040cee0) at main.c:260
tuhaihe pushed a commit that referenced this pull request Nov 21, 2026
* Allow sorted GatherSingle motion receivers

A replicated data-modifying CTE with ORDER BY reaches the sorted receiver with motionType GATHER_SINGLE, sendSorted set, and a non-NULL merge heap. It tripped the nodeMotion.c:441 assertion, which only allowed GATHER. Permit GATHER_SINGLE while retaining the sendSorted and heap checks.

GDB backtrace (verbatim):
#0  0x000079fa0d69ebec in pthread_kill () from /lib/x86_64-linux-gnu/libc.so.6
#1  0x000079fa0d64527e in raise () from /lib/x86_64-linux-gnu/libc.so.6
#2  0x000079fa0d6288ff in abort () from /lib/x86_64-linux-gnu/libc.so.6
#3  0x0000646474bc5726 in ExceptionalCondition (conditionName=conditionName@entry=0x6464754da9a0 "motion->motionType == MOTIONTYPE_GATHER && motion->sendSorted && hp != NULL", fileName=fileName@entry=0x646475445062 "nodeMotion.c", lineNumber=lineNumber@entry=441) at assert.c:42
#4  0x0000646474ef5260 in execMotionSortedReceiver (node=0x6464a0549f48) at nodeMotion.c:441
#5  ExecMotion (pstate=0x6464a0549f48) at nodeMotion.c:152
#6  0x0000646474e9cd8d in ExecProcNodeGPDB (node=0x6464a0549f48) at execProcnode.c:672
#7  ExecProcNodeFirst (node=0x6464a0549f48) at execProcnode.c:633
#8  0x0000646474e91e6a in ExecProcNode (node=0x6464a0549f48) at ../../../src/include/executor/executor.h:305
#9  ExecutePlan (queryDesc=queryDesc@entry=0x6464a0453610, use_parallel_mode=<optimized out>, use_parallel_mode@entry=false, operation=operation@entry=CMD_SELECT, sendTuples=sendTuples@entry=true, numberTuples=numberTuples@entry=0, direction=direction@entry=ForwardScanDirection, dest=0x6464a0453580, execute_once=true) at execMain.c:2899
#10 0x0000646474e928a3 in standard_ExecutorRun (queryDesc=0x6464a0453610, direction=ForwardScanDirection, count=0, execute_once=true) at execMain.c:1037
#11 0x0000646474e92ffd in ExecutorRun (queryDesc=queryDesc@entry=0x6464a0453610, direction=direction@entry=ForwardScanDirection, count=count@entry=0, execute_once=execute_once@entry=true) at execMain.c:845
#12 0x00006464751738a8 in ProcessQuery (portal=portal@entry=0x6464a04ad358, stmt=stmt@entry=0x6464a05671f8, params=<optimized out>, queryEnv=0x0, dest=dest@entry=0x6464a0453580, qc=qc@entry=0x7fff171201c0, sourceText=<optimized out>) at pquery.c:251
#13 0x0000646475174022 in PortalRunMulti (portal=portal@entry=0x6464a04ad358, isTopLevel=isTopLevel@entry=true, setHoldSnapshot=setHoldSnapshot@entry=true, dest=dest@entry=0x6464a0453580, altdest=0x6464757f90a0 <donothingDR>, qc=qc@entry=0x7fff171201c0) at pquery.c:1497
#14 0x0000646475174247 in FillPortalStore (portal=portal@entry=0x6464a04ad358, isTopLevel=isTopLevel@entry=true) at pquery.c:1241
#15 0x00006464751759dd in PortalRun (portal=portal@entry=0x6464a04ad358, count=count@entry=9223372036854775807, isTopLevel=isTopLevel@entry=true, run_once=run_once@entry=true, dest=dest@entry=0x6464a0567308, altdest=altdest@entry=0x6464a0567308, qc=0x7fff171203e0) at pquery.c:975
#16 0x000064647517025e in exec_simple_query (query_string=0x6464a04138c8 "WITH ins AS (INSERT INTO rep_order_assert VALUES (1),(1) RETURNING v) SELECT v FROM ins ORDER BY v;") at postgres.c:2008
#17 0x0000646475172a87 in PostgresMain (dbname=<optimized out>, username=<optimized out>) at postgres.c:5933
#18 0x00006464750a4aab in BackendRun (port=0x6464a044eec0) at postmaster.c:5095
#19 BackendStartup (port=0x6464a044eec0) at postmaster.c:4805
#20 ServerLoop () at postmaster.c:2107
#21 0x00006464750a5a8b in PostmasterMain (argc=argc@entry=7, argv=argv@entry=0x6464a040cee0) at postmaster.c:1750
#22 0x0000646474bd9f3d in main (argc=7, argv=0x6464a040cee0) at main.c:260

* Cover sorted GatherSingle in the WITH regression

Move the replicated writable-CTE case into the existing WITH test and
reuse its replicated table. Add one EXPLAIN (COSTS OFF) with captured
expected output, retaining both the ordered result and unsorted control.
Remove the standalone test and its separate serial schedule entry.

The tested query path is:
  WITH ins AS (INSERT INTO t_w_cte_relp VALUES (1),(1) RETURNING a)
  SELECT a FROM ins ORDER BY a;

Validation: the extracted block passed pg_regress (1/1), and its output
matched the new block in a full WITH run byte for byte. Existing fixture
and resource-output differences in that full run are left unchanged.

* Update optimizer expected output for sorted GatherSingle CTE

The optimizer regression runs the same with.sql against with_optimizer.out.
Its newly added replicated-CTE block explicitly sets optimizer=off, so this
variant must contain the captured PostgreSQL plan and result rows too.
Add that missing block without adding another SQL case or EXPLAIN.

The existing regression query is:
  WITH ins AS (INSERT INTO t_w_cte_relp VALUES (1),(1) RETURNING a)
  SELECT a FROM ins ORDER BY a;

Validation: the added block matches the previously captured and passing
pg_regress result byte for byte; expected-file selection and the optimizer
GUC gate were checked in the harness/planner sources. diff --check passes.
reshke added a commit to reshke/cloudberrydb that referenced this pull request Dec 1, 2026
Mark float8arr_eq STRICT so SQL NULL arguments are handled by the executor
before the C implementation dereferences them. Add a 1.0.3 upgrade path for
existing installations, correct fresh-install scripts, and add NULL regression
coverage for installation and upgrades from 1.0.1 and 1.0.2.

SQL reproduction as a non-superuser before the fix:

    SELECT sparse_vector.float8arr_eq(NULL::float8[], ARRAY[1]::float8[]);

For the backtrace run, the same call was executed through this prepared
statement:

    PREPARE q(float8[], float8[]) AS
        SELECT sparse_vector.float8arr_eq($1, $2);
    EXECUTE q(NULL::float8[], ARRAY[1]::float8[]);

Verbatim server log:

    2026-12-01 12:28:32.427106 MSK,,,p395704,th123456,,,2026-12-01 12:27:33 MSK,0,,cmd4,seg-1,,,,,"PANIC","XX000","Unexpected internal error: Segment process received signal SIGSEGV",,,,,,,0,,,,
    2026-12-01 12:28:32.427211 MSK,,,p263623,th-153823424,,,,0,,,seg-1,,,,,"LOG","00000","server process (PID 395704) was terminated by signal 11: Segmentation fault","Failed process was running: EXECUTE q(NULL::float8[], ARRAY[1]::float8[]);",,,,,,0,,"postmaster.c",4278,
    2026-12-01 12:28:32.427218 MSK,,,p263623,th-153823424,,,,0,,,seg-1,,,,,"LOG","00000","terminating any other active server processes",,,,,,,0,,"postmaster.c",4071,
    2026-12-01 12:28:32.428219 MSK,"sqltester","postgres",p415572,th-153823424,"[local]",,2026-12-01 12:28:32 MSK,0,,,seg-1,,,,sx1,"FATAL","57P03","the database system is resetting",,,,,,,0,,"postmaster.c",2833,
    2026-12-01 12:28:32.428731 MSK,,,p263623,th-153823424,,,,0,,,seg-1,,,,,"LOG","00000","all server processes terminated; reinitializing",,,,,,,0,,"postmaster.c",4551,

Verbatim gdb backtrace:

    Program received signal SIGSEGV, Segmentation fault.
    0x000055a9c94fcca4 in pg_detoast_datum ()
    #0  0x000055a9c94fcca4 in pg_detoast_datum ()
    #1  0x00007f02eb0727c2 in float8arr_equals () from /home/reshke/.ya/tmp/1795466526.3735447.62efjlaq/opencode/cbdb-install/lib/postgresql/gp_svec.so
    #2  0x000055a9c90daaae in ExecInterpExpr ()
    #3  0x000055a9c9280558 in evaluate_expr ()
    #4  0x000055a9c9280da4 in simplify_function ()
    #5  0x000055a9c9281dad in eval_const_expressions_mutator ()
    #6  0x000055a9c9185714 in expression_tree_mutator_impl ()
    apache#7  0x000055a9c91864d2 in expression_tree_mutator_impl ()
    apache#8  0x000055a9c9282949 in eval_const_expressions ()
    apache#9  0x000055a9c925c918 in preprocess_expression.constprop ()
    #10 0x000055a9c9264954 in subquery_planner ()
    apache#11 0x000055a9c926557a in standard_planner ()
    apache#12 0x000055a9c9266064 in planner ()
    apache#13 0x000055a9c9367086 in pg_plan_query ()
    apache#14 0x000055a9c9367183 in pg_plan_queries ()
    apache#15 0x000055a9c94cfa73 in BuildCachedPlan ()
    apache#16 0x000055a9c94cfdc8 in GetCachedPlan ()
    apache#17 0x000055a9c907270b in ExecuteQuery ()
    apache#18 0x000055a9c9370313 in standard_ProcessUtility ()
    apache#19 0x000055a9c9370c5d in ProcessUtility ()
    apache#20 0x000055a9c936e183 in PortalRunUtility ()
    apache#21 0x000055a9c936e857 in FillPortalStore ()
    apache#22 0x000055a9c936ebad in PortalRun ()
    apache#23 0x000055a9c93678e0 in exec_simple_query ()
    apache#24 0x000055a9c936c104 in PostgresMain ()
    apache#25 0x000055a9c92b8004 in ServerLoop.isra.0 ()
    apache#26 0x000055a9c92b926a in PostmasterMain ()
    apache#27 0x000055a9c8e7a548 in main ()
    [Inferior 1 (process 395704) detached]
reshke added a commit to reshke/cloudberrydb that referenced this pull request Dec 1, 2026
Mark float8arr_eq(float8[], float8[]), l2norm(float8[]), and unnest(svec)
STRICT so whole-argument SQL NULLs are handled before their C entry points.
Update install scripts and version migrations, plus fresh-install and upgrade
regression coverage. Keep the 1.0.2 default install script and provide a small
explicit 1.0.2-to-1.0.3 migration, avoiding a copied full 1.0.3 install file.

SQL reproductions and pre-fix evidence
=======================================

float8arr_eq:

SQL reproduction as a non-superuser before the fix:

    SELECT sparse_vector.float8arr_eq(NULL::float8[], ARRAY[1]::float8[]);

For the backtrace run, the same call was executed through this prepared
statement:

    PREPARE q(float8[], float8[]) AS
        SELECT sparse_vector.float8arr_eq($1, $2);
    EXECUTE q(NULL::float8[], ARRAY[1]::float8[]);

Verbatim server log:

    2026-12-01 12:28:32.427106 MSK,,,p395704,th123456,,,2026-12-01 12:27:33 MSK,0,,cmd4,seg-1,,,,,"PANIC","XX000","Unexpected internal error: Segment process received signal SIGSEGV",,,,,,,0,,,,
    2026-12-01 12:28:32.427211 MSK,,,p263623,th-153823424,,,,0,,,seg-1,,,,,"LOG","00000","server process (PID 395704) was terminated by signal 11: Segmentation fault","Failed process was running: EXECUTE q(NULL::float8[], ARRAY[1]::float8[]);",,,,,,0,,"postmaster.c",4278,
    2026-12-01 12:28:32.427218 MSK,,,p263623,th-153823424,,,,0,,,seg-1,,,,,"LOG","00000","terminating any other active server processes",,,,,,,0,,"postmaster.c",4071,
    2026-12-01 12:28:32.428219 MSK,"sqltester","postgres",p415572,th-153823424,"[local]",,2026-12-01 12:28:32 MSK,0,,,seg-1,,,,sx1,"FATAL","57P03","the database system is resetting",,,,,,,0,,"postmaster.c",2833,
    2026-12-01 12:28:32.428731 MSK,,,p263623,th-153823424,,,,0,,,seg-1,,,,,"LOG","00000","all server processes terminated; reinitializing",,,,,,,0,,"postmaster.c",4551,

Verbatim gdb backtrace:

    Program received signal SIGSEGV, Segmentation fault.
    0x000055a9c94fcca4 in pg_detoast_datum ()
    #0  0x000055a9c94fcca4 in pg_detoast_datum ()
    #1  0x00007f02eb0727c2 in float8arr_equals () from /home/reshke/.ya/tmp/1795466526.3735447.62efjlaq/opencode/cbdb-install/lib/postgresql/gp_svec.so
    #2  0x000055a9c90daaae in ExecInterpExpr ()
    #3  0x000055a9c9280558 in evaluate_expr ()
    #4  0x000055a9c9280da4 in simplify_function ()
    #5  0x000055a9c9281dad in eval_const_expressions_mutator ()
    #6  0x000055a9c9185714 in expression_tree_mutator_impl ()
    apache#7  0x000055a9c91864d2 in expression_tree_mutator_impl ()
    apache#8  0x000055a9c9282949 in eval_const_expressions ()
    apache#9  0x000055a9c925c918 in preprocess_expression.constprop ()
    #10 0x000055a9c9264954 in subquery_planner ()
    apache#11 0x000055a9c926557a in standard_planner ()
    apache#12 0x000055a9c9266064 in planner ()
    apache#13 0x000055a9c9367086 in pg_plan_query ()
    apache#14 0x000055a9c9367183 in pg_plan_queries ()
    apache#15 0x000055a9c94cfa73 in BuildCachedPlan ()
    apache#16 0x000055a9c94cfdc8 in GetCachedPlan ()
    apache#17 0x000055a9c907270b in ExecuteQuery ()
    apache#18 0x000055a9c9370313 in standard_ProcessUtility ()
    apache#19 0x000055a9c9370c5d in ProcessUtility ()
    apache#20 0x000055a9c936e183 in PortalRunUtility ()
    apache#21 0x000055a9c936e857 in FillPortalStore ()
    apache#22 0x000055a9c936ebad in PortalRun ()
    apache#23 0x000055a9c93678e0 in exec_simple_query ()
    apache#24 0x000055a9c936c104 in PostgresMain ()
    apache#25 0x000055a9c92b8004 in ServerLoop.isra.0 ()
    apache#26 0x000055a9c92b926a in PostmasterMain ()
    apache#27 0x000055a9c8e7a548 in main ()
    [Inferior 1 (process 395704) detached]

l2norm:

Triggering SQL as a non-superuser:

    SELECT sparse_vector.l2norm(NULL::float8[]);

Verbatim log from the pre-fix disposable Cloudberry 16.9 cluster:

    2026-12-01 12:19:45.412720 MSK,,,p229290,th123456,,,2026-12-01 12:19:45 MSK,0,,cmd1,seg-1,,,,,"PANIC","XX000","Unexpected internal error: Segment process received signal SIGSEGV",,,,,,,0,,,,
    2026-12-01 12:19:45.413579 MSK,,,p220887,th2071603008,,,,0,,,seg-1,,,,,"LOG","00000","server process (PID 229290) was terminated by signal 11: Segmentation fault","Failed process was running: SELECT sparse_vector.l2norm(NULL::float8[]);",,,,,,0,,"postmaster.c",4278,
    2026-12-01 12:19:45.413587 MSK,,,p220887,th2071603008,,,,0,,,seg-1,,,,,"LOG","00000","terminating any other active server processes",,,,,,,0,,"postmaster.c",4071,
    2026-12-01 12:19:45.414588 MSK,,,p220887,th2071603008,,,,0,,,seg-1,,,,,"LOG","00000","all server processes terminated; reinitializing",,,,,,,0,,"postmaster.c",4551,

Backtrace captured with gdb on the pre-fix backend:

    #0  0x000055b0ed991ca4 in pg_detoast_datum ()
    #1  0x00007f8e49aa4a64 in float8arr_l2norm ()
       from /home/reshke/.ya/tmp/1795466526.3735447.62efjlaq/opencode/cbdb-install/lib/postgresql/gp_svec.so
    #2  0x000055b0ed56faae in ExecInterpExpr ()
    #3  0x000055b0ed715558 in evaluate_expr ()
    #4  0x000055b0ed715da4 in simplify_function ()
    #5  0x000055b0ed716dad in eval_const_expressions_mutator ()
    #6  0x000055b0ed61a714 in expression_tree_mutator_impl ()
    apache#7  0x000055b0ed61b4d2 in expression_tree_mutator_impl ()
    apache#8  0x000055b0ed717949 in eval_const_expressions ()
    apache#9  0x000055b0ed6f1918 in preprocess_expression.constprop ()
    #10 0x000055b0ed6f9954 in subquery_planner ()
    apache#11 0x000055b0ed6fa57a in standard_planner ()
    apache#12 0x000055b0ed6fb064 in planner ()
    apache#13 0x000055b0ed7fc086 in pg_plan_query ()
    apache#14 0x000055b0ed7fc183 in pg_plan_queries ()
    apache#15 0x000055b0ed7fcb77 in exec_simple_query ()
    apache#16 0x000055b0ed801104 in PostgresMain ()
    apache#17 0x000055b0ed74d004 in ServerLoop.isra.0 ()
    apache#18 0x000055b0ed74e26a in PostmasterMain ()
    apache#19 0x000055b0ed30f548 in main ()

After applying the catalog change in the disposable cluster, the same
non-superuser SQL returned NULL and a following SELECT 1 succeeded.

unnest:

Reproducer before the fix, run as non-superuser sqltester:

    SELECT * FROM sparse_vector.unnest(NULL::sparse_vector.svec);

Verbatim backend log before the fix:

    2026-12-01 12:27:30.062505 MSK,,,p363547,th123456,,,2026-12-01 12:26:04 MSK,0,,cmd4,seg-1,,,,,"PANIC","XX000","Unexpected internal error: Segment process received signal SIGSEGV",,,,,,,0,,,,
    2026-12-01 12:27:50.458365 MSK,,,p354590,th-73722048,,,,0,,,seg-1,,,,,"LOG","00000","server process (PID 363547) was terminated by signal 11: Segmentation fault","Failed process was running: SELECT * FROM sparse_vector.unnest(NULL::sparse_vector.svec);",,,,,,0,,"postmaster.c",4278,
    2026-12-01 12:27:50.458393 MSK,,,p354590,th-73722048,,,,0,,,seg-1,,,,,"LOG","00000","terminating any other active server processes",,,,,,,0,,"postmaster.c",4071,
    2026-12-01 12:27:50.459466 MSK,,,p354590,th-73722048,,,,0,,,seg-1,,,,,"LOG","00000","all server processes terminated; reinitializing",,,,,,,0,,"postmaster.c",4551,

GDB backtrace at SIGSEGV:

    #0  0x00005611c942eca4 in pg_detoast_datum ()
    #1  0x00007f54efdab31a in svec_unnest () from /home/reshke/.ya/tmp/1795466526.3735447.62efjlaq/opencode/cbdb-install/lib/postgresql/gp_svec.so
    #2  0x00005611c901de14 in ExecMakeTableFunctionResult ()
    #3  0x00005611c9034ec6 in FunctionNext ()
    #4  0x00005611c901ab72 in ExecProcNodeFirst ()
    #5  0x00005611c9010cda in ExecutePlan ()
    #6  0x00005611c9011adb in standard_ExecutorRun ()
    apache#7  0x00005611c9011ce5 in ExecutorRun ()
    apache#8  0x00005611c929ed3a in PortalRunSelect ()
    apache#9  0x00005611c92a0afa in PortalRun ()
    #10 0x00005611c92998e0 in exec_simple_query ()
    apache#11 0x00005611c929e104 in PostgresMain ()
    apache#12 0x00005611c91ea004 in ServerLoop.isra.0 ()
    apache#13 0x00005611c91eb26a in PostmasterMain ()
    apache#14 0x00005611c8dac548 in main ()

Tests: added the exact SQL case to gp_svec and upgrade coverage for 1.0.1 ->
1.0.2 and 1.0.2 -> 1.0.3. In a disposable cluster, after applying STRICT,
the same query returned zero rows and the backend stayed available. The full
multi-segment installcheck suite was not run in the utility-mode test cluster.
reshke added a commit to reshke/cloudberrydb that referenced this pull request Dec 1, 2026
Mark float8arr_eq STRICT so SQL NULL arguments are handled by the executor
before the C implementation dereferences them. Add a 1.0.3 upgrade path for
existing installations, correct fresh-install scripts, and add NULL regression
coverage for installation and upgrades from 1.0.1 and 1.0.2.

SQL reproduction as a non-superuser before the fix:

    SELECT sparse_vector.float8arr_eq(NULL::float8[], ARRAY[1]::float8[]);

For the backtrace run, the same call was executed through this prepared
statement:

    PREPARE q(float8[], float8[]) AS
        SELECT sparse_vector.float8arr_eq($1, $2);
    EXECUTE q(NULL::float8[], ARRAY[1]::float8[]);

Verbatim server log:

    2026-12-01 12:28:32.427106 MSK,,,p395704,th123456,,,2026-12-01 12:27:33 MSK,0,,cmd4,seg-1,,,,,"PANIC","XX000","Unexpected internal error: Segment process received signal SIGSEGV",,,,,,,0,,,,
    2026-12-01 12:28:32.427211 MSK,,,p263623,th-153823424,,,,0,,,seg-1,,,,,"LOG","00000","server process (PID 395704) was terminated by signal 11: Segmentation fault","Failed process was running: EXECUTE q(NULL::float8[], ARRAY[1]::float8[]);",,,,,,0,,"postmaster.c",4278,
    2026-12-01 12:28:32.427218 MSK,,,p263623,th-153823424,,,,0,,,seg-1,,,,,"LOG","00000","terminating any other active server processes",,,,,,,0,,"postmaster.c",4071,
    2026-12-01 12:28:32.428219 MSK,"sqltester","postgres",p415572,th-153823424,"[local]",,2026-12-01 12:28:32 MSK,0,,,seg-1,,,,sx1,"FATAL","57P03","the database system is resetting",,,,,,,0,,"postmaster.c",2833,
    2026-12-01 12:28:32.428731 MSK,,,p263623,th-153823424,,,,0,,,seg-1,,,,,"LOG","00000","all server processes terminated; reinitializing",,,,,,,0,,"postmaster.c",4551,

Verbatim gdb backtrace:

    Program received signal SIGSEGV, Segmentation fault.
    0x000055a9c94fcca4 in pg_detoast_datum ()
    #0  0x000055a9c94fcca4 in pg_detoast_datum ()
    #1  0x00007f02eb0727c2 in float8arr_equals () from /home/reshke/.ya/tmp/1795466526.3735447.62efjlaq/opencode/cbdb-install/lib/postgresql/gp_svec.so
    #2  0x000055a9c90daaae in ExecInterpExpr ()
    #3  0x000055a9c9280558 in evaluate_expr ()
    #4  0x000055a9c9280da4 in simplify_function ()
    #5  0x000055a9c9281dad in eval_const_expressions_mutator ()
    #6  0x000055a9c9185714 in expression_tree_mutator_impl ()
    apache#7  0x000055a9c91864d2 in expression_tree_mutator_impl ()
    apache#8  0x000055a9c9282949 in eval_const_expressions ()
    apache#9  0x000055a9c925c918 in preprocess_expression.constprop ()
    #10 0x000055a9c9264954 in subquery_planner ()
    apache#11 0x000055a9c926557a in standard_planner ()
    apache#12 0x000055a9c9266064 in planner ()
    apache#13 0x000055a9c9367086 in pg_plan_query ()
    apache#14 0x000055a9c9367183 in pg_plan_queries ()
    apache#15 0x000055a9c94cfa73 in BuildCachedPlan ()
    apache#16 0x000055a9c94cfdc8 in GetCachedPlan ()
    apache#17 0x000055a9c907270b in ExecuteQuery ()
    apache#18 0x000055a9c9370313 in standard_ProcessUtility ()
    apache#19 0x000055a9c9370c5d in ProcessUtility ()
    apache#20 0x000055a9c936e183 in PortalRunUtility ()
    apache#21 0x000055a9c936e857 in FillPortalStore ()
    apache#22 0x000055a9c936ebad in PortalRun ()
    apache#23 0x000055a9c93678e0 in exec_simple_query ()
    apache#24 0x000055a9c936c104 in PostgresMain ()
    apache#25 0x000055a9c92b8004 in ServerLoop.isra.0 ()
    apache#26 0x000055a9c92b926a in PostmasterMain ()
    apache#27 0x000055a9c8e7a548 in main ()
    [Inferior 1 (process 395704) detached]
reshke added a commit to reshke/cloudberrydb that referenced this pull request Dec 1, 2026
Mark float8arr_eq(float8[], float8[]), l2norm(float8[]), and unnest(svec)
STRICT so whole-argument SQL NULLs are handled before their C entry points.
Update install scripts and version migrations, plus fresh-install and upgrade
regression coverage. Keep the 1.0.2 default install script and provide a small
explicit 1.0.2-to-1.0.3 migration, avoiding a copied full 1.0.3 install file.

SQL reproductions and pre-fix evidence
=======================================

float8arr_eq:

SQL reproduction as a non-superuser before the fix:

    SELECT sparse_vector.float8arr_eq(NULL::float8[], ARRAY[1]::float8[]);

For the backtrace run, the same call was executed through this prepared
statement:

    PREPARE q(float8[], float8[]) AS
        SELECT sparse_vector.float8arr_eq($1, $2);
    EXECUTE q(NULL::float8[], ARRAY[1]::float8[]);

Verbatim server log:

    2026-12-01 12:28:32.427106 MSK,,,p395704,th123456,,,2026-12-01 12:27:33 MSK,0,,cmd4,seg-1,,,,,"PANIC","XX000","Unexpected internal error: Segment process received signal SIGSEGV",,,,,,,0,,,,
    2026-12-01 12:28:32.427211 MSK,,,p263623,th-153823424,,,,0,,,seg-1,,,,,"LOG","00000","server process (PID 395704) was terminated by signal 11: Segmentation fault","Failed process was running: EXECUTE q(NULL::float8[], ARRAY[1]::float8[]);",,,,,,0,,"postmaster.c",4278,
    2026-12-01 12:28:32.427218 MSK,,,p263623,th-153823424,,,,0,,,seg-1,,,,,"LOG","00000","terminating any other active server processes",,,,,,,0,,"postmaster.c",4071,
    2026-12-01 12:28:32.428219 MSK,"sqltester","postgres",p415572,th-153823424,"[local]",,2026-12-01 12:28:32 MSK,0,,,seg-1,,,,sx1,"FATAL","57P03","the database system is resetting",,,,,,,0,,"postmaster.c",2833,
    2026-12-01 12:28:32.428731 MSK,,,p263623,th-153823424,,,,0,,,seg-1,,,,,"LOG","00000","all server processes terminated; reinitializing",,,,,,,0,,"postmaster.c",4551,

Verbatim gdb backtrace:

    Program received signal SIGSEGV, Segmentation fault.
    0x000055a9c94fcca4 in pg_detoast_datum ()
    #0  0x000055a9c94fcca4 in pg_detoast_datum ()
    #1  0x00007f02eb0727c2 in float8arr_equals () from /home/reshke/.ya/tmp/1795466526.3735447.62efjlaq/opencode/cbdb-install/lib/postgresql/gp_svec.so
    #2  0x000055a9c90daaae in ExecInterpExpr ()
    #3  0x000055a9c9280558 in evaluate_expr ()
    #4  0x000055a9c9280da4 in simplify_function ()
    #5  0x000055a9c9281dad in eval_const_expressions_mutator ()
    #6  0x000055a9c9185714 in expression_tree_mutator_impl ()
    apache#7  0x000055a9c91864d2 in expression_tree_mutator_impl ()
    apache#8  0x000055a9c9282949 in eval_const_expressions ()
    apache#9  0x000055a9c925c918 in preprocess_expression.constprop ()
    #10 0x000055a9c9264954 in subquery_planner ()
    apache#11 0x000055a9c926557a in standard_planner ()
    apache#12 0x000055a9c9266064 in planner ()
    apache#13 0x000055a9c9367086 in pg_plan_query ()
    apache#14 0x000055a9c9367183 in pg_plan_queries ()
    apache#15 0x000055a9c94cfa73 in BuildCachedPlan ()
    apache#16 0x000055a9c94cfdc8 in GetCachedPlan ()
    apache#17 0x000055a9c907270b in ExecuteQuery ()
    apache#18 0x000055a9c9370313 in standard_ProcessUtility ()
    apache#19 0x000055a9c9370c5d in ProcessUtility ()
    apache#20 0x000055a9c936e183 in PortalRunUtility ()
    apache#21 0x000055a9c936e857 in FillPortalStore ()
    apache#22 0x000055a9c936ebad in PortalRun ()
    apache#23 0x000055a9c93678e0 in exec_simple_query ()
    apache#24 0x000055a9c936c104 in PostgresMain ()
    apache#25 0x000055a9c92b8004 in ServerLoop.isra.0 ()
    apache#26 0x000055a9c92b926a in PostmasterMain ()
    apache#27 0x000055a9c8e7a548 in main ()
    [Inferior 1 (process 395704) detached]

l2norm:

Triggering SQL as a non-superuser:

    SELECT sparse_vector.l2norm(NULL::float8[]);

Verbatim log from the pre-fix disposable Cloudberry 16.9 cluster:

    2026-12-01 12:19:45.412720 MSK,,,p229290,th123456,,,2026-12-01 12:19:45 MSK,0,,cmd1,seg-1,,,,,"PANIC","XX000","Unexpected internal error: Segment process received signal SIGSEGV",,,,,,,0,,,,
    2026-12-01 12:19:45.413579 MSK,,,p220887,th2071603008,,,,0,,,seg-1,,,,,"LOG","00000","server process (PID 229290) was terminated by signal 11: Segmentation fault","Failed process was running: SELECT sparse_vector.l2norm(NULL::float8[]);",,,,,,0,,"postmaster.c",4278,
    2026-12-01 12:19:45.413587 MSK,,,p220887,th2071603008,,,,0,,,seg-1,,,,,"LOG","00000","terminating any other active server processes",,,,,,,0,,"postmaster.c",4071,
    2026-12-01 12:19:45.414588 MSK,,,p220887,th2071603008,,,,0,,,seg-1,,,,,"LOG","00000","all server processes terminated; reinitializing",,,,,,,0,,"postmaster.c",4551,

Backtrace captured with gdb on the pre-fix backend:

    #0  0x000055b0ed991ca4 in pg_detoast_datum ()
    #1  0x00007f8e49aa4a64 in float8arr_l2norm ()
       from /home/reshke/.ya/tmp/1795466526.3735447.62efjlaq/opencode/cbdb-install/lib/postgresql/gp_svec.so
    #2  0x000055b0ed56faae in ExecInterpExpr ()
    #3  0x000055b0ed715558 in evaluate_expr ()
    #4  0x000055b0ed715da4 in simplify_function ()
    #5  0x000055b0ed716dad in eval_const_expressions_mutator ()
    #6  0x000055b0ed61a714 in expression_tree_mutator_impl ()
    apache#7  0x000055b0ed61b4d2 in expression_tree_mutator_impl ()
    apache#8  0x000055b0ed717949 in eval_const_expressions ()
    apache#9  0x000055b0ed6f1918 in preprocess_expression.constprop ()
    #10 0x000055b0ed6f9954 in subquery_planner ()
    apache#11 0x000055b0ed6fa57a in standard_planner ()
    apache#12 0x000055b0ed6fb064 in planner ()
    apache#13 0x000055b0ed7fc086 in pg_plan_query ()
    apache#14 0x000055b0ed7fc183 in pg_plan_queries ()
    apache#15 0x000055b0ed7fcb77 in exec_simple_query ()
    apache#16 0x000055b0ed801104 in PostgresMain ()
    apache#17 0x000055b0ed74d004 in ServerLoop.isra.0 ()
    apache#18 0x000055b0ed74e26a in PostmasterMain ()
    apache#19 0x000055b0ed30f548 in main ()

After applying the catalog change in the disposable cluster, the same
non-superuser SQL returned NULL and a following SELECT 1 succeeded.

unnest:

Reproducer before the fix, run as non-superuser sqltester:

    SELECT * FROM sparse_vector.unnest(NULL::sparse_vector.svec);

Verbatim backend log before the fix:

    2026-12-01 12:27:30.062505 MSK,,,p363547,th123456,,,2026-12-01 12:26:04 MSK,0,,cmd4,seg-1,,,,,"PANIC","XX000","Unexpected internal error: Segment process received signal SIGSEGV",,,,,,,0,,,,
    2026-12-01 12:27:50.458365 MSK,,,p354590,th-73722048,,,,0,,,seg-1,,,,,"LOG","00000","server process (PID 363547) was terminated by signal 11: Segmentation fault","Failed process was running: SELECT * FROM sparse_vector.unnest(NULL::sparse_vector.svec);",,,,,,0,,"postmaster.c",4278,
    2026-12-01 12:27:50.458393 MSK,,,p354590,th-73722048,,,,0,,,seg-1,,,,,"LOG","00000","terminating any other active server processes",,,,,,,0,,"postmaster.c",4071,
    2026-12-01 12:27:50.459466 MSK,,,p354590,th-73722048,,,,0,,,seg-1,,,,,"LOG","00000","all server processes terminated; reinitializing",,,,,,,0,,"postmaster.c",4551,

GDB backtrace at SIGSEGV:

    #0  0x00005611c942eca4 in pg_detoast_datum ()
    #1  0x00007f54efdab31a in svec_unnest () from /home/reshke/.ya/tmp/1795466526.3735447.62efjlaq/opencode/cbdb-install/lib/postgresql/gp_svec.so
    #2  0x00005611c901de14 in ExecMakeTableFunctionResult ()
    #3  0x00005611c9034ec6 in FunctionNext ()
    #4  0x00005611c901ab72 in ExecProcNodeFirst ()
    #5  0x00005611c9010cda in ExecutePlan ()
    #6  0x00005611c9011adb in standard_ExecutorRun ()
    apache#7  0x00005611c9011ce5 in ExecutorRun ()
    apache#8  0x00005611c929ed3a in PortalRunSelect ()
    apache#9  0x00005611c92a0afa in PortalRun ()
    #10 0x00005611c92998e0 in exec_simple_query ()
    apache#11 0x00005611c929e104 in PostgresMain ()
    apache#12 0x00005611c91ea004 in ServerLoop.isra.0 ()
    apache#13 0x00005611c91eb26a in PostmasterMain ()
    apache#14 0x00005611c8dac548 in main ()

Tests: added the exact SQL case to gp_svec and upgrade coverage for 1.0.1 ->
1.0.2 and 1.0.2 -> 1.0.3. In a disposable cluster, after applying STRICT,
the same query returned zero rows and the backend stayed available. The full
multi-segment installcheck suite was not run in the utility-mode test cluster.
reshke added a commit to reshke/cloudberrydb that referenced this pull request Dec 3, 2026
FigureColnameInternal recursively walks a raw expression while
CREATE INDEX derives the preliminary index column name. This happens
before transformExpr() applies its stack-depth protection, so a deep cast
chain can exhaust the backend stack. Check stack depth on every recursive
visit and reject the expression with stack_depth_limit_exceeded.

Add a create_index regression that dynamically builds the deep expression,
so the source tree does not contain a megabyte-scale SQL statement.

SQL-reachable SIGSEGV: CREATE INDEX expression cast chain

The query is executable by the ordinary table owner. The test role sqlsmith_probe has rolsuper=false and owns schema index_hunt and table index_hunt.idx_t. It created a short index successfully with the same role.

Setup SQL:
CREATE SCHEMA index_hunt AUTHORIZATION sqlsmith_probe;
CREATE TABLE index_hunt.idx_t(a integer) DISTRIBUTED RANDOMLY;

Reproducer SQL: execute as sqlsmith_probe; N=270000:
CREATE INDEX idx_t_cast_270k ON index_hunt.idx_t ((a::int::int::...::int));

Generate the exact SQL with:
python3 - <<'PY'
n = 270000
expr = 'a' + '::int' * n
print('CREATE INDEX idx_t_cast_270k ON index_hunt.idx_t ((' + expr + '));')
PY

The grammar builds a left-deep TypeCast tree. CREATE INDEX reaches FigureIndexColname()/FigureColnameInternal before transformExpr(). The backend SIGSEGVs in FigureColnameInternal.constprop.0. GDB reports roughly 261k recursive frames at the 500k repro; 270k also crashes.

GDB bt (top frames):
#0  0x000055bcff76594f in FigureColnameInternal.constprop.0 ()
#1  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
#2  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
#3  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
#4  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
#5  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
#6  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#7  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#8  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#9  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
#10 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#11 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#12 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#13 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#14 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#15 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#16 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#17 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#18 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#19 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
(More stack frames follow...)
Warning: 'set logging off', an alias for the command 'set logging enabled', is deprecated.
Use 'set logging enabled off'.

Verbatim coordinator postmaster log:
2026-12-03 16:06:52.845238 MSK,,,p1484041,th1997600576,,,,0,,,seg-1,,,,,"LOG","00000","server process (PID 2111634) was terminated by signal 11: Segmentation fault","Failed process was running: CREATE INDEX idx_t_cast_270k ON index_hunt.idx_t ((a::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int:",,,,,,0,,"postmaster.c",4278,
reshke added a commit to reshke/cloudberrydb that referenced this pull request Dec 3, 2026
FigureColnameInternal recursively walks a raw expression while
CREATE INDEX derives the preliminary index column name. This happens
before transformExpr() applies its stack-depth protection, so a deep cast
chain can exhaust the backend stack. Check stack depth on every recursive
visit and reject the expression with stack_depth_limit_exceeded.

Add a create_index regression that dynamically builds the deep expression,
so the source tree does not contain a megabyte-scale SQL statement.

SQL-reachable SIGSEGV: CREATE INDEX expression cast chain

The query is executable by the ordinary table owner. The test role sqlsmith_probe has rolsuper=false and owns schema index_hunt and table index_hunt.idx_t. It created a short index successfully with the same role.

Setup SQL:
CREATE SCHEMA index_hunt AUTHORIZATION sqlsmith_probe;
CREATE TABLE index_hunt.idx_t(a integer) DISTRIBUTED RANDOMLY;

Reproducer SQL: execute as sqlsmith_probe; N=270000:
CREATE INDEX idx_t_cast_270k ON index_hunt.idx_t ((a::int::int::...::int));

Generate the exact SQL with:
python3 - <<'PY'
n = 270000
expr = 'a' + '::int' * n
print('CREATE INDEX idx_t_cast_270k ON index_hunt.idx_t ((' + expr + '));')
PY

The grammar builds a left-deep TypeCast tree. CREATE INDEX reaches FigureIndexColname()/FigureColnameInternal before transformExpr(). The backend SIGSEGVs in FigureColnameInternal.constprop.0. GDB reports roughly 261k recursive frames at the 500k repro; 270k also crashes.

GDB bt (top frames):
#0  0x000055bcff76594f in FigureColnameInternal.constprop.0 ()
#1  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
#2  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
#3  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
#4  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
#5  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
#6  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#7  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#8  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#9  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
#10 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#11 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#12 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#13 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#14 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#15 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#16 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#17 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#18 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#19 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
(More stack frames follow...)
Warning: 'set logging off', an alias for the command 'set logging enabled', is deprecated.
Use 'set logging enabled off'.

Verbatim coordinator postmaster log:
2026-12-03 16:06:52.845238 MSK,,,p1484041,th1997600576,,,,0,,,seg-1,,,,,"LOG","00000","server process (PID 2111634) was terminated by signal 11: Segmentation fault","Failed process was running: CREATE INDEX idx_t_cast_270k ON index_hunt.idx_t ((a::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int:",,,,,,0,,"postmaster.c",4278,
reshke added a commit to reshke/cloudberrydb that referenced this pull request Dec 3, 2026
FigureColnameInternal recursively walks a raw expression while
CREATE INDEX derives the preliminary index column name. This happens
before transformExpr() applies its stack-depth protection, so a deep cast
chain can exhaust the backend stack. Check stack depth on every recursive
visit and reject the expression with stack_depth_limit_exceeded.

Add a create_index regression that dynamically builds the deep expression,
so the source tree does not contain a megabyte-scale SQL statement.

SQL-reachable SIGSEGV: CREATE INDEX expression cast chain

The query is executable by the ordinary table owner. The test role sqlsmith_probe has rolsuper=false and owns schema index_hunt and table index_hunt.idx_t. It created a short index successfully with the same role.

Setup SQL:
CREATE SCHEMA index_hunt AUTHORIZATION sqlsmith_probe;
CREATE TABLE index_hunt.idx_t(a integer) DISTRIBUTED RANDOMLY;

Reproducer SQL: execute as sqlsmith_probe; N=270000:
CREATE INDEX idx_t_cast_270k ON index_hunt.idx_t ((a::int::int::...::int));

Generate the exact SQL with:
python3 - <<'PY'
n = 270000
expr = 'a' + '::int' * n
print('CREATE INDEX idx_t_cast_270k ON index_hunt.idx_t ((' + expr + '));')
PY

The grammar builds a left-deep TypeCast tree. CREATE INDEX reaches FigureIndexColname()/FigureColnameInternal before transformExpr(). The backend SIGSEGVs in FigureColnameInternal.constprop.0. GDB reports roughly 261k recursive frames at the 500k repro; 270k also crashes.

GDB bt (top frames):
#0  0x000055bcff76594f in FigureColnameInternal.constprop.0 ()
#1  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
#2  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
#3  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
#4  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
#5  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
#6  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#7  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#8  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#9  0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
#10 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#11 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#12 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#13 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#14 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#15 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#16 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#17 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#18 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
apache#19 0x000055bcff765959 in FigureColnameInternal.constprop.0 ()
(More stack frames follow...)
Warning: 'set logging off', an alias for the command 'set logging enabled', is deprecated.
Use 'set logging enabled off'.

Verbatim coordinator postmaster log:
2026-12-03 16:06:52.845238 MSK,,,p1484041,th1997600576,,,,0,,,seg-1,,,,,"LOG","00000","server process (PID 2111634) was terminated by signal 11: Segmentation fault","Failed process was running: CREATE INDEX idx_t_cast_270k ON index_hunt.idx_t ((a::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int::int:",,,,,,0,,"postmaster.c",4278,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority: Medium This issue may be useful, and needs some attention. type: Pipeline

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants