【问题标题】:PostgreSQL crashing: terminating connection due to unexpected postmaster exitPostgreSQL 崩溃:由于 postmaster 意外退出而终止连接
【发布时间】:2021-12-28 22:57:59
【问题描述】:

我正在执行一项数据迁移任务,使用 Python 线程从 Python 运行 60 个并行进程。

过了一会儿,PG崩溃了,看PG日志文件的结尾:

2021-11-17 09:30:09.973 CET [19372] FATAL:  terminating connection due to unexpected postmaster exit
2021-11-17 09:30:09.973 CET [17944] FATAL:  terminating connection due to unexpected postmaster exit
2021-11-17 09:30:09.973 CET [16628] FATAL:  terminating connection due to unexpected postmaster exit
2021-11-17 09:30:09.973 CET [19508] FATAL:  terminating connection due to unexpected postmaster exit
2021-11-17 09:30:09.973 CET [21636] FATAL:  postmaster exited during a parallel transaction
2021-11-17 09:30:09.973 CET [21636] CONTEXT:  SQL statement "......"
    PL/pgSQL function swn.nearest_pgr_node(geometry,numeric) line 7 at SQL statement
    SQL statement "select swn.nearest_pgr_node(structure_end_geom, 2.0)"
    PL/pgSQL function swn.migrate_cable(character varying) line 316 at SQL statement
2021-11-17 09:30:09.973 CET [21636] STATEMENT:  select swn.migrate_cable('{F97554BF-59BA-44D6-9D70-DD9B6B5927EA}')
2021-11-17 09:30:09.973 CET [17944] FATAL:  could not duplicate handle for "Global/PostgreSQL.2398935412": Permission denied
2021-11-17 09:30:11.227 CET [14284] FATAL:  terminating connection due to unexpected postmaster exit

有没有人知道问题出在哪里?我在使用本地磁盘的物理 Windows 服务器上运行它。 PG 版本 14。

感谢您的任何意见。谷歌搜索问题没有给我任何有用的提示。

上面的SQL代码(“......”)是

2021-11-17 09:30:09.973 CET [21636] CONTEXT:  SQL statement "with ptest as
                (
                    (select the_geom as point, id as id
                    from swn.pni_route_vertices_pgr
                    where st_distance(the_geom, _point) < _dist)
                )
                SELECT
    
                  closest_route.id                      FROM ptest p1
                CROSS JOIN LATERAL 
                  (SELECT
                      id, 
                      st_closestpoint(p2.point, _point) as nearest_point,
                      ST_Distance(_point, p2.point) as dist
                      FROM ptest p2
                   ORDER BY _point <-> p2.point
                     LIMIT 1
                   ) AS closest_route
                   order by 1"
    PL/pgSQL function swn.nearest_pgr_node(geometry,numeric) line 7 at SQL statement
    SQL statement "select swn.nearest_pgr_node(structure_end_geom, 2.0)"
    PL/pgSQL function swn.migrate_cable(character varying) line 316 at SQL statement
2021-11-17 09:30:09.973 CET [21636] STATEMENT:  select swn.migrate_cable('{F97554BF-59BA-44D6-9D70-DD9B6B5927EA}') 

我浏览了我的 PG 日志文件以查找此错误,结果发现每次都在相同的代码上崩溃。

已安装扩展:

  • pg_routing
  • plpgsql
  • postgis
  • postgis_sfcgal
  • uuid-ossp

【问题讨论】:

  • 如果您在集群数据目录中创建一个名为 crashdumps 的子目录,它将在该文件夹下生成故障转储。它可以帮助确定崩溃的原因。
  • 我修正了问题的标题,以免激进的动物保护者在“终止连接”时冒犯。
  • 您从日志中排除了有趣的 SQL 语句。请添加缺少的信息并告诉我们安装了哪些扩展。
  • @LaurenzAlbe,我已经用其他信息更新了案例

标签: postgresql parallel-processing crash postgresql-14


【解决方案1】:

原因是postmaster,所有PostgreSQL进程的父进程,意外死亡。

为了进一步澄清,请检查是否有其他日志消息可以阐明该事件。您还应该查看内核日志以获取来自 OOM 杀手的消息。很多时候,此类事件是由系统内存不足引起的,而内存过量使用尚未停用(调整 vm.overcommit_memoryvm.overcommit_ratio!)。

我注意到您的查询使用的是 PostGIS,在处理复杂的几何图形时会消耗大量内存。减少 work_mem 和/或 shared_buffers 以避免内存不足。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-13
    • 2013-09-25
    • 2015-06-07
    • 2021-06-13
    • 1970-01-01
    • 2018-09-16
    相关资源
    最近更新 更多