| From: | Tomas Vondra <tomas(at)vondra(dot)me> |
|---|---|
| To: | Rui Zhao <zhaorui126(at)gmail(dot)com> |
| Cc: | Daniel Gustafsson <daniel(at)yesql(dot)se>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, Ewan Young <kdbase(dot)hack(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: allow spread checkpoints when changing checksums online |
| Date: | 2026-11-23 16:23:47 |
| Message-ID: | a7a8a655-97a7-462e-b17a-22af9cd06af4@vondra.me |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Rui,
sorry for the delay.
On 7/14/26 13:12, Rui Zhao wrote:
> Hi Tomas,
>
> Thanks, the new patch addresses the earlier points -- builds clean,
> test_checksums passes, disabling with fast => false still spreads. Switching
> launcher_exit() to launch_fast_checkpoint reads right: it's the source of
> truth, set by the user's pg_enable/disable call, while fast_checkpoint is the
> effective copy the worker maintains -- so reading launch_fast_checkpoint from
> the launcher gets the current intent and can't race a worker write the way
> reading fast_checkpoint could.
>
> On the locking: three of the four reads take the lock -- launcher_exit()
> (:1044) and the two in DataChecksumsWorkerLauncherMain() (:1248, :1275) -- but
> ProcessAllDatabases() (:1388) still reads DataChecksumState->fast_checkpoint
> inline, unlocked. It's safe there (no worker is running at that point), so
> :1388 is just the read that slipped past the locking protocol; and where the
> lock is taken it's LW_EXCLUSIVE on plain reads, where LW_SHARED would do (the
> writers already hold it exclusive), :1388 included once locked. More
> substantive: now that launcher_exit() reads launch_fast_checkpoint, the three
> still reading fast_checkpoint (:1248, :1275, :1388) look inconsistent -- should
> they move to launch_fast_checkpoint too?
>
Yeah, I think you're probably right. It seems better to stick to the
locking protocol everywhere, even if maybe in some places it's safe to
access the flag without the lock. Or at least properly document why it's
safe in that particular place (when it's actually worth it - I don't
think this case is that).
The other thing I was wondering about during rebase is - why are we
using launch_fast_checkpoint directly in launcher_exit, and not the
"normal" flag? Maybe there's a reason, not sure.
But as I mentioned in the other message I just sent to this thread, I'm
not sure launcher_exit should issue checkpoints, in which case this
question would be irrelevant.
> One broader observation, and it predates the patch -- from the original
> online-checksums commit; this one just adds fast_checkpoint to the pattern. Each
> of the four non-launch_ "effective" fields mirrors a launch_ field, yet each has
> at most one real reader: operation is never read (write-only at :1187/:1303),
> cost_delay/cost_limit only by the worker (:1691, plus the change-check
> at :1750),
> and fast_checkpoint only by the launcher for its checkpoint (the worker's :1752
> compare just keeps the mirror in step). The worker's use of the cost fields is a
> "what did I last apply" baseline that could as easily be process-local, and in
> each case the launch_ value is right there to read directly. So the whole
> effective group looks like it may not need to be shared state at all
> -- derivable
> from the launch_ fields plus a worker-local baseline. Nothing to settle in this
> patch, and maybe there's intent behind the mirror I'm missing, but since the
> patch grows the group by one it seemed worth putting on the table.
>
Right. I think this is consistent with my observation that the
checkpoints are issued by the launcher, and so why should it be up to
the workers to propagate the value from launch_fast_checkpoint flag to
the fast_checkpoint?
> One doc nit, since 0001 is backpatched: typos in the added text -- "generate of
> lot of writes" -> "a lot", "requresting spread checkpoints" -> "requesting", and
> the I/O bullet's "enabling and disabling data checksums requires performing
> checkpoints" -> "require".
>
Thanks. I think I fixed most of these typos in v6. If not, I'll fix them
in v7.
> On the "checksums" vs "data checksums" wording in wal.sgml: that's the whole
> section's existing style, not something this patch touches, so I'd leave it out
> of a backpatched doc fix -- a separate cleanup if anyone cares. And +1 on the
> retitle to "Impact of Online Operations on System".
>
OK.
regards
--
Tomas Vondra
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Fabrice Chapuis | 2026-11-23 16:50:53 | unidirectional logical replication logging issue |
| Previous Message | Matheus Alcantara | 2026-11-23 16:20:24 | Re: [PATCH v1] Fix for Bug#19724 - ALTER TYPE ... ALTER ATTRIBUTE triggers internal error for base type of domain with check |