[PATCH] Improve REPACK (CONCURRENTLY) error messages for unsupported configurations

Поиск
Список
Период
Сортировка
Искать

[PATCH] Improve REPACK (CONCURRENTLY) error messages for unsupported configurations

От:
Baji Shaik <baji.pgdev@gmail.com>
Дата:
Вложения:
Hi,

While exploring the new REPACK (CONCURRENTLY) feature, I noticed 
a few user-facing error paths that could be made more accurate.  
Patch series of three:

 0001 -- When wal_level < replica, REPACK (CONCURRENTLY) currently
         surfaces generic "replication slots ... wal_level" error
         from CheckSlotRequirements(), with a CONTEXT line referring
         to an internal worker.  Add an upfront check that reports a
         REPACK-specific error.

 0002 -- check_concurrent_repack_requirements() reports the same
         generic "no identity index" error for several distinct
         cases, two of which are misleading: REPLICA IDENTITY FULL
         (which is set, but the hint says there is no identity), and
         a deferrable PK as the only identity (skipped per commit
         832e220d99a, but the hint suggests adding an index that
         already exists).  Distinguish these cases.

 0003 -- Four ereport(ERROR) calls in the REPACK CONCURRENTLY code
         path lack errcode() and default to ERRCODE_INTERNAL_ERROR.
         Add appropriate errcodes; in particular, the
         apply_concurrent_update/delete failures map cleanly to
         ERRCODE_T_R_SERIALIZATION_FAILURE.

All three are error-path only; the success path is unchanged.  Each
patch is independently committable.  Detailed rationale is in the
individual commit messages.

Tested with `make check` (245/245 pass) and `make isolation/check`
(128/128 pass) on top of master; 0002 also updates
src/test/regress/expected/cluster.out to match the new deferrable-PK
message.

Thanks,
Baji Shaik

Re: [PATCH] Improve REPACK (CONCURRENTLY) error messages for unsupported configurations

От:
Chao Li <li.evan.chao@gmail.com>
Дата:


> On May 27, 2026, at 11:06, Baji Shaik  wrote:
> 
> Hi,
> 
> While exploring the new REPACK (CONCURRENTLY) feature, I noticed 
> a few user-facing error paths that could be made more accurate.  
> Patch series of three:
> 
>  0001 -- When wal_level < replica, REPACK (CONCURRENTLY) currently
>          surfaces generic "replication slots ... wal_level" error
>          from CheckSlotRequirements(), with a CONTEXT line referring
>          to an internal worker.  Add an upfront check that reports a
>          REPACK-specific error.
> 

LGTM

>  0002 -- check_concurrent_repack_requirements() reports the same
>          generic "no identity index" error for several distinct
>          cases, two of which are misleading: REPLICA IDENTITY FULL
>          (which is set, but the hint says there is no identity), and
>          a deferrable PK as the only identity (skipped per commit
>          832e220d99a, but the hint suggests adding an index that
>          already exists).  Distinguish these cases.
> 

When I was working on 832e220d99a, I actually considered for more detailed error messages, but I ended up giving up. I think we should be careful about adding more branches here unless the existing message is causing significant confusion in practice.

So, I personally don’t like 0002.

>  0003 -- Four ereport(ERROR) calls in the REPACK CONCURRENTLY code
>          path lack errcode() and default to ERRCODE_INTERNAL_ERROR.
>          Add appropriate errcodes; in particular, the
>          apply_concurrent_update/delete failures map cleanly to
>          ERRCODE_T_R_SERIALIZATION_FAILURE.
> 

LGTM

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/






Re: [PATCH] Improve REPACK (CONCURRENTLY) error messages for unsupported configurations

От:
Baji Shaik <baji.pgdev@gmail.com>
Дата:
Hi Chao,

Thanks for the quick review and feedback.

On Wed, May 27, 2026 at 1:50 AM Chao Li <li.evan.chao@gmail.com> wrote:


> On May 27, 2026, at 11:06, Baji Shaik <baji.pgdev@gmail.com> wrote:

When I was working on 832e220d99a, I actually considered for more detailed error messages, but I ended up giving up. I think we should be careful about adding more branches here unless the existing message is causing significant confusion in practice.

So, I personally don’t like 0002.
 
I hear the concern of adding more branches here.  FWIW, neither the
deferrable PK limitation nor the REPLICA IDENTITY FULL case is
documented in repack.sgml, and the current error message doesn't
surface either issue.  The user has no way to discover what's wrong
without reading the source.  That's why I think the improved messages
are warranted here.  Happy to add a documentation note as well, or
both. Let me know what's preferred.

But happy to drop 0002 if others feel the same. 0001 and 0003 stand on
their own.

Thanks,
Baji Shaik

Re: [PATCH] Improve REPACK (CONCURRENTLY) error messages for unsupported configurations

От:
Álvaro Herrera <alvherre@kurilemu.de>
Дата:
On 2026-May-27, Chao Li wrote:

> > On May 27, 2026, at 11:06, Baji Shaik  wrote:

> > 
> >  0001 -- When wal_level < replica, REPACK (CONCURRENTLY) currently
> >          surfaces generic "replication slots ... wal_level" error
> >          from CheckSlotRequirements(), with a CONTEXT line referring
> >          to an internal worker.  Add an upfront check that reports a
> >          REPACK-specific error.
> 
> LGTM

Pushed this one earlier.  I changed the errcode though, because in my
mind "object" is a database object, and the server configuration is not
an object.  So I used INVALID_PARAMETER_VALUE instead.  I also don't
think it makes sense to say "cannot repack table X", so the user leaves
thinking they could repack table Y instead.  The whole point being that
you cannot vacuum _any_ tables.  So I made the errmsg() say that.

> When I was working on 832e220d99a, I actually considered for more
> detailed error messages, but I ended up giving up. I think we should
> be careful about adding more branches here unless the existing message
> is causing significant confusion in practice.
> 
> So, I personally don’t like 0002.

I'll give this a look after some icecream.

> >  0003 -- Four ereport(ERROR) calls in the REPACK CONCURRENTLY code
> >          path lack errcode() and default to ERRCODE_INTERNAL_ERROR.
> >          Add appropriate errcodes; in particular, the
> >          apply_concurrent_update/delete failures map cleanly to
> >          ERRCODE_T_R_SERIALIZATION_FAILURE.

Also pushed, with additional editorialization.  I have recollections of
out message policy saying something about "could not do X" instead of
"failed to do X", so I changed it that way.  (But I couldn't find that
in the style guide.)

-- 
Álvaro Herrera               48°01'N 7°57'E  —  https://www.EnterpriseDB.com/


Re: [PATCH] Improve REPACK (CONCURRENTLY) error messages for unsupported configurations

От:
Álvaro Herrera <alvherre@kurilemu.de>
Дата:
Вложения:
While looking these patches over I noticed that we still have some error
reports cases uncovered.  Here's a quick attempt to try and complete
that.

After this patch I see only one uncovered error path, the one that
prevents repacking a temp table of another session.  That would require
an isolation test.  Not sure it's worth the trouble ...  (There's a
bunch of uncovered "elog(ERROR)" cases, but those are mostly just
can't-happen conditions, as I understand).

-- 
Álvaro Herrera        Breisgau, Deutschland  —  https://www.EnterpriseDB.com/

Re: [PATCH] Improve REPACK (CONCURRENTLY) error messages for unsupported configurations

От:
Baji Shaik <baji.pgdev@gmail.com>
Дата:
On Thu, May 28, 2026 at 4:18 PM Álvaro Herrera <alvherre@kurilemu.de> wrote:
While looking these patches over I noticed that we still have some error
reports cases uncovered.  Here's a quick attempt to try and complete
that.

After this patch I see only one uncovered error path, the one that
prevents repacking a temp table of another session.  That would require
an isolation test.  Not sure it's worth the trouble ...  (There's a
bunch of uncovered "elog(ERROR)" cases, but those are mostly just
can't-happen conditions, as I understand).

LGTM, thanks for adding these.

FWIW I see a couple more uncovered ereport(ERROR) paths 1/ invalid
index (line 813) 2/ shared catalog with USING INDEX (line 580,
needs allow_system_table_mods). But both need unusual setup, so
fine to leave them along with the temp table one. 

Thanks,
Baji Shaik.
FAQ