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 1wBot3-001PDD-0v for pgsql-bugs@arkaria.postgresql.org; Sun, 12 Apr 2026 07:05:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wBot1-001Xdr-1o for pgsql-bugs@arkaria.postgresql.org; Sun, 12 Apr 2026 07:05:40 +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 1wBot1-001Xdj-10 for pgsql-bugs@lists.postgresql.org; Sun, 12 Apr 2026 07:05:40 +0000 Received: from mail-dy1-x1329.google.com ([2607:f8b0:4864:20::1329]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wBot0-00000000dG4-1P7d for pgsql-bugs@lists.postgresql.org; Sun, 12 Apr 2026 07:05:39 +0000 Received: by mail-dy1-x1329.google.com with SMTP id 5a478bee46e88-2c156c4a9efso4721214eec.1 for ; Sun, 12 Apr 2026 00:05:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775977536; cv=none; d=google.com; s=arc-20240605; b=hsAAIiycBlQphWzwFuf0Fd/Ocyu4ezhP0ptlMDpqnA8K75bHxPDPpaW7jA6647hWDZ EA3DAP8neJYbLorW6idMd85U2TJozrhnjTMXTo6iVGkd5M+w1ZRYsP0PgJiI2/Z/Tblb bQGqgZfWxYyrcv3kZQR1izoNWfbNPZTxhtl+jUDGSa4PgIILDGKnBx/hkAgxbC59eI5H zzj1vvMkcGHBTa0osI6rCTrrZyvDm1YKkio/faSf2PpUN9cOEsv1rtsrHrED+wz9iUub zy7nyhmGyktbUZjRY+mijU766bbBtxOWOG6K9BAXgFfGhk1oOpos5Tu+6NL1dbllA+jf E7MA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=cUWntPxMKqYx8pWGJz8+uiOUW3XQFF1dyxFCsQbqtq0=; fh=lZfRwwdVlpHjlmfRRjZ2VEk/z6fXzeCZq9bax/1muJ4=; b=Rd/uVyEzgDaits/mgMHVSna7FxWz7KBrBHaboXX39CBG0qifbOxcxG0GEvwUVVl3Sg ynjggCh/V/kW7jckEde4YGzGXdC62wakdvI2hjfJvMVRpKY/F+oYQSF2rehv58FZmAYZ DBxVNNoQoxgpBHmzCEcQPdE5p7cwMLsiSu1RFvzjTFtihRTnT0kWbKpF7z3iBUswG3vS 4mZe6ldbMB9PzNORc8JayqDUNOahkW23682o6KXdPm0LlSVaup8VG/s/34Q/jj8t1rkN gZWHnZyHolEsqSKwumDWQTWgikgofVc4z8KSXM9plp/CMhvJAfKMNtj7E+TgvpGe4EkG S8+g==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775977536; x=1776582336; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=cUWntPxMKqYx8pWGJz8+uiOUW3XQFF1dyxFCsQbqtq0=; b=e9hgbR63bjcz7/5yojqCeoKcNthZHU0qk0e7DixqX0X2GYllQry9S3cVWj6SKbNt+7 ZUsDEH7h3bvry3Tz9MevtTrT6eCUuoJOOrDqnYzcqmfWf+hR8AJ2D/sUB7JM7IWaIS5x Xzqkt7eXwwpYwWF1QaiUl3STac7eGFXXILq77SlWdI/npk42yF0ahHpYPgItb4Q1At4M 2xozRuRv9ttTQZhcGSWUElwT5/eOdrCrNy1D1DX5M2UXXgmre9vTff2kN4bQa2iH0cCw B9cKxQ3cZBVhNPZl05SuAu25GSY9Fa1UPfuMqYIN3sKGtCrISAwYqpLi35Il4ZYguA1v YU5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775977536; x=1776582336; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=cUWntPxMKqYx8pWGJz8+uiOUW3XQFF1dyxFCsQbqtq0=; b=UDLGOmTCxLY/VDcILpLOXAngg3EMbK+XXlZ2VAa7aZQg50p7o0DhJTocAvCJVka2R8 oqIwsX2wZholSvMYfDX8URMfifA5bYK84lNR/NkuKETcDgIpbXtVRRLRE4r8NX5x1miP YAnIaYAih7NjqzCBiWbwyG7QY8XrDZmd8yBLaTNVehGpNCwjWjr1zUlrMfvwV964rUF5 TpAPV/NoSG5atC8JZA5Fz9c6zJMnRLpvJrCn+oCOxLIjHd+8/3eaXzyGDW68r9Exmj0y ytoaRKO5lM0v+RFnH36wfEe0DqxhQxXMP6KIvQq/94acSPug5fi5Qcc7o5xTLzoVxDTa i62w== X-Forwarded-Encrypted: i=1; AFNElJ9G7YNOqqC/8kdQl5T/WgpiDO0aYQF9EVME2gNu1J3KILv5eHkYOdilPi362g556+w4tLoORzUo9Gi+@lists.postgresql.org X-Gm-Message-State: AOJu0YzjdPymH7jWpcGWChFkTBftBHhbJIy0yBkhz7R+grmaCOimRNSY cjIPik0qbmDiKIda/gSxGXNwBLbzAJ+k+2IivZUtXtogf/Bs/VwdmbFvMMjmf8gm3Sdsdm5HUjo Y3STC3Zn1qYxLvn+eqZ5Qs9AiRcg7rvo= X-Gm-Gg: AeBDiet7CvS7f1VJSFBYgUzg2ixQDR5VsACnuD91DnHmgTvJ2Goxjsgwv59xDs1RM24 px63gIIC6Rgk+JkAP6yT+wV5QLVy/5K3pcJSAVQWq5a57EDCFQNK2MI557AhJBaYMgPP9QLh1fb ql92Hi+U2UTLXD6fTGfDLyAa2aOKrOa6NJXP7z5+5WGtoywdlDYCgfUtJ8g3uWS4TiiE/cf78Oe zcQm9GIJU+RTnA09BSspm0b+Em6hVpegAuD802J03UU1c0VhRvND/mqGiVHO2nNYGMLln1r7/Tf bgL9c+g56oGNhFo9XEUmXFiXsgn63CjbsENGgKfOr3QLRTWfWe/XILtsfVMf84fOGopyzncu7EX ddjo8wTnUGkmgc5fWbjPCkTVm9SlmzCVKvWOwJdeZ X-Received: by 2002:a05:7300:1493:b0:2c1:3f85:756 with SMTP id 5a478bee46e88-2d58779dc43mr4063295eec.11.1775977536271; Sun, 12 Apr 2026 00:05:36 -0700 (PDT) MIME-Version: 1.0 References: <10df46d9.7dc2.19cd740a640.Coremail.jiye_sw@126.com> <5557f6f5.45bd.19cdb7a1764.Coremail.jiye_sw@126.com> <705358bc.2ead.19d5154b82f.Coremail.jiye_sw@126.com> In-Reply-To: <705358bc.2ead.19d5154b82f.Coremail.jiye_sw@126.com> From: Etsuro Fujita Date: Sun, 12 Apr 2026 16:05:25 +0900 X-Gm-Features: AQROBzB-wwAz6bvTEXs1RvmKFDw4K98uMRCaZlJ1NU_nsCTFsqckR960593ITNY Message-ID: Subject: Re: Re: Re: FDW connection drops with "Connection timed out" during async append query due to TCP receive buffer filling up To: jiye Cc: "David G. Johnston" , "pgsql-bugs@lists.postgresql.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Apr 3, 2026 at 12:13=E2=80=AFPM jiye wrote: > We have successfully reproduced this issue and gained a clearer understan= ding of its root cause. The application uses a cursor to fetch partial resu= lts in batches, with a delay between consecutive fetch operations. When the= interval between two batches exceeds the tcp_user_timeout threshold, the c= onnection is terminated unexpectedly. I think that that is *expected* behavior. > In my analysis, during cursor-based queries, applications typically retri= eve results in partial batches. If the number of rows fetched in a single b= atch is smaller than the number of rows scanned from the local table, the e= xecutor is unable to proceed with fetching rows from the foreign table. IIRC, I don't think that Append in async mode has such a limitation; it chooses the next partition to scan independently of the number of rows returned from it. No? > To achieve a fundamental resolution, I propose two potential solutions: > > =E2=80=8CAlternate Row Fetching=E2=80=8C: Modify the executor to alternat= ely retrieve rows from the local table and the foreign table, ensuring bala= nced data flow between the two data sources. > =E2=80=8CAsynchronous Tuple Storage=E2=80=8C: Implement a tuple storage m= echanism to asynchronously cache results from the foreign table. This would= allow the executor to fetch foreign table results into the storage buffer = independently, preventing TCP window exhaustion and decoupling the dependen= cy between local and foreign data retrieval. I suppose that these are improvements, but I'm not sure these are really worth complicating the code, as what you are trying to solve by these is not a normal case; in particular, it's far from normal to set a tcp_user_timeout that the query cannot finish. Anyway, thanks for sharing the analysis and ideas! Sorry for the delay. Best regards, Etsuro Fujita