| From: | Sami Imseih <samimseih(dot)pg(at)gmail(dot)com> |
|---|---|
| To: | Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>, Nisha Moond <nisha(dot)moond412(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Subject: | Re: Show effective xmin in pg_replication_slots when xmin is not set |
| Date: | 2026-10-06 19:40:30 |
| Message-ID: | CAN12+YJMAsMR7MEev-5X54xPa5kjs0c4n2FbaiAnzMXCDRh24Q@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
> The documentation describes xmin as the oldest
> transaction that the slot needs the database to retain, so the view
> doesn't match the documentation in this case.
That's right, this is a gap. The pg_replication_slots.xmin column should also
show the in-memory xmin used while initializing logical decoding with a full
snapshot; otherwise it is not obvious from the slot view that this slot is one
of the things that can be holding the VACUUM cutoff back.
> + else if (slot_contents.effective_xmin != InvalidTransactionId)
> + values[i++] = TransactionIdGetDatum(...);
From what I can tell, we should only enter this fallback for normal logical
decoding slots while initializing a full snapshot. In the other cases,
data.xmin and
effective_xmin are set together.
The patch overall LGTM, and closes the documentation gap.
> I checked that the first case reproduces on all supported branches, so
> I think we can backpatch the fix. Please find the attached v1 patch.
>
> Thoughts?
I think backpatching is good here.
I was debating whether we should add a test for this, but the test would need
concurrent sessions, so it would likely have to be a Perl TAP test. I am not
sure that is worth it for this case.
> So in both phases of REPACK (CONCURRENTLY) a visible backend holds the
> same xmin as the slot.
Right, there can be multiple holders for the same cutoff. The
pg_xmin_horizon reporting work being done here [2] will be the
appropriate utility to identify all contributors holding the cutoff xmin back.
[2] https://postgr.es/m/CALj2ACV9FYmK9nHZ+DtNkOvN_z8uMvWF+MwsMgJu2V686vuYHg@mail.gmail.com
--
Sami Imseih
Amazon Web Services (AWS)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alvaro Herrera | 2026-10-06 20:08:28 | Re: REPACK (CONCURRENTLY): do not block the table while waiting for the final lock |
| Previous Message | Nathan Bossart | 2026-10-06 19:37:44 | Re: use a non-locking initial test in TAS_SPIN on AArch64 |