On 2021-Aug-17, alvherre@alvh.no-ip.org wrote:
> However, why do it in a WAL-producing client-connected backend? It
> strikes me as a bad thing to do, because you are possibly causing delays
> for client-connected backends. I suggest that we should give this task
> to the WAL writer process -- say, have XLogBackgroundFlush do it.
Reading the comments on walwriter.c I am hesitant of having walwriter do
it:
> * Because the walwriter's cycle is directly linked to the maximum delay
> * before async-commit transactions are guaranteed committed, it's probably
> * unwise to load additional functionality onto it. For instance, if you've
> * got a yen to create xlog segments further in advance, that'd be better done
> * in bgwriter than in walwriter.
So that comment suggests that we should give the responsibility to bgwriter.
This seems good enough to me. I suppose if bgwriter has a long run of
buffers to write it could take a little bit of time (a few hundred
milliseconds?) but I think that should be okay.
--
Álvaro Herrera 39°49'30"S 73°17'W — https://www.EnterpriseDB.com/
"No renuncies a nada. No te aferres a nada."