Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create extension postgis raises out of memory if pg_store_plans in installed #7

Open
danielwestermann opened this issue Aug 3, 2020 · 2 comments

Comments

@danielwestermann
Copy link

Hi,

on RedHat 7.7:

[root@rhel77 ~]# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.7 (Maipo)

... with this packages installed:

[root@rhel77 ~]# rpm -qa | egrep "postgres|postgis|store_plan"
postgresql12-server-12.3-5PGDG.rhel7.x86_64
postgresql12-contrib-12.3-5PGDG.rhel7.x86_64
postgresql12-12.3-5PGDG.rhel7.x86_64
postgis30_12-3.0.1-5.rhel7.x86_64
pg_store_plans12-1.4-1.el7.x86_64
postgresql12-libs-12.3-5PGDG.rhel7.x86_64
postgresql12-llvmjit-12.3-5PGDG.rhel7.x86_64

Once pg_store_plans is in shared_preload_libraries this does not work anymore:

-bash-4.2$ psql -p 5500
psql (12.3)
Type "help" for help.

postgres=# select version();
                                                 version                                                 
---------------------------------------------------------------------------------------------------------
 PostgreSQL 12.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39), 64-bit
(1 row)

postgres=# \dx
                                     List of installed extensions
        Name        | Version |   Schema   |                        Description                        
--------------------+---------+------------+-----------------------------------------------------------
 pg_buffercache     | 1.3     | public     | examine the shared buffer cache
 pg_stat_statements | 1.7     | public     | track execution statistics of all SQL statements executed
 pg_store_plans     | 1.4     | public     | track plan statistics of all SQL statements executed
 pgstattuple        | 1.5     | public     | show tuple-level statistics
 plpgsql            | 1.0     | pg_catalog | PL/pgSQL procedural language
(5 rows)

postgres=# show shared_preload_libraries ;
 shared_preload_libraries 
--------------------------
 pg_store_plans
(1 row)

postgres=# create extension postgis;
server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.

OOM kicks in and kills the process. Can someone please have a look at this?

Thanks in advance
Daniel

@kasaharatt
Copy link
Contributor

Hi.
Thanks for your report. I confirmed and could reproduce this problem.

When issue CREATE EXTENSION, pg_store_plans parses the query string for entire script per execute each query in the script. So, consume huge memory and killed by OOM-Killer.
This problem became apparent because the PostGIS script contains a lot of queries

Since the execution plans of the queries executed by CREATE/ALTER EXTENSION is not very important, we may want to ignore getting the execution plan of these operations.

I'll PR the patch to solve this problem.
Best regards,

@danielwestermann
Copy link
Author

danielwestermann commented Aug 7, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants