BUG #17828: postgres_fdw leaks file descriptors on error and aborts aborted transaction in lack of fds - Mailing list pgsql-bugs
From | PG Bug reporting form |
---|---|
Subject | BUG #17828: postgres_fdw leaks file descriptors on error and aborts aborted transaction in lack of fds |
Date | |
Msg-id | 17828-122da8cba23236be@postgresql.org Whole thread Raw |
Responses |
Re: BUG #17828: postgres_fdw leaks file descriptors on error and aborts aborted transaction in lack of fds
|
List | pgsql-bugs |
The following bug has been logged on the website: Bug reference: 17828 Logged by: Alexander Lakhin Email address: exclusion@gmail.com PostgreSQL version: 15.2 Operating system: Ubuntu 22.04 Description: The following script: CREATE EXTENSION postgres_fdw; DO $d$ BEGIN EXECUTE $$CREATE SERVER loopback FOREIGN DATA WRAPPER postgres_fdw OPTIONS (dbname '$$||current_database()||$$', port '$$||current_setting('port')||$$', async_capable 'true' )$$; END; $d$; CREATE USER MAPPING FOR CURRENT_USER SERVER loopback; CREATE TABLE t(a int) PARTITION BY RANGE (a); CREATE TABLE pt1 (a int); INSERT INTO pt1 SELECT 1; CREATE FOREIGN TABLE fpt1 PARTITION OF t FOR VALUES FROM ( 0) TO (10) SERVER loopback OPTIONS (table_name 'pt1'); CREATE FOREIGN TABLE fpt2 PARTITION OF t FOR VALUES FROM (10) TO (20) SERVER loopback OPTIONS (table_name 'non_existent_table'); CREATE TABLE nt(a int); SELECT 'INSERT INTO nt SELECT * FROM t' FROM generate_series(1, 400) \gexec (assuming "ulimit -n" = 1024 and max_safe_fds / 3 = 329) invokes errors and an assertion failure: ... CONTEXT: remote SQL command: SELECT a FROM public.non_existent_table ERROR: relation "public.non_existent_table" does not exist CONTEXT: remote SQL command: SELECT a FROM public.non_existent_table ERROR: relation "public.non_existent_table" does not exist CONTEXT: remote SQL command: SELECT a FROM public.non_existent_table ERROR: epoll_create1 failed: Too many open files ERROR: epoll_create1 failed: Too many open files WARNING: AbortTransaction while in ABORT state server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. connection to server was lost ... Core was generated by `postgres: law regression [local] INSERT '. Program terminated with signal SIGABRT, Aborted. warning: Section `.reg-xstate/3229796' in core file too small. #0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=139748276750272) at ./nptl/pthread_kill.c:44 44 ./nptl/pthread_kill.c: No such file or directory. (gdb) bt #0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=139748276750272) at ./nptl/pthread_kill.c:44 #1 __pthread_kill_internal (signo=6, threadid=139748276750272) at ./nptl/pthread_kill.c:78 #2 __GI___pthread_kill (threadid=139748276750272, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 #3 0x00007f19adb0e476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #4 0x00007f19adaf47f3 in __GI_abort () at ./stdlib/abort.c:79 #5 0x000055f6436330b5 in ExceptionalCondition (conditionName=0x55f643c7b780 <str> "TransactionIdIsValid(proc->xid)", fileName=0x55f643c7e48c "procarray.c", lineNumber=683) at assert.c:66 #6 0x000055f642ae083c in ProcArrayEndTransaction (proc=0x7f19a9c1e160, latestXid=1060) at procarray.c:683 #7 0x000055f641180763 in AbortTransaction () at xact.c:2841 #8 0x000055f64118710f in AbortCurrentTransaction () at xact.c:3346 #9 0x000055f642c0f27a in PostgresMain (dbname=0x62900001b358 "regression", username=0x6250000020f8 "law") at postgres.c:4299 #10 0x000055f642765b37 in BackendRun (port=0x614000000240) at postmaster.c:4461 #11 0x000055f64275cd90 in BackendStartup (port=0x614000000240) at postmaster.c:4189 #12 0x000055f642756d01 in ServerLoop () at postmaster.c:1779 #13 0x000055f642753da3 in PostmasterMain (argc=3, argv=0x603000000670) at postmaster.c:1463 #14 0x000055f641f5a0fa in main (argc=3, argv=0x603000000670) at main.c:200 Here pgfdw_get_result() calls WaitLatchOrSocket() -> CreateWaitEventSet(), that fails due to a lack of file descriptors; as a result, AbortCurrentTransaction() called, that calls CallXactCallbacks() -> pgfdw_xact_callback() -> pgfdw_abort_cleanup() -> pgfdw_cancel_query() -> pgfdw_get_cleanup_result() -> WaitLatchOrSocket() -> CreateWaitEventSet(), that fails and AbortCurrentTransaction() called again...
pgsql-bugs by date: