Issue with bgworker, SPI and pgstat_report_stat

From: Julien Rouhaud <julien(dot)rouhaud(at)dalibo(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Marc Cousin <marc(dot)cousin(at)dalibo(dot)com>
Subject: Issue with bgworker, SPI and pgstat_report_stat
Date: 2016-07-07 17:52:30
Message-ID: 577E96DE.3010402@dalibo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Content-Type Size
worker_spi_report_stat-v1.diff text/x-diff 426 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2016-07-07 17:52:55 Re: Don't include MMAP DSM's transient files in basebackup
Previous Message Robert Haas 2016-07-07 17:51:46 Re: Bug in batch tuplesort memory CLUSTER case (9.6 only)