Avoid call MaintainOldSnapshotTimeMapping, if old_snapshot_threshold is disabled.

Started by Ranier Vilelaover 5 years ago3 messageshackers
Beta feature

Hackorum builds and tests every patch posted to the lists, not only commitfest submissions. This is Hackorum's own CI rather than the PostgreSQL project's, and it is still under testing - please report anything that looks wrong.

won't retrysuccessCI history

You can run a PostgreSQL built from this patch straight from Docker, with no checkout and no build:

docker run --rm -p 5432:5432 ghcr.io/hackorum-dev/postgres-patch:t44409
psql -h localhost -U postgres

Built from patchset v1 (message #1), July 27, 2026 at 04:47 PM.

Every patchset is also pushed to a branch of our PostgreSQL fork, so you can check out the same tree CI built. Without a PostgreSQL checkout:

git clone --branch t44409_1 https://github.com/hackorum-dev/postgres.git

In a checkout you already have, add the fork once:

git remote add hackorum https://github.com/hackorum-dev/postgres.git

then, for this patchset and every later one:

git fetch hackorum t44409_1 && git checkout t44409_1

Patchset v1 (message #1) is on t44409_1

Jump to latest
#1Ranier Vilela
ranier.vf@gmail.com

Hi,

While another long thread discusses the situation of old_snapshot_threshold,
I believe we can improve procarray.c by avoiding calling
MaintainOldSnapshotTimeMapping (src/backend/utils/time/snapmgr.c).

There's a very explicit comment there, which says (line 1866):
"Never call this function when old snapshot checking is disabled."

Well, assert should never be used to validate a condition that certainly
occurs at runtime.

Since old_snapshot_threshold is -1, it is disabled, so
MaintainOldSnapshotTimeMapping doesn't need to be run, right?

regards,
Ranier Vilela

Attachments:

t44409_1
avoid_call_if_old_snapshot_threshold_is_disabled.patchapplication/octet-stream; name=avoid_call_if_old_snapshot_threshold_is_disabled.patchDownload+4-2
#2Andres Freund
andres@anarazel.de
In reply to: Ranier Vilela (#1)
Re: Avoid call MaintainOldSnapshotTimeMapping, if old_snapshot_threshold is disabled.

Hi,

On 2021-06-17 21:27:15 -0300, Ranier Vilela wrote:

While another long thread discusses the situation of old_snapshot_threshold,
I believe we can improve procarray.c by avoiding calling
MaintainOldSnapshotTimeMapping (src/backend/utils/time/snapmgr.c).

There's a very explicit comment there, which says (line 1866):
"Never call this function when old snapshot checking is disabled."

Well, assert should never be used to validate a condition that certainly
occurs at runtime.

I don't see how it can happen at runtime currently?

Since old_snapshot_threshold is -1, it is disabled, so
MaintainOldSnapshotTimeMapping doesn't need to be run, right?

It *isn't* run, the caller checks OldSnapshotThresholdActive() first.

Greetings,

Andres Freund

#3Ranier Vilela
ranier.vf@gmail.com
In reply to: Andres Freund (#2)
Re: Avoid call MaintainOldSnapshotTimeMapping, if old_snapshot_threshold is disabled.

Em qui., 17 de jun. de 2021 às 22:08, Andres Freund <andres@anarazel.de>
escreveu:

Hi,

On 2021-06-17 21:27:15 -0300, Ranier Vilela wrote:

While another long thread discusses the situation of

old_snapshot_threshold,

I believe we can improve procarray.c by avoiding calling
MaintainOldSnapshotTimeMapping (src/backend/utils/time/snapmgr.c).

There's a very explicit comment there, which says (line 1866):
"Never call this function when old snapshot checking is disabled."

Well, assert should never be used to validate a condition that certainly
occurs at runtime.

I don't see how it can happen at runtime currently?

Since old_snapshot_threshold is -1, it is disabled, so
MaintainOldSnapshotTimeMapping doesn't need to be run, right?

It *isn't* run, the caller checks OldSnapshotThresholdActive() first.

True. My mistake.
I didn't check GetSnapshotDataInitOldSnapshot correctly.

regards,
Ranier Vilela