yugabyte / yugabyte/yugabyte-db
[YSQL] segfault on select temp table returning in with clause
- Dominant language
- C
- Stars
- 10.5k
- Forks
- 1.3k
- PR merge metrics
- PR metrics pending
Description
Jira Link: [DB-18044](https://yugabyte.atlassian.net/browse/DB-18044)
### Description
```sql
CREATE TEMP TABLE tmp (i int);
WITH rows AS (
INSERT INTO tmp
SELECT 1
RETURNING 1
) SELECT 1;
```
causes segfault, traces:
```
#0 0x00007fd14b3aaacf in raise () from /lib64/libc.so.6
#1 0x00007fd14b37dea5 in abort () from /lib64/libc.so.6
#2 0x0000000000b67821 in ExceptionalCondition (conditionName=conditionName@entry=0xdbc5b0 "!TransactionIdIsValid(proc->xid)", errorType=errorType@entry=0xc6a4c0 "FailedAssertion", fileName=fileName@entry=0xdbbb10 "../../../../../../../src/postgres/src/backend/storage/ipc/procarray.c", lineNumber=lineNumber@entry=726) at ../../../../../../../src/postgres/src/backend/utils/error/assert.c:69
#3 0x00000000009b0432 in ProcArrayEndTransaction (proc=0x7fd133eb15c8, latestXid=latestXid@entry=0) at ../../../../../../../src/postgres/src/backend/storage/ipc/procarray.c:726
#4 0x00000000005b0a58 in CommitTransaction () at ../../../../../../../src/postgres/src/backend/access/transam/xact.c:2496
#5 0x00000000005b1c9f in CommitTransactionCommand () at ../../../../../../../src/postgres/src/backend/access/transam/xact.c:3409
#6 0x00000000009dccb9 in finish_xact_command () at ../../../../../../src/postgres/src/backend/tcop/postgres.c:2922
#7 0x00000000009e5063 in exec_simple_query (query_string=0x72e6bff06958 "WITH rows AS (", ' ' ...) at ../../../../../../src/postgres/src/backend/tcop/postgres.c:1400
#8 yb_exec_simple_query_impl (query_string=query_string@entry=0x72e6bff06958) at ../../../../../../src/postgres/src/backend/tcop/postgres.c:5669
#9 0x00000000009e270d in yb_exec_query_wrapper_one_attempt (exec_context=exec_context@entry=0x72e6bff06000, retry_data=retry_data@entry=0x7fffd95cd650, functor=functor@entry=0x9e4775 , functor_context=functor_context@entry=0x72e6bff06958, attempt=attempt@entry=0, retry=retry@entry=0x7fffd95cd60f) at ../../../../../../src/postgres/src/backend/tcop/postgres.c:5636
#10 0x00000000009e3781 in yb_exec_query_wrapper (exec_context=exec_context@entry=0x72e6bff06000, retry_data=retry_data@entry=0x7fffd95cd650, functor=functor@entry=0x9e4775 , functor_context=functor_context@entry=0x72e6bff06958) at ../../../../../../src/postgres/src/backend/tcop/postgres.c:5661
#11 0x00000000009e37d4 in yb_exec_simple_query (query_string=query_string@entry=0x72e6bff06958 "WITH rows AS (", ' ' ..., exec_context=exec_context@entry=0x72e6bff06000) at ../../../../../../src/postgres/src/backend/tcop/postgres.c:5685
#12 0x00000000009e6462 in PostgresMain (dbname=, username=) at ../../../../../../src/postgres/src/backend/tcop/postgres.c:6496
#13 0x000000000091e929 in BackendRun (port=0x72e6bff89c00) at ../../../../../../src/postgres/src/backend/postmaster/postmaster.c:4992
#14 BackendStartup (port=0x72e6bff89c00) at ../../../../../../src/postgres/src/backend/postmaster/postmaster.c:4698
#15 ServerLoop () at ../../../../../../src/postgres/src/backend/postmaster/postmaster.c:1905
#16 0x0000000000920f83 in PostmasterMain (argc=argc@entry=25, argv=argv@entry=0x72e6bfc14410) at ../../../../../../src/postgres/src/backend/postmaster/postmaster.c:1559
#17 0x00000000008478c6 in PostgresServerProcessMain (argc=25, argv=0x72e6bfc14410) at ../../../../../../src/postgres/src/backend/main/main.c:213
#18 0x0000000000846eae in main ()
```
```
#0 0x00007fd14b3aaacf in raise () from /lib64/libc.so.6
#1 0x00007fd14b37dea5 in abort () from /lib64/libc.so.6
#2 0x0000000000b67821 in ExceptionalCondition (conditionName=conditionName@entry=0xdbc488 "!TransactionIdIsValid(ProcGlobal->xids[myoff])", errorType=errorType@entry=0xc6a4c0 "FailedAssertion", fileName=fileName@entry=0xdbbb10 "../../../../../../../src/postgres/src/backend/storage/ipc/procarray.c", lineNumber=lineNumber@entry=627) at ../../../../../../../src/postgres/src/backend/utils/error/assert.c:69
#3 0x00000000009affaa in ProcArrayRemove (proc=proc@entry=0x7fd133eb15c8, latestXid=latestXid@entry=0) at ../../../../../../../src/postgres/src/backend/storage/ipc/procarray.c:627
#4 0x000000000091cb4a in CleanupKilledProcess (proc=0x7fd133eb15c8) at ../../../../../../src/postgres/src/backend/postmaster/postmaster.c:3761
#5 reaper (postgres_signal_arg=) at ../../../../../../src/postgres/src/backend/postmaster/postmaster.c:3306
#6
#7 0x00007fd14b48294b in select () from /lib64/libc.so.6
#8 0x000000000091e18f in ServerLoop () at ../../../../../../src/postgres/src/backend/postmaster/postmaster.c:1861
#9 0x0000000000920f83 in PostmasterMain (argc=argc@entry=25, argv=argv@entry=0x72e6bfc14410) at ../../../../../../src/postgres/src/backend/postmaster/postmaster.c:1559
#10 0x00000000008478c6 in PostgresServerProcessMain (argc=25, argv=0x72e6bfc14410) at ../../../../../../src/postgres/src/backend/main/main.c:213
#11 0x0000000000846eae in main ()
```
on master 10a4f93d015c744989fa29d7078bdea7b7ce1f50, almalinux 8, fastdebug, gcc11 build.
### Issue Type
kind/bug
### Warning: Please confirm that this issue does not contain any sensitive information
- [x] I confirm this issue does not contain any sensitive information.
[DB-18044]: https://yugabyte.atlassian.net/browse/DB-18044?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.