| From: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> |
|---|---|
| To: | "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com> |
| Cc: | vignesh C <vignesh21(at)gmail(dot)com>, Noah Misch <noah(at)leadboat(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: sequencesync worker race with REFRESH SEQUENCES |
| Date: | 2026-07-28 12:21:11 |
| Message-ID: | CAA4eK1K9XjDk5z2ept-9CLmqAdRdZJ91stb8sCfWEHfOeXnCdA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Tue, Jul 28, 2026 at 4:14 PM Hayato Kuroda (Fujitsu)
<kuroda(dot)hayato(at)fujitsu(dot)com> wrote:
>
> One minor comment:
> ```
> + /*
> + * Lock the sequence so its identity (namespace and name) cannot change
> + * under us via a concurrent DROP, RENAME or SET SCHEMA. Release it
> + * right away rather than at transaction end, to avoid accumulating a
> + * lock per sequence.
> + */
> + sequence_rel = try_table_open(subrel->srrelid, AccessShareLock);
> ```
>
> I think this comment is not enough. We can describe why the releasing the lock
> immediately is OK. IIUC, it's because the name and the namespace would be checked
> again in copy_sequences(), right?
>
Yes, that is correct. How about a comment as follows:
/*
* Lock the sequence so its identity (namespace and name) cannot change
* under us via a concurrent DROP, RENAME or SET SCHEMA while we read it.
* The lock is released immediately rather than at transaction end. The
* later synchronization does not depend on this captured identity
* remaining valid, as it re-opens the sequence and tolerates concurrent
* changes. Releasing early also avoids holding one lock per sequence,
* which could exhaust the lock table.
*/
--
With Regards,
Amit Kapila.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2026-07-28 12:24:25 | Re: remove_useless_joins vs. bug #19560 |
| Previous Message | Andrew Dunstan | 2026-07-28 11:56:41 | Re: Skip .DS_Store files in check_mode_recursive |