| From: | Haibo Yan <tristan(dot)yim(at)gmail(dot)com> |
|---|---|
| To: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Robert Haas <robertmhaas(at)gmail(dot)com> |
| Subject: | Re: [PATCH v1] pg_stash_advice: Reject embedded NUL bytes in persistence files |
| Date: | 2026-11-17 18:27:10 |
| Message-ID: | CABXr29GRJczXCEsrytK8CupMCwyt0N=7FXObM=gBcNxDWSpsRA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Chao,
Thanks for reviewing. I haven't found a case where normal writes or
a crash left an embedded NUL in pg_stash_advice.tsv. The writer uses a
temporary file and durable_rename(), and SQL text input rejects NUL
even with SQL_ASCII. I inserted the NUL by hand for the test.
Other byte changes can go undetected. NUL is worth checking because
the loader mistakes it for EOF, reports success, and can discard the
remaining records on the next save.
Best regards,
Haibo
On Mon, Nov 16, 2026 at 11:26 PM Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> wrote:
>
>
>
> > On Nov 17, 2026, at 10:35, Haibo Yan <tristan(dot)yim(at)gmail(dot)com> wrote:
> >
> > Hi hackers,
> >
> > The initial leads for this work came from several independent
> > LLM-assisted reviews of the plan advice code. The reviews identified
> > several candidate issues, which we then reproduced and checked
> > individually. Several issues were confirmed.
> >
> > This is the first patch we are posting from that review. It addresses
> > one of the confirmed issues. The remaining fixes are independent and
> > will be submitted separately after their tests and reviews are
> > complete.
> >
> > pg_stash_advice reads its persistence file into memory, but the loader
> > previously parsed the buffer as a NUL-terminated string. If the file
> > contained an embedded NUL byte, the loader silently treated it as the
> > end of the file and accepted only the preceding records.
>
> Hi Haibo,
>
> Thanks for the patch.
>
> I'm just curious why a file might contain an embedded NUL byte. Is there a known scenario where pg_stash_advice.tsv could contain a NUL byte? If that's because of file corruption, couldn't any byte appear in the middle of the file? In that case, is checking only for NUL bytes good enough?
>
> Best regards,
> --
> Chao Li (Evan)
> HighGo Software Co., Ltd.
> https://www.highgo.com/
>
>
>
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Baji Shaik | 2026-11-17 18:28:58 | Re: using index to speedup add not null constraints to a table |
| Previous Message | Masahiko Sawada | 2026-11-17 18:26:24 | Re: Assertion failure in update_local_synced_slot(), slotsync.c:364 |