Re: Spurious "apparent wraparound" via SimpleLruTruncate() rounding

Noah Misch <noah@leadboat.com>

From: Noah Misch <noah@leadboat.com>
To: Andrey Borodin <x4mmm@yandex-team.ru>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Tomas Vondra <tomas.vondra@2ndquadrant.com>, pgsql-hackers@postgresql.org
Date: 2021-01-02T10:00:34Z
Lists: pgsql-hackers
On Sat, Jan 02, 2021 at 12:31:45PM +0500, Andrey Borodin wrote:
> Do I understand correctly that this is bugfix that needs to be back-patched?

The slru-truncate-modulo patch fixes a bug.  The slru-truncate-t-insurance
patch does not.  Neither _needs_ to be back-patched, though I'm proposing to
back-patch both.  I welcome opinions about that.

> Thus we should not refactor 4 identical *PagePrecedes(int page1, int page2) into 1 generic function?

I agree with not refactoring that way, in this case.

> Since functions are not symmetric anymore, maybe we should have better names for arguments than "page1" and "page2"? At least in dev branch.

That works for me.  What names would you suggest?

> Is it common practice to embed tests into assert checking like in SlruPagePrecedesUnitTests()?

No; it's neither common practice nor a policy breach.



Commits

  1. Prevent excess SimpleLruTruncate() deletion.

  2. Fix unlinking of SLRU segments.

  3. Defer flushing of SLRU files.

  4. Change XID and mxact limits to warn at 40M and stop at 3M.