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 1lnWg6-0008OH-Tb for pgsql-hackers@arkaria.postgresql.org; Mon, 31 May 2021 01:25:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lnWg5-0002TK-M6 for pgsql-hackers@arkaria.postgresql.org; Mon, 31 May 2021 01:25:13 +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 1lnWg5-0002T9-AQ for pgsql-hackers@lists.postgresql.org; Mon, 31 May 2021 01:25:13 +0000 Received: from mail-io1-xd35.google.com ([2607:f8b0:4864:20::d35]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1lnWfw-0002Yc-33 for pgsql-hackers@postgresql.org; Mon, 31 May 2021 01:25:12 +0000 Received: by mail-io1-xd35.google.com with SMTP id v9so10331415ion.11 for ; Sun, 30 May 2021 18:25:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=telsasoft-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=AJy1OfSeIFESSk7mDLsKIqmoEpPSmWA2bWfwrLLGpZk=; b=y0xJMEbhMKXC+lSo3Xn0y+T7lCck3jt6+LU1ReW2iSpPXrH6NHG2FGHiHLLmSnJbjG 9SAuKTQQqVw1lUAzU0vEyED8auLh0C0UGio4eiUwiQIqOVuOf+MJTUHV4Upy33UepcNg +1KarxKwdbExYxvk4t74pcZmWgkBpCXgCYiCZjYB3yP/08h5qXk3hbV2o9di5bMRbHtk +ZUKPnGhpbxCdKwBMTeFiLesNTo5VgKyy00nvBkFsILmkbvutoM4ly0pzCkZPHaGaC+m oulDPjWhK9dzHtP32LzaOzKWVEvbG2jPz9+nl7rSIYkDM4Aqa1sVPAFReP+oaHtBMWpD bsPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=AJy1OfSeIFESSk7mDLsKIqmoEpPSmWA2bWfwrLLGpZk=; b=gIcGpUxleSde6MRzAIS4uLkMDZsMypa77ztfbTPSqHxxzcljJfE2ylYNVZOlP6hkKg e3U+JHh1OhOzR98iag41W0Q7DMEa8oGTC4/VELc23l3hULKbAjKKO0i5iLSuFh1vm0TA sN7LO8c+KUEnmShQoZdg4kyWO/wmoxaPvUVYTxF4lVRLhHIyZBbVcYF+mNvDmPzzb8R2 h7N5T2W3scZUmnXf3OwEtahaeLnj83MPoBzNC5EdiMgC+35AZXFrj6Kgl+auFYo8BKRm 1660yi3kaoY++0+mkfiUQAP8qLUNJ9zBB6QqLA3NnO5DUPq9Ek6jr4kaXarxyQmJxKXA 2fsA== X-Gm-Message-State: AOAM5331gXX5u55jY074n4643bBfWnQI0E9daoUHwkkNiysL3/qX+JRN ghp8Chk05wiaWresHtuQvAtlIA== X-Google-Smtp-Source: ABdhPJwEqf3w+4i7AlEuWcIKo5DW0HDwPoWyHMkJ/7S92YgO6QcIb0LYIdck9i4zni5UPFehWJSSXQ== X-Received: by 2002:a05:6638:b84:: with SMTP id b4mr17998809jad.122.1622424302553; Sun, 30 May 2021 18:25:02 -0700 (PDT) Received: from pryzbyj.telsasoft (charmander.telsasoft.com. [50.244.222.1]) by smtp.gmail.com with ESMTPSA id e15sm7132675ile.63.2021.05.30.18.25.01 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 May 2021 18:25:02 -0700 (PDT) Received: by pryzbyj.telsasoft (Postfix, from userid 1000) id D0594800A7A; Sun, 30 May 2021 20:25:00 -0500 (CDT) Date: Sun, 30 May 2021 20:25:00 -0500 From: Justin Pryzby To: Tom Lane Cc: Hubert Zhang , tsunakawa.takay@fujitsu.com, pgsql-hackers@postgresql.org, Andreas Seltenreich , Bruce Momjian Subject: Re: Multiple hosts in connection string failed to failover in non-hot standby mode Message-ID: <20210531012500.GP2082@telsasoft.com> References: <229507.1610056206@sss.pgh.pa.us> <770711.1610318330@sss.pgh.pa.us> <20210506162651.GJ27406@telsasoft.com> <4170264.1620321747@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4170264.1620321747@sss.pgh.pa.us> User-Agent: Mutt/1.9.4 (2018-02-28) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, May 06, 2021 at 01:22:27PM -0400, Tom Lane wrote: > Justin Pryzby writes: > > 52a10224 broke sqlsmith, of all things. > > > It was using errmsg as a test of success, instead of checking if the connection > > result wasn't null: > > > conn = PQconnectdb(conninfo.c_str()); > > char *errmsg = PQerrorMessage(conn); > > if (strlen(errmsg)) > > throw dut::broken(errmsg, "08001"); > > > That's clearly the wrong thing to do, but maybe this should be described in the > > release notes as a compatibility issue, in case other people had the same idea. > > Clearing errorMessage during success is an option.. > > Hm. I'd debated whether to clear conn->errorMessage at the end of > a successful connection sequence, and decided not to on the grounds > that it might be interesting info (eg it could tell you why you > ended up connected to server Y and not server X). But perhaps > it's too much of a compatibility break for this small benefit. I don't care if applications break because they check the errorMessage instead of the return value... ..But I think it's not useful to put details into errorMessage on success, unless you're going to document that. It would never have occurred to me to look there, or that it would even be safe. -- Justin