citus
citus copied to clipboard
[SEGFAULT] Querying distributed tables with window partition causes segmentation fault
Running the following SQL query always causes a segmentation fault in Citus 12 with Postgres 16:
CREATE TABLE gianluca_camp_test(
id BYTEA,
account_id BYTEA NOT NULL,
start_timestamp INT,
PRIMARY KEY(account_id, id)
);
SELECT create_distributed_table('gianluca_acc_test', 'id');
SELECT create_distributed_table('gianluca_camp_test', 'account_id');
INSERT INTO gianluca_acc_test VALUES ('\x5b3f8be2f3fd8f25cf402b46'),('\x5aafffc481d8c13b05606f03');
INSERT INTO gianluca_camp_test VALUES
('\x3b3f8be2f3fd8f25cf402123','\x5aafffc481d8c13b05606f03',10),
('\x3b3f8be2f3fd8f25cf402456','\x5b3f8be2f3fd8f25cf402b46',20),
('\x3b3f8be2f3fd8f25cf402789','\x5aafffc481d8c13b05606f03',NULL);
SELECT
DISTINCT "gianluca_acc_test"."id",
MAX("gianluca_camp_test"."start_timestamp") OVER (PARTITION BY "gianluca_camp_test"."id")
FROM
"gianluca_acc_test"
LEFT OUTER JOIN "gianluca_camp_test" ON "gianluca_acc_test"."id" = "gianluca_camp_test"."account_id"
WHERE
"gianluca_acc_test"."id" IN (
'\x5b3f8be2f3fd8f25cf402b46',
'\x5aafffc481d8c13b05606f03'
);
The query executes successfully if:
- The window partition is removed
- Only one of the 2 IDs is included in the filter
- Postgres 14 is used
- The tables are not distributed
- The join is removed, like so:
SELECT
DISTINCT "gianluca_camp_test"."account_id",
MAX("gianluca_camp_test"."start_timestamp") OVER (PARTITION BY "gianluca_camp_test"."id")
FROM
"gianluca_camp_test"
WHERE
"gianluca_camp_test"."account_id" IN (
'\x5b3f8be2f3fd8f25cf402b46',
'\x5aafffc481d8c13b05606f03'
);
Logs:
2024-10-15 08:13:43.555 UTC [8571] LOG: server process (PID 12396) was terminated by signal 11: Segmentation fault
2024-10-15 08:13:43.555 UTC [8571] DETAIL: Failed process was running: SELECT
DISTINCT "gianluca_acc_test"."id",
MAX("gianluca_camp_test"."start_timestamp") OVER (PARTITION BY encode("gianluca_camp_test"."id", 'hex'))
FROM
"gianluca_acc_test"
LEFT OUTER JOIN "gianluca_camp_test" ON "gianluca_acc_test"."id" = "gianluca_camp_test"."account_id"
WHERE
"gianluca_acc_test"."id" IN (
'\x5b3f8be2f3fd8f25cf402b46',
'\x5aafffc481d8c13b05606f03'
);
2024-10-15 08:13:43.555 UTC [8571] LOG: terminating any other active server processes
2024-10-15 08:13:43.556 UTC [12428] postgres@postgres FATAL: the database system is in recovery mode
2024-10-15 08:13:43.558 UTC [8571] LOG: all server processes terminated; reinitializing
2024-10-15 08:13:43.599 UTC [12429] LOG: database system was interrupted; last known up at 2024-10-15 08:09:03 UTC
2024-10-15 08:13:44.085 UTC [12429] LOG: database system was not properly shut down; automatic recovery in progress
2024-10-15 08:13:44.093 UTC [12429] LOG: redo starts at 0/21B52F0
2024-10-15 08:13:44.097 UTC [12429] LOG: invalid record length at 0/22BC3B0: expected at least 24, got 0
2024-10-15 08:13:44.097 UTC [12429] LOG: redo done at 0/22BC378 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s
2024-10-15 08:13:44.112 UTC [12430] LOG: checkpoint starting: end-of-recovery immediate wait
2024-10-15 08:13:44.223 UTC [12430] LOG: checkpoint complete: wrote 182 buffers (1.1%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.015 s, sync=0.069 s, total=0.120 s; sync files=154, longest=0.007 s, average=0.001 s; distance=1052 kB, estimate=1052 kB; lsn=0/22BC3B0, redo lsn=0/22BC3B0