| From: | Anthonin Bonnefoy <anthonin(dot)bonnefoy(at)datadoghq(dot)com> |
|---|---|
| To: | Fujii Masao <masao(dot)fujii(at)gmail(dot)com> |
| Cc: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Mircea Cadariu <cadariu(dot)mircea(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Japin Li <japinli(at)hotmail(dot)com> |
| Subject: | Re: Propagate XLogFindNextRecord error to callers |
| Date: | 2026-03-23 08:15:13 |
| Message-ID: | CAO6_XqruVj8UmLMxeK1yN15cbJRs3e_k86N+D6PF=6OsikA1Cw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Tue, Mar 17, 2026 at 10:49 AM Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> Since this patch is marked Ready for Committer, I've started reviewing it.
Thanks for the review!
On Tue, Mar 17, 2026 at 10:49 AM Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> + * When set, *errormsg points to an internal buffer that's valid until the next
> + * call to XLogReadRecord.
>
> Could that buffer also be invalidated by other functions that modify
> "XLogReaderState *state", such as XLogBeginRead()?
Yes, XLogBeginRead() will clear the buffer, but I don't think there's
a pattern where XLogBeginRead() is called after XLogFindNextRecord()
on the same reader?
The comment was more focused on how the function would be used, with
XLogReadRecord() being called after the reader state is initialized,
and talking about XLogBeginRead() here could be confusing.
> +# Wrong WAL version. We copy an existing wal file and set the
> +# page's magic value to 0000.
>
> Would it be better to describe the purpose of this test at the top?
> For example:
>
> # Test that pg_waldump reports a detailed error message when dumping
> # a WAL file with an invalid magic number (0000).
> {
> # The broken WAL file is created by copying a valid WAL file and
> # overwriting its magic number with 0000.
> my $broken_wal_dir = PostgreSQL::Test::Utils::tempdir_short();
Sounds good, I've updated the patch.
> + open($fh, '+<', $broken_wal);
> + close($fh);
>
> Should we add error handling like:
>
> open(my $fh, '+<', $broken_wal)
> or BAIL_OUT("open($broken_wal) failed: $!");
> close($fh)
> or BAIL_OUT("close failed: $!");
Added.
> Also, other similar tests seem to call binmode. Is it really unnecessary
> in this case?
Ha right, I've missed those calls. I'm not sure if it's strictly
necessary for the functions used there, but it's probably a lot saner
to read and write WAL using binary mode. I've added a binmode call.
Regards,
Anthonin Bonnefoy
| Attachment | Content-Type | Size |
|---|---|---|
| v7-0001-Propagate-errormsg-to-XLogFindNextRecord-caller.patch | application/octet-stream | 8.7 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Bertrand Drouvot | 2026-03-23 08:18:05 | Re: Adding locks statistics |
| Previous Message | David Geier | 2026-03-23 08:00:34 | Re: Reduce timing overhead of EXPLAIN ANALYZE using rdtsc? |