rapidloop / pgmetrics

Collect and display information and stats from a running PostgreSQL server
https://pgmetrics.io
Apache License 2.0
960 stars 65 forks source link

Crashes PSQL when table has high Partition Count #56

Open GEverding opened 1 year ago

GEverding commented 1 year ago

I've caused psql14 to crash multiple times trying to run pgmetrics with a hash partitioned table with 1024 partitions.

GEverding commented 1 year ago
2022-12-01 19:30:09 UTC [915447]: user=,db=,app=,client= LOG:  server process (PID 1350804) was terminated by signal 7: Bus error
2022-12-01 19:30:09 UTC [915447]: user=,db=,app=,client= DETAIL:  Failed process was running:
        SELECT
          current_database() AS db, schemaname, tablename, reltuples::bigint AS tups, relpages::bigint AS pages, otta,
          ROUND(CASE WHEN otta=0 OR sml.relpages=0 OR sml.relpages=otta THEN 0.0 ELSE sml.relpages/otta::numeric END,1) AS tbloat,
          CASE WHEN relpages < otta THEN 0 ELSE relpages::bigint - otta END AS wastedpages,
          CASE WHEN relpages < otta THEN 0 ELSE bs*(sml.relpages-otta)::bigint END AS wastedbytes,
          CASE WHEN relpages < otta THEN '0 bytes'::text ELSE (bs*(relpages-otta))::bigint::text || ' bytes' END AS wastedsize,
          iname, ituples::bigint AS itups, ipages::bigint AS ipages, iotta,
          ROUND(CASE WHEN iotta=0 OR ipages=0 OR ipages=iotta THEN 0.0 ELSE ipages/iotta::numeric END,1) AS ibloat,
          CASE WHEN ipages < iotta THEN 0 ELSE ipages::bigint - iotta END AS wastedipages,
          CASE WHEN ipages < iotta THEN 0 ELSE (bs*(ipages-iotta))::bigint END AS wastedibytes,
          CASE WHEN ipages < iotta THEN '0 bytes' ELSE (bs*(ipages-iotta))::bigint::text || ' bytes' END AS wastedisize,
          CASE WHEN relpages < ott
2022-12-01 19:30:09 UTC [915447]: user=,db=,app=,client= LOG:  terminating any other active server processes

Seems to be a common problem. I'm pretty sure pgwatch2 did something very similar

pashagolub commented 1 year ago

It's not a pgmetrics and it's not a pgwatch2. You have misconfigured instance. Check your settings and tune memory, especially huge_pages