You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

启用shared_preload_libraries后PostgreSQL 15.1持续重启求助

PostgreSQL 15.x/14.4在CentOS7 32位下启用citus预加载库后频繁重启

问题现象

在CentOS7 32位架构下,通过Python守护进程运行PostgreSQL 15.1,未设置shared_preload_libraries时服务运行正常;但执行ALTER SYSTEM SET shared_preload_libraries='citus'启用citus扩展后,PostgreSQL每隔几秒就会自动重启。此前使用PostgreSQL 9.6.4搭配citus无此问题,测试PostgreSQL 15.0、14.4均出现相同故障。

环境说明

  • 系统:CentOS7 32位
  • PostgreSQL版本:15.1/15.0/14.4(基于openssl-1.1.1i源码编译)
  • 扩展:citus(基于对应PostgreSQL版本从源码编译生成citus.so)
  • 启动方式:Python编写的守护进程

相关日志

初始故障日志

waiting for server to start....2023-02-15 07:13:45.676 GMT [28605] LOG:  skipping missing configuration file "/home/runtime/pgsql/data/postgresql.auto.conf"
2023-02-15 07:13:45.825 GMT [28605] LOG:  starting PostgreSQL 15.1 on i686-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 32-bit
2023-02-15 07:13:45.825 GMT [28605] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2023-02-15 07:13:45.933 GMT [28605] LOG:  listening on Unix socket "/home/runtime/pgsql/.s.PGSQL.5432"
2023-02-15 07:13:45.969 GMT [28608] LOG:  database system was shut down at 2023-02-15 07:13:35 GMT
2023-02-15 07:13:45.989 GMT [28605] LOG:  database system is ready to accept connections
 done
server started

ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
2023-02-15 07:13:51.480 GMT [28605] LOG:  received fast shutdown request
waiting for server to shut down....2023-02-15 07:13:51.512 GMT [28605] LOG:  aborting any active transactions
2023-02-15 07:13:51.513 GMT [28605] LOG:  background worker "logical replication launcher" (PID 28611) exited with exit code 1
2023-02-15 07:13:51.513 GMT [28606] LOG:  shutting down
2023-02-15 07:13:51.536 GMT [28606] LOG:  checkpoint starting: shutdown immediate
2023-02-15 07:13:51.908 GMT [28606] LOG:  checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.090 s, sync=0.028 s, total=0.395 s; sync files=2, longest=0.021 s, average=0.014 s; distance=0 kB, estimate=0 kB
2023-02-15 07:13:51.909 GMT [28605] LOG:  database system is shut down
 done
server stopped

重新编译citus后的循环重启日志

waiting for server to start....2023-02-23 09:18:17.826 GMT [18659] LOG:  skipping missing configuration file "/home/runtime/pgsql/data/postgresql.auto.conf"
2023-02-23 09:18:18.102 GMT [18659] LOG:  starting PostgreSQL 15.1 on i686-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 32-bit
2023-02-23 09:18:18.102 GMT [18659] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2023-02-23 09:18:18.183 GMT [18659] LOG:  listening on Unix socket "/home/runtime/pgsql/.s.PGSQL.5432"
2023-02-23 09:18:18.206 GMT [18662] LOG:  database system was shut down at 2023-02-23 09:18:07 GMT
2023-02-23 09:18:18.227 GMT [18659] LOG:  database system is ready to accept connections
 done
server started
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
waiting for server to shut down....2023-02-23 09:18:23.510 GMT [18659] LOG:  received fast shutdown request
2023-02-23 09:18:23.542 GMT [18659] LOG:  aborting any active transactions
2023-02-23 09:18:23.543 GMT [18659] LOG:  background worker "logical replication launcher" (PID 18665) exited with exit code 1
2023-02-23 09:18:23.543 GMT [18660] LOG:  shutting down
2023-02-23 09:18:23.587 GMT [18660] LOG:  checkpoint starting: shutdown immediate
2023-02-23 09:18:23.787 GMT [18660] LOG:  checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.054 s, sync=0.047 s, total=0.244 s; sync files=2, longest=0.025 s, average=0.024 s; distance=0 kB, estimate=0 kB
2023-02-23 09:18:23.788 GMT [18659] LOG:  database system is shut down
 done
server stopped
waiting for server to start....2023-02-23 09:18:34.158 GMT [18824] LOG:  skipping missing configuration file "/home/runtime/pgsql/data/postgresql.auto.conf"
2023-02-23 09:18:34.228 GMT [18824] LOG:  starting PostgreSQL 15.1 on i686-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 32-bit
2023-02-23 09:18:34.228 GMT [18824] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2023-02-23 09:18:34.297 GMT [18824] LOG:  listening on Unix socket "/home/runtime/pgsql/.s.PGSQL.5432"
2023-02-23 09:18:34.468 GMT [18827] LOG:  database system was shut down at 2023-02-23 09:18:23 GMT
2023-02-23 09:18:34.596 GMT [18824] LOG:  database system is ready to accept connections
 done
server started
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
waiting for server to shut down....2023-02-23 09:18:40.156 GMT [18824] LOG:  received fast shutdown request
2023-02-23 09:18:40.191 GMT [18824] LOG:  aborting any active transactions
2023-02-23 09:18:40.192 GMT [18824] LOG:  background worker "logical replication launcher" (PID 18830) exited with exit code 1
2023-02-23 09:18:40.192 GMT [18825] LOG:  shutting down
2023-02-23 09:18:40.238 GMT [18825] LOG:  checkpoint starting: shutdown immediate
2023-02-23 09:18:40.513 GMT [18825] LOG:  checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.040 s, sync=0.003 s, total=0.322 s; sync files=2, longest=0.002 s, average=0.002 s; distance=0 kB, estimate=0 kB
2023-02-23 09:18:40.514 GMT [18824] LOG:  database system is shut down
 done
server stopped
waiting for server to start....2023-02-23 09:18:50.904 GMT [18986] LOG:  skipping missing configuration file "/home/runtime/pgsql/data/postgresql.auto.conf"
2023-02-23 09:18:51.032 GMT [18986] LOG:  starting PostgreSQL 15.1 on i686-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 32-bit
2023-02-23 09:18:51.032 GMT [18986] LOG:  listening on IPv4 address "127.0.0.1", port 5432
2023-02-23 09:18:51.140 GMT [18986] LOG:  listening on Unix socket "/home/runtime/pgsql/.s.PGSQL.5432"
2023-02-23 09:18:51.376 GMT [18989] LOG:  database system was shut down at 2023-02-23 09:18:40 GMT
2023-02-23 09:18:51.517 GMT [18986] LOG:  database system is ready to accept connections
 done
server started
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
ALTER SYSTEM
waiting for server to shut down....2023-02-23 09:18:57.194 GMT [18986] LOG:  received fast shutdown request
2023-02-23 09:18:57.236 GMT [18986] LOG:  aborting any active transactions
2023-02-23 09:18:57.237 GMT [18986] LOG:  background worker "logical replication launcher" (PID 18993) exited with exit code 1
2023-02-23 09:18:57.237 GMT [18987] LOG:  shutting down
2023-02-23 09:18:57.550 GMT [18987] LOG:  checkpoint starting: shutdown immediate
2023-02-23 09:18:57.783 GMT [18987] LOG:  checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.007 s, sync=0.024 s, total=0.546 s; sync files=2, longest=0.021 s, average=0.012 s; distance=0 kB, estimate=0 kB
2023-02-23 09:18:57.785 GMT [18986] LOG:  database system is shut down
 done
server stopped

排查与解决方案建议

  • 检查守护进程逻辑:日志中重复出现ALTER SYSTEM执行记录,大概率是Python守护进程存在重复执行配置修改命令的逻辑,触发PostgreSQL因配置变更重启,形成循环。需检查守护进程代码,确认是否错误判定配置未生效、重复执行命令。
  • 排除守护进程干扰:直接用pg_ctl启动PostgreSQL,测试是否仍会重启,确认问题是否由守护进程逻辑导致。
  • 修复配置文件问题:日志显示启动时找不到postgresql.auto.conf,手动创建该文件并设置PostgreSQL运行用户的读写权限,避免ALTER SYSTEM无法保存配置,导致守护进程重复触发命令。
  • 验证citus兼容性:PostgreSQL 14+对32位系统支持弱化,citus可能未充分适配32位环境。检查citus编译参数是否与PostgreSQL一致,查看编译日志是否有警告;开启log_min_messages = debug1和log_statement = all,获取更详细的日志定位fast shutdown request来源。

内容的提问来源于stack exchange,提问作者Vishal Gupta

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.31 20:35:31