public inbox for [email protected]  
help / color / mirror / Atom feed
Re: Tighten asserts on ParallelWorkerNumber a little bit
2+ messages / 2 participants
[nested] [flat]

* Re: Tighten asserts on ParallelWorkerNumber a little bit
@ 2026-03-13 10:53 Bertrand Drouvot <[email protected]>
  2026-03-14 14:53 ` Re: Tighten asserts on ParallelWorkerNumber a little bit Tomas Vondra <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Bertrand Drouvot @ 2026-03-13 10:53 UTC (permalink / raw)
  To: Tomas Vondra <[email protected]>; +Cc: PostgreSQL Hackers <[email protected]>

Hi,

On Thu, Mar 12, 2026 at 07:59:43PM +0100, Tomas Vondra wrote:
> Hi,
> 
> While hacking on something I happened to notice a couple asserts on
> ParallelWorkerNumber when collecting shared instrumentation:
> 
>   Assert(ParallelWorkerNumber <= node->shared_info->num_workers);
> 
> This is not quire right, because num_workers is used to size arrays
> indexed by ParallelWorkerNumber. And the comment in parallel.c also
> claims (ParallelWorkerNumber < num_workers).
> 
> So AFAICS the assert(s) should be
> 
>   Assert(ParallelWorkerNumber < node->shared_info->num_workers);

I think that you're right. It looks like the first one has been introduced
by bf11e7ee2e3 and then the others are probably copy/paste.

> I don't think we had issues with this not catching a bug. But it may be
> a bit misleading, so worth fixing and (probably) backpatching.

I do agree.

With that patch applied, the remaining one:

$ git grep "<=.*num_workers"
src/backend/executor/nodeGatherMerge.c: Assert(nreaders <= castNode(GatherMerge, gm_state->ps.plan)->num_workers);

does not need to be fixed, so I think that your patch does not miss any and
LGTM.

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com





^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Tighten asserts on ParallelWorkerNumber a little bit
  2026-03-13 10:53 Re: Tighten asserts on ParallelWorkerNumber a little bit Bertrand Drouvot <[email protected]>
@ 2026-03-14 14:53 ` Tomas Vondra <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Tomas Vondra @ 2026-03-14 14:53 UTC (permalink / raw)
  To: Bertrand Drouvot <[email protected]>; +Cc: PostgreSQL Hackers <[email protected]>

On 3/13/26 11:53, Bertrand Drouvot wrote:
> ...
>
>> So AFAICS the assert(s) should be
>>
>>   Assert(ParallelWorkerNumber < node->shared_info->num_workers);
> 
> I think that you're right. It looks like the first one has been introduced
> by bf11e7ee2e3 and then the others are probably copy/paste.
> 
>> I don't think we had issues with this not catching a bug. But it may be
>> a bit misleading, so worth fixing and (probably) backpatching.
> 
> I do agree.
> 
> With that patch applied, the remaining one:
> 
> $ git grep "<=.*num_workers"
> src/backend/executor/nodeGatherMerge.c: Assert(nreaders <= castNode(GatherMerge, gm_state->ps.plan)->num_workers);
> 
> does not need to be fixed, so I think that your patch does not miss any and
> LGTM.
> 

Thanks. Pushed and backpatched.

-- 
Tomas Vondra






^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2026-03-14 14:53 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-03-13 10:53 Re: Tighten asserts on ParallelWorkerNumber a little bit Bertrand Drouvot <[email protected]>
2026-03-14 14:53 ` Tomas Vondra <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox