RE: Some shared memory chunks are allocated even if related processes won't start - Mailing list pgsql-hackers

From Hayato Kuroda (Fujitsu)
Subject RE: Some shared memory chunks are allocated even if related processes won't start
Date
Msg-id TYCPR01MB12077D982922BFD6FE8706758F5232@TYCPR01MB12077.jpnprd01.prod.outlook.com
Whole thread Raw
In response to Re: Some shared memory chunks are allocated even if related processes won't start  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
Responses Re: Some shared memory chunks are allocated even if related processes won't start
List pgsql-hackers
Dear Alvaro,

Thanks for giving comments!

> > While reading codes, I found that ApplyLauncherShmemInit() and
> > AutoVacuumShmemInit() are always called even if they would not be
> > launched.
> 
> Note that there are situations where the autovacuum launcher is started
> even though autovacuum is nominally turned off, and I suspect your
> proposal would break that.  IIRC this occurs when the Xid or multixact
> counters cross the max_freeze_age threshold.

Right. In GetNewTransactionId(), SetTransactionIdLimit() and some other places,
PMSIGNAL_START_AUTOVAC_LAUNCHER is sent to postmaster when the xid exceeds
autovacuum_freeze_max_age. This work has already been written in the doc [1]:

```
To ensure that this does not happen, autovacuum is invoked on any table that
might contain unfrozen rows with XIDs older than the age specified by the
configuration parameter autovacuum_freeze_max_age. (This will happen even
if autovacuum is disabled.)
```

This means that my first idea won't work well. Even if the postmaster does not
initially allocate shared memory, backends may request to start auto vacuum and
use the region. However, the second idea is still valid, which allows the allocation
of shared memory dynamically. This is a bit efficient for the system which tuples
won't be frozen. Thought?

[1]: https://www.postgresql.org/docs/devel/routine-vacuuming.html#VACUUM-FOR-WRAPAROUND

Best Regards,
Hayato Kuroda
FUJITSU LIMITED
https://www.fujitsu.com/ 


pgsql-hackers by date:

Previous
From: Dean Rasheed
Date:
Subject: Re: MERGE ... WHEN NOT MATCHED BY SOURCE
Next
From: Jelte Fennema-Nio
Date:
Subject: Re: Injection points: some tools to wait and wake