Re: Fix possible 'unexpected data beyond EOF' on replica restart
| От | Amul Sul |
|---|---|
| Тема | Re: Fix possible 'unexpected data beyond EOF' on replica restart |
| Дата | |
| Msg-id | CAAJ_b94FEArRqXd4q+drOh=yS4_2sPrdHTGXTVH+wHRP0EPuCw@mail.gmail.com обсуждение исходный текст |
| Ответ на | Fix possible 'unexpected data beyond EOF' on replica restart (Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>) |
| Ответы |
Re: Fix possible 'unexpected data beyond EOF' on replica restart
|
| Список | pgsql-hackers |
On Tue, Dec 16, 2025 at 6:38 PM Anthonin Bonnefoy
<anthonin.bonnefoy@datadoghq.com> wrote:
>
> [...]
> The patch fixes the issue by moving smgr_cached_nblocks updates in mdtruncate and only updating the cached value if
truncatewas successful.
>
Thanks for detailed reproducible steps, I can see the reported issue
and proposed patch fixes the same. Patch looks good to me except
following changes in smgrtruncate():
- /* Make the cached size is invalid if we encounter an error. */
- reln->smgr_cached_nblocks[forknum[i]] = InvalidBlockNumber;
-
smgrsw[reln->smgr_which].smgr_truncate(reln, forknum[i],
old_nblocks[i], nblocks[i]);
The deleted code you moved to mdtruncate() should be kept where it
was. We cannot ensure that every extension using this interface will
adhere to that requirement what the comment describes. Furthermore,
an extension's routine might miss updating smgr_cached_nblocks.
To ensure that updates smgr_cached_nblocks properly, we should also
add an assertion after the call, like this:
/*
* Ensure that the local smgr_cached_nblocks value is updated.
*/
Assert(reln->smgr_cached_nblocks[forknum[i]] != InvalidBlockNumber);
Regards,
Amul
В списке pgsql-hackers по дате отправления: