darold / pgbadger

A fast PostgreSQL Log Analyzer

Home Page:http://pgbadger.darold.net/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SQL generating TEMP not reported if failed

ncalero-uy opened this issue · comments

Hi, I found an issue where the database temp space was exhausted by an SQL, and the pgBadger report is not reporting the SQL causing the problem, despite the SQL is in the log.

In this case, the SQL failed with the error message "ERROR: could not write to file "file_name": No space left on device"

The overall statistics section correctly reports the temp space used and files - it only misses the SQL in the Queries section for temp. Like this:

# pgbadger -f logplex -T "Heroku TMP issue" -o ./badger-tmp.txt ./heroku-temp-error-20230703.log
[========================>] Parsed 69690 bytes of 69690 (100.00%), queries: 2, events: 8
LOG: Ok, generating txt report...

# cat badger-tmp.txt 
...
- Overall statistics ---------------------------------------------------

Number of unique normalized queries: 2
Number of queries: 2
Total query duration: 399ms
First query: 2023-07-03 07:32:00
Last query: 2023-07-03 07:35:47
Query peak: 1 queries/s at 2023-07-03 07:32:00
Number of events: 8
Number of unique normalized events: 4
Number temporary files: 90
Max size of temporary files: 23.13 GiB
Average size of temporary files: 765.80 MiB
Total number of databases: 2
...
- Queries generating the most temporary files (N) ---------------------------

Rank   Count   Total size    Min/Max/Avg size    Query

- Queries generating the largest temporary files ----------------------------

Rank   Size    Query


- Slowest queries -----
- ...

Attaching the PostgreSQL log file to reproduce the report. It is from a Heroku database.
heroku-temp-error-20230703.log

Hi, this is normal, the SQL query is associated to the error "no space left". Normally if there was enough disk space it would not end as error and should be associated to the temporary files generation. Anyway I have found several parsing error with logplex format, they have been fixed in commits d51444a and 5945104.