WaitForOlderSnapshots refactoring

Started by Peter Eisentrautabout 8 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:t39234
psql -h localhost -U postgres

Built from patchset v1 (message #1), July 28, 2026 at 05:25 AM.

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 t39234_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 t39234_1 && git checkout t39234_1

Patchset v1 (message #1) is on t39234_1

Jump to latest
#1Peter Eisentraut
peter_e@gmx.net

The attached patch factors out the CREATE INDEX CONCURRENTLY code that
waits for transactions with older snapshots to finish into a new
function WaitForOlderSnapshots().

This refactoring was part of a previously posted REINDEX CONCURRENTLY
patch. But this code is now also appearing as a copy-and-paste in the
ATTACH/DETACH PARTITION CONCURRENTLY thread, so it might be worth making
it an official thing.

The question is where to put it. This patch just leaves it static in
indexcmds.c, which doesn't help other uses. A sensible place might be a
new src/backend/commands/common.c. Or we make it non-static in
indexcmds.c when the need arises.

Thoughts?

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

Attachments:

t39234_1
0001-Factor-out-WaitForOlderSnapshots.patchtext/plain; charset=UTF-8; name=0001-Factor-out-WaitForOlderSnapshots.patch; x-mac-creator=0; x-mac-type=0Download+86-70
#2Andres Freund
andres@anarazel.de
In reply to: Peter Eisentraut (#1)
Re: WaitForOlderSnapshots refactoring

Hi,

On 2018-08-20 14:35:34 +0200, Peter Eisentraut wrote:

The attached patch factors out the CREATE INDEX CONCURRENTLY code that
waits for transactions with older snapshots to finish into a new
function WaitForOlderSnapshots().

This refactoring was part of a previously posted REINDEX CONCURRENTLY
patch. But this code is now also appearing as a copy-and-paste in the
ATTACH/DETACH PARTITION CONCURRENTLY thread, so it might be worth making
it an official thing.

I'm doubtful that ATTACH should use this, but I think the refactoring is
a good idea regardless.

The question is where to put it. This patch just leaves it static in
indexcmds.c, which doesn't help other uses. A sensible place might be a
new src/backend/commands/common.c. Or we make it non-static in
indexcmds.c when the need arises.

Why not move it to procarray.c? Most of the referenced functionality
resides there IIRC.

Greetings,

Andres Freund

#3Peter Eisentraut
peter_e@gmx.net
In reply to: Andres Freund (#2)
Re: WaitForOlderSnapshots refactoring

On 20/08/2018 14:39, Andres Freund wrote:

The question is where to put it. This patch just leaves it static in
indexcmds.c, which doesn't help other uses. A sensible place might be a
new src/backend/commands/common.c. Or we make it non-static in
indexcmds.c when the need arises.

Why not move it to procarray.c? Most of the referenced functionality
resides there IIRC.

I was thinking about that, too. I thought that that would create a
circular dependency between lock.c and procarray.c, but seeing that
that's already the case, I guess it's OK. (lock.c includes procarray.h,
but procarray.c uses stuff from lock.h, even though it doesn't include
it directly.) I'll rework the patch accordingly.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services