Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w109B-002P6u-36 for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Mar 2026 10:53:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w109A-003Lv8-0f for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Mar 2026 10:53:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w1099-003Lv0-2t for pgsql-hackers@lists.postgresql.org; Fri, 13 Mar 2026 10:53:36 +0000 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w1096-00000002RqR-1KhV for pgsql-hackers@lists.postgresql.org; Fri, 13 Mar 2026 10:53:34 +0000 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-48539d21b76so14365155e9.1 for ; Fri, 13 Mar 2026 03:53:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773399211; x=1774004011; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=4o3AfKHnU+gky0p/P40KnHCDD+OY0YDgLIRkJN2Tpp0=; b=B/R74F/B9YEJ17Em3yDlmq9vOvX5mMgJBY6xLRJRKoFmTMouYv2de9hqyMRQKT9aU6 WL3fWSUJEMqiGS46h7/gRk1S0FCdzflL6tRJk+RSWlNZHk1ozTyR4g9O+JCo3XgW29ky 28hOPwGZazS5n0n+/HjQe4g7CNx/kHfNFE63B7FlTZibVsVAM27qy2ob0kD/Hqpnx4Ap eSl0NEnkCfqznemUWEfoVmWUPkaZlaxwARQ65tn4r/lsqHzN3/lgjf7upL+8pDKsSnHc D6tu6ars3fN9oaOAr5hIi7Bfxi3tBunbnMsHbnBOFoeKfgAiJDWRXj1e9nvqV2K1g/82 K+tA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773399211; x=1774004011; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4o3AfKHnU+gky0p/P40KnHCDD+OY0YDgLIRkJN2Tpp0=; b=lmhikkCKt2hr3U6iVGXDkMHslkMaOwFr9LlKAj8uDHxkPkhXUDh1O1CWj97+GY+Smh ntM6Mk49B2fyV95T7E0Utu425f4EmGuuca47ji6CWxXzMo/irl5nECRN3PByFJHPVjT+ EgGa7WHnbpjJjvtMHEyX7f5WIdGp/upZZ7JaF7G4Pt1grxwM6JKWylkJXfi4K7P62MiK BQE/zDw3zHU6AtAeHFDwUnrBuu+wZ+0IRRh74VKr4/jq2FqLV5qI3gWwj6xWUJ9u05uU DDBbD9ncSRZwWTDHY2jBe6dhixe888ebvx6x0CPEoZtn2cY/7Hp14mpGSqXRvUhxMA+B Y34w== X-Gm-Message-State: AOJu0Yz80mmuK+vDUP5hGZ+EgegxJFSNUw6yqlYi0JgKSI4dC/VVp1Zg xGYqAhoJ2bieteUwvSBQYeFyhXMO8l68AqZzqINdZsLZMLASrHOSF75j X-Gm-Gg: ATEYQzzOhQN8tLz+5/3fwBrnHQYrV+Q6d54ve6lWsqobnrVVEekLicK0ig2+72DcI8P N2QNjPdZzG8YUK7VVuyxC9RPRBXBeCzA6BGwi3RhYbgOR03UAq9EU/2U1XuHw62gUDLHM+ynnbD 7/opPm0ksf0KO1a+43aemcQg7V3tli6WxC65UV5fIZDotkbjDbJw2sA8rgd4b/AFs/+TZ7s4rtb wxSeGZJSZJnkjnb2pr7/cmiy87jJbjKA5ZOoZrFSWITAVBYxYV0qfUZkLYxqIsU7gdCe8bdbaei SQnXBwrupo8dhPl5ACATPITTVRicO2IWkiFr6xyYvCVHSN3yXVA04RNH4qR+WBNNJJiWtTV2mYV nUgJsut7LYD+poTbyZiXMm5/JhmS5Pa0lzVnZcofH8oM5LUWj1NP4SLa5FN79P0dA6ayh40MMcF jkpugLc/PRRQDaADKWX6LCtpZyyE2bH4f9x4FF5uRmkAh9C27Sj68j+H8NRusGzGDRI5tk1cDkJ r7MDFTpBxS19+o3bvn7HmBMIL3cO2/HaN3blgbEm8wQvEk3RHNEotRRXw== X-Received: by 2002:a05:600c:4514:b0:485:2f6a:6ed with SMTP id 5b1f17b1804b1-4855670b701mr39700545e9.28.1773399210710; Fri, 13 Mar 2026 03:53:30 -0700 (PDT) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-237-197-144.eu-west-3.compute.amazonaws.com. [15.237.197.144]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-439fe1b287dsm16007887f8f.17.2026.03.13.03.53.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Mar 2026 03:53:30 -0700 (PDT) Date: Fri, 13 Mar 2026 10:53:29 +0000 From: Bertrand Drouvot To: Tomas Vondra Cc: PostgreSQL Hackers Subject: Re: Tighten asserts on ParallelWorkerNumber a little bit Message-ID: References: <5db067a1-2cdf-4afb-a577-a04f30b69167@vondra.me> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5db067a1-2cdf-4afb-a577-a04f30b69167@vondra.me> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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