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 1poKNX-0006l8-P3 for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Apr 2023 08:38:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1poKNU-0003Nd-OI for pgsql-hackers@arkaria.postgresql.org; Mon, 17 Apr 2023 08:38:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1poKNU-0003NU-EA for pgsql-hackers@lists.postgresql.org; Mon, 17 Apr 2023 08:38:24 +0000 Received: from mail-pj1-x1029.google.com ([2607:f8b0:4864:20::1029]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1poKNO-003OB9-JO for pgsql-hackers@lists.postgresql.org; Mon, 17 Apr 2023 08:38:23 +0000 Received: by mail-pj1-x1029.google.com with SMTP id kx14so4804706pjb.1 for ; Mon, 17 Apr 2023 01:38:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681720696; x=1684312696; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:from:subject:cc:to:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=BfONYZ+3FgcdaWIuhZI3y46Wd8dUQulrJ8wkbMpS64Q=; b=Wrt/V/MOV7E1hdzwuZ5NzYMzjnU83e2inXjwOK35wtn2xkNywJAFQH1ydV6CCXTv0l jxoYzd0C3tp3vwnx9GL2qUQwI3i5GfAGtCEPnni0G6DemrA4Z2EZ/3x/N6hgZfYqEKx1 C0Fr9ZXQOADvdsQVT4jBAlGXbcaERpkQ+VwCHGkLWCXA2/5n/616gmtiL2Zw3VNMQ59a kvRCBz8IPI4AkXpBd4gDXx4+03404Dpob8wSGH2rbkvlyGbThAArLssbciiv5lBis0KJ jrWykab/prh0ePuoy+grU0BoL6UbBJLu3VNZnhiO1A0fHt5WmiFcwx0Ty391v4OG2FMZ 6iAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681720696; x=1684312696; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:from:subject:cc:to:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=BfONYZ+3FgcdaWIuhZI3y46Wd8dUQulrJ8wkbMpS64Q=; b=B6MTUXehVdnUHZfHfeOAJQ0NKBlRNqxvDn8hXdRPXyHyh3FrI6PXhUsp4lbpjOd9Ob bagSj1vM5sd5CIQVtyUHPBzjaMiEs9Q90FqL15X++Cd68hoTyRf31N7EH9cm3JgAGvGj SMZUijR6DQDDKGv+d+pkPE/ZguThhffqxsA0GBaI6OX0wSzohNLcWmnokO5znp07wn93 ZwHldgWSuxcqcMHMxfoaU1sO9EJgwwZnj1ol1nDb0Yx9n5haUWvEkpR5PktUb1C71471 YHA1xsgNvt35WmzkqkQ3mvrmJX2O85YqxH4+sbOwMNCwIavHbtyBOVtlq/9jRd72Qg0o NHfQ== X-Gm-Message-State: AAQBX9dxQSQkUO9HFkmEX5RDV3V0spABaQQbLjFUQPPpYhj5gheQCcg0 cNpzgEHUHeFP39GUy0HQqrs= X-Google-Smtp-Source: AKy350azLAXEyJ5FEeexQHnxFQaPlZYOaAfuS4qSLeXuqNka8paww+nGCq92V5MZiQUlKtrcZh0tfA== X-Received: by 2002:a17:90a:ce18:b0:22c:59c3:8694 with SMTP id f24-20020a17090ace1800b0022c59c38694mr14245159pju.44.1681720696105; Mon, 17 Apr 2023 01:38:16 -0700 (PDT) Received: from localhost (KD036014041111.ppp-bb.dion.ne.jp. [36.14.41.111]) by smtp.gmail.com with ESMTPSA id m9-20020a654c89000000b00502ecb91940sm6680779pgt.55.2023.04.17.01.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 01:38:15 -0700 (PDT) Date: Mon, 17 Apr 2023 17:38:12 +0900 (JST) Message-Id: <20230417.173812.452521384661813597.horikyota.ntt@gmail.com> To: etsuro.fujita@gmail.com Cc: masao.fujii@oss.nttdata.com, pgsql-hackers@lists.postgresql.org Subject: Re: Issue in postgres_fdw causing unnecessary wait for cancel request reply From: Kyotaro Horiguchi In-Reply-To: References: <67cad2e7-f9c1-5eb0-a0be-99fd78571906@oss.nttdata.com> User-Agent: Mew version 6.8 on Emacs 27.2 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk At Mon, 17 Apr 2023 15:21:02 +0900, Etsuro Fujita wrote in > > >> Although the primary message is the same, the supplemental message pro= > vides additional context that can help distinguish which function is report= > ing the message. > > > > > > If the user is familiar with the PQgetCancel/PQcancel internals, this > > > is true, but if not, I do not think this is always true. Consider > > > this error message, for example: > > > > > > 2023-04-14 17:48:55.862 JST [24344] WARNING: could not send cancel > > > request: invalid integer value "99999999999" for connection option > > > "keepalives" > > > > > > It would be hard for users without the knowledge about those internals > > > to distinguish that from this message. For average users, I think it > > > would be good to use a more distinguishable error message. > > > > In this case, I believe that they should be able to understand that an in= > valid integer value "99999999999" was specified in the "keepalives" connect= > ion option, which caused the warning message. Then, they would need to chec= > k the setting of the "keepalives" option and correct it if necessary. > > Maybe my explanation was not clear. Let me explain. Assume that a > user want to identify the place where the above error was thrown. > Using grep with =E2=80=9Dcould not send cancel request=E2=80=9D, the user c= > an find the > two places emitting the message in pgfdw_cancel_query_begin: one for > PQgetCancel and one for PQcancel. If the user are familiar with the > PQgetCancel/PQcancel internals, the user can determine, from the > supplemental message, that the error was thrown by the former. But if > not, the user cannot do so. To support the unfamiliar user as well, I > think it would be a good idea to use a more appropriate message for > PQgetCancel that is different from "could not send cancel request=E2=80=9D. > > (I agree that most users would not care about the places where errors > were thrown, but I think some users would, and actually, I do when > investigating unfamiliar errors.) If PGgetCancel() fails due to invalid keepliave-related values, It seems like a bug that needs fixing, regardless of whether we display an error message when PGgetCacncel() fails. The only error case of PGgetCancel() that could occur in pgfdw_cancel_query_begin() is a malloc() failure, which currently does not set an error message (I'm not sure we can do that in that case, though..). In my opinion, PQconnectPoll and PQgetCancel should use the same parsing function or PQconnectPoll should set parsed values, making unnecessary for PQgetCancel to parse the same parameter again. Additionally, PQgetCancel should set appropriate error messages for all failure modes. regards. -- Kyotaro Horiguchi NTT Open Source Software Center