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.98.2) (envelope-from ) id 1xRWzX-000000013o2-2KpO for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Nov 2026 15:45:35 +0000 Received: from localhost ([127.0.0.1]:55978 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xRWzW-00000002z0h-0Vgp for pgsql-bugs@arkaria.postgresql.org; Thu, 12 Nov 2026 15:45:34 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]:36700) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xRWzV-00000002z0W-3YtT for pgsql-bugs@lists.postgresql.org; Thu, 12 Nov 2026 15:45:33 +0000 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1xRWzT-00000000hDI-36XZ for pgsql-bugs@postgresql.org; Thu, 12 Nov 2026 15:45:33 +0000 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4a35d5d4a20so52767825e9.2 for ; Thu, 12 Nov 2026 07:45:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1794498330; x=1795103130; darn=postgresql.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=8bVvZav+ie+wpMvkhfREuIca72TIxKG064EIm5I0XNA=; b=izmPjIxNMfNQHewFr5F3RkTLQ3B8XfGZszKMktEKqZwX3gHZfJ04Fi07bocDm2eUWp m5hdrWTiXyDrBbxTq1l9Kfg6wkMD0IWblNBdcQqMA5ppk6Lt5txK6JuOvzmCAOETBG8a jRpYAi1ScwsnNWNgvUNqmSzuQ3QgV9RQ0IC4XuYMqNQoj/2hTm4ssU6dbhD8h+YhV704 iTQRMb53HgLJESnmrYnjLmWkuIhNQtwcK6+zXGvXZ9qzuHQ51oF1RVXIUWGcv3eOV9i6 O1ux78300EDvDKyXA91XDb5r+A0L/U9IulRLf8d9eSwbsuDVgBS6+J+ke9AFg+S7hN8k pmlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1794498330; x=1795103130; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=8bVvZav+ie+wpMvkhfREuIca72TIxKG064EIm5I0XNA=; b=HEbOCPbDZEKlDh1OjGlDjV6RRJfoaS61WGGcCoAcxZdlvXxLVnrfwCEFpgPvke4YvV y/9Iwsv/M+dUkQ8zsvyxV/VXrrPZs47pONKn/OpIIL82BX1ukMZkKwYawrVs6ejxmlZ7 eAOP8NDiTidcjiB5VNC9XqKxgbyI3P+STKj0BYML4B8EtEqgOBaPmaKjJkTp32o7SgOB n+cfHgc3e8YeH/2wBrXOEFyfk0CfjYsCFwCdDoemz92szvV7vvqnZuu+VawSVYaB/3dt 6yCPwUbNwwpnhWqf5b1b9TlmYix5PAIBM9kHnEbYyBnZ1yVtUnw3Xiq7ZkFJJNdX9ucc 67+g== X-Gm-Message-State: APuU4Z8hfF6hfww7d380ExKhqBTpn01DjOWqZ8jh8EGqDCs+UrMk60QB QC8916GTIcno8hVF0bFafzyVmftA7BNqu/BYKiZVT8twpj/LP0CvTjze X-Gm-Gg: AYBFou1BFzFrrHZpKihH2Xl6FRP9Sn9Id5n2m7uRfImzFdngMHD4adSttFYv5B/kJOO Jm3PBRXCym1DInwzFSbUSBb4OnzG6FBim6+Sjx0sx8Ef5HjIzoWFkOLtlTyN9gFmPFl/hRjTk7y S9fOCywMKql+B8ayRdy0EJ3gkDdZYBaB4+3HNOketB9xbed6TS/hpUqYzITeZUUTitPF9re67vM ouHybWMQSkw1PzJfUJQNxXYzLSqj8TGBCZHQmMTiaGrg2OcY7C1tIE6QeKr7PbA/1GNa+seT3Q5 UJ+jW4e+w8tF4Q/sD3Md5UhaRToBn5cKtFjTA2cwzbo8QuquxnT2tezP7SvOs+0975dyRRL5O55 F3C2cYGNfwZzTLn4nAk4T/pH+Mz5SWav+8DpPJDQG5ziAoGyRZCp0amwvt8O9uNa+zziOzheZ52 bacZpLNS0mBe9KMi4iVx0KcbblxHF9U9wnLpYNxBxVkLWFd0Ub8QMlDo8DW+jgMUF3VbUi5YxTn xaY/l3kIFu3D/QH6o4CYV71FK4mEigHAdjkEdVxPFzbFcQUCRO6ZcAGWxz0bxjutldhSTsuWsb3 3eDm4cbZTQ5cU433oxWIpVaRhjph5A09NV7hYVNzkjMNdd5R9Mpm/eU2/RWUxwXewbayg+r8Bds 0HZ2a X-Received: by 2002:a05:600c:190a:b0:4a1:f99e:f22d with SMTP id 5b1f17b1804b1-4ba0936c0d2mr118880965e9.6.1794498329761; Thu, 12 Nov 2026 07:45:29 -0800 (PST) Received: from [192.168.0.205] (84.123.224.205.dyn.user.ono.com. [84.123.224.205]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4988f5b1ce3sm15929957f8f.14.2026.11.12.07.45.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Nov 2026 07:45:27 -0800 (PST) Message-ID: <6d04d232-e1ea-4f7d-a3a9-1ce02a74fd18@gmail.com> Date: Thu, 12 Nov 2026 16:45:26 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: bug: Gather rescan keeps the first scan's tuple bound in workers To: shihao zhong , Jeff Davis Cc: pgsql-bugs@postgresql.org, Robert Haas References: <2701c83e33f3fe66320291fb5d1b74ca2cb90bd7.camel@j-davis.com> Content-Language: en-US From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 19/09/2026 05:05, shihao zhong wrote: > Hi Jeff, > > Thanks for reporting this bug. > > I can reproduce this on master, and a 1000 row table is enough. > The attached 0001 adds a tuples_needed argument to > ExecParallelReinitialize() and stores it in the shared state, the same > way ExecInitParallelPlan() does.  0002 is a regression test and is > optional. > > For the back branches this changes the signature of an exported > function.  I don't know of any extension that calls it, but if that is > a concern, a new function could set the bound there instead. I think you should merge patches 0001 and 0002. While you’re at it, you could add a couple of words pointing out that the tuples_needed field of the FixedParallelExecutorState structure needs to be updated on each rescan. Also, for the back-patch you should add a wrapper for ExecParallelReinitialize(), so that its existing signature stays intact in the stable branches. One more thing: the test covers only Gather Merge. It would be good to add the same query without ORDER BY in the subquery, so that the plain Gather path is exercised too. -- regards, Andrei Lepikhov, pgEdge