Issue with bgworker, SPI and pgstat_report_stat - Mailing list pgsql-hackers

From Julien Rouhaud
Subject Issue with bgworker, SPI and pgstat_report_stat
Date
Msg-id 577E96DE.3010402@dalibo.com
Whole thread Raw
Responses Re: Issue with bgworker, SPI and pgstat_report_stat  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
Hello,

While investigating on a bloat issue with a colleague, we found that if
a bgworker executes some queries with SPI, the statistic changes will
never be reported, since pgstat_report_stat() is only called in regular
backends.

In our case, the bgworker is the only process inserting and deleting a
large amount of data on some tables, so the autovacuum never tried to do
any maintenance on these tables.

Should a bgworker modifing data have to call pgstat_report_stat() to
avoid this problem? I don't find any documentation suggesting it, and it
seems that worker_spi (used as a template for this bgworker and I
suppose a lot of other one) is also affected.

If yes, I think at least worker_spi should be fixed (patched attached).

Regards.

--
Julien Rouhaud
http://dalibo.com - http://dalibo.org

Attachment

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Bug in batch tuplesort memory CLUSTER case (9.6 only)
Next
From: Andres Freund
Date:
Subject: Re: Don't include MMAP DSM's transient files in basebackup