0

我正在使用 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_sfcgal
  • uuid-ossp
4

1 回答 1

0

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

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

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

于 2021-11-18T07:28:48.290 回答