Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1n3H5h-0006gb-5f for pgsql-bugs@arkaria.postgresql.org; Fri, 31 Dec 2021 12:33:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1n3H58-0003bl-MM for pgsql-bugs@arkaria.postgresql.org; Fri, 31 Dec 2021 12:32:26 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from <9erthalion6@gmail.com>) id 1n3H58-0003bc-Cp for pgsql-bugs@lists.postgresql.org; Fri, 31 Dec 2021 12:32:26 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from <9erthalion6@gmail.com>) id 1n3H51-0004mC-Kv for pgsql-bugs@lists.postgresql.org; Fri, 31 Dec 2021 12:32:25 +0000 Received: by mail-wr1-x436.google.com with SMTP id s1so55878767wrg.1 for ; Fri, 31 Dec 2021 04:32:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=+nrFmD2OqU65qW2tuUscj4o6gV6ptaY1vFV2LHTaUKE=; b=k7cJbGT4b3lrjJplqS0JmpBvDg8TGatISUwcuQixKAEnjHTdgTYmv1jjw1JZqjiZTz bPw/l9nAAf8jDQNEy6nU7lNMyJmHI+s0TLB+zC24KBLibm80VI0ESgqEbTubUIxoaEZH PWOCGpMk3zHwBpLqUohA4q6es2nHbt+kq88i5xjRIpZ0kXq5Qzm9hBDToxhPN0WzzomZ zXNzjECu3T5HOLYZIlXw6eXz+OdP5EVwGSqq2DnwUydcdXdmg7IEM6y/f4oTCErvUMzG fKcFmvPN5lf4i40Fxzzb/R0k5KCqGgbNPDUUVXSoWEttD+jw6zFt16xnkHGY0NYEqxkl prfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=+nrFmD2OqU65qW2tuUscj4o6gV6ptaY1vFV2LHTaUKE=; b=LjjZFc7ODRC6ZoblU9o1YUEaglPzyyE/gTCM49r8G6jdDw4INcxZ0exwz9f281mRHf gqyJVPfyCFmPARB2wL7+I9rIbyUHP0l00sYniuBa3fNi2rsFzwrupSYeC+Pt2Yv0FA2S 0hiWQoGY6DQ7N6tEnGTFI0jm+cZtrpGeT3u4IRSxhnHV68xXx/bqce87aSpuQxbM0/Dp tNKM5ca3wpbiY/iYTGfpmY80FAPBgFbIMrXcr4B7orMogNRLbHMinQjxmpQ6EyxEL8+4 5uj3Z/bc9CYgi+H3qJHWlO2jfcImqVxfyUKfVRhFfIW6+dqnztoebee7SwfVJLctzJY8 f3Mw== X-Gm-Message-State: AOAM532M6f4ec2LfZlwU5LbQvRTHy7Wy1QLiElGk3xGWx+7UP8hj1MWP /Ea8i0zqntnQyqE8pLgSHXU= X-Google-Smtp-Source: ABdhPJwDFqRktG4BQY2OLsGxUp08CrlUnzEB6aJ6PEJPIEDVOz08ZaVkpcXWpYmnu3QoNn0xer9nIA== X-Received: by 2002:a5d:588f:: with SMTP id n15mr29669230wrf.279.1640953937213; Fri, 31 Dec 2021 04:32:17 -0800 (PST) Received: from erthalion.local (dslb-178-012-041-031.178.012.pools.vodafone-ip.de. [178.12.41.31]) by smtp.gmail.com with ESMTPSA id n4sm27129139wrc.1.2021.12.31.04.32.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Dec 2021 04:32:16 -0800 (PST) Date: Fri, 31 Dec 2021 13:32:11 +0100 From: Dmitry Dolgov <9erthalion6@gmail.com> To: Etsuro Fujita Cc: pgsql-bugs@lists.postgresql.org, exclusion@gmail.com Subject: Re: BUG #17344: Assert failed on queiring async_capable foreign table with inheritance Message-ID: <20211231123211.dnohvu5exp5dr5oe@erthalion.local> References: <17344-226b78b00de73a7e@postgresql.org> <20211225232625.5xuplnlegneh42cw@erthalion.local> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Fri, Dec 31, 2021 at 04:36:42PM +0900, Etsuro Fujita wrote: > On Tue, Dec 28, 2021 at 10:14 PM Etsuro Fujita wrote: > > The root cause of the > > assertion failure in the first case might be something other than the > > limitation. I’ll look into this in more detail. > > I think the root cause is that we fail to process a pending async > request (if any) in postgresReScanForeignScan() in the case where we > just reset the next_tuple counter in that function, without > destroying/recreating or rewinding the cursor. (In the case where we > destroy/recreate or rewind the cursor in that function, the pending > async request would be processed by pgfdw_exec_query() called from > that function.) This breaks the assumption about ExecAppend() that > when called for the first time after ReScan, there are no pending > async requests made for async subplans for the Append node, causing > the assertion failure in postgresForeignAsyncRequest() called from > that ExecAppend(). My oversight in commit 27e1f1456. :-( > > To fix, I modified postgresReScanForeignScan() so that we always > process a pending async request (if any) before restarting the foreign > scan. Attached is a patch for that. I tested the patch with the > first case, and it addresses the assertion failure. Yep, makes sense now, thank you. The fix works for me, but I'm curious about the requestee condition: fsstate->conn_state->pendingAreq->requestee == (PlanState *) node) You've mentioned that in those cases where the cursor will be destroyed/recreated or rewind, pgfdw_exec_query will take care of processing pending requests, and looks like it will do this without checking the requestee. Just for me to understand, why is this condition necessary?