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 1lq0JW-0001Wd-P7 for pgsql-hackers@arkaria.postgresql.org; Sun, 06 Jun 2021 21:28:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lq0JV-000454-EU for pgsql-hackers@arkaria.postgresql.org; Sun, 06 Jun 2021 21:28:09 +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 1lq0JV-00044v-5k for pgsql-hackers@lists.postgresql.org; Sun, 06 Jun 2021 21:28:09 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lq0JO-00012S-MZ for pgsql-hackers@postgresql.org; Sun, 06 Jun 2021 21:28:08 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 156LRnFL744013; Sun, 6 Jun 2021 17:27:49 -0400 From: Tom Lane To: Michael Paquier cc: Justin Pryzby , 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 In-reply-to: References: <20210506162651.GJ27406@telsasoft.com> <4170264.1620321747@sss.pgh.pa.us> <20210531012500.GP2082@telsasoft.com> <2522602.1622433912@sss.pgh.pa.us> <2566986.1622468180@sss.pgh.pa.us> <2732890.1622509658@sss.pgh.pa.us> Comments: In-reply-to Michael Paquier message dated "Tue, 01 Jun 2021 16:34:44 +0900" MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0" Content-ID: <743967.1623014811.0@sss.pgh.pa.us> Date: Sun, 06 Jun 2021 17:27:49 -0400 Message-ID: <744012.1623014869@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk ------- =_aaaaaaaaaa0 Content-Type: text/plain; charset="us-ascii" Content-ID: <743967.1623014811.1@sss.pgh.pa.us> It seems like nobody's terribly interested in figuring out why pg_GSS_have_cred_cache() is misbehaving on Windows. So I took a look at disabling GSSENC in these test cases to try to silence hamerkop's test failure that way. Here's a proposed patch. It relies on setenv() being available, but I think that's fine because we link the ECPG test programs with libpgport. regards, tom lane ------- =_aaaaaaaaaa0 Content-Type: text/x-diff; name="disable-GSS-in-ECPG-test.patch"; charset="us-ascii" Content-ID: <743967.1623014811.2@sss.pgh.pa.us> Content-Description: disable-GSS-in-ECPG-test.patch Content-Transfer-Encoding: quoted-printable diff --git a/src/interfaces/ecpg/test/connect/test5.pgc b/src/interfaces/e= cpg/test/connect/test5.pgc index e712fa8778..f7263935ce 100644 --- a/src/interfaces/ecpg/test/connect/test5.pgc +++ b/src/interfaces/ecpg/test/connect/test5.pgc @@ -18,6 +18,9 @@ exec sql begin declare section; char *user=3D"regress_ecpg_user1"; exec sql end declare section; = + /* disable GSSENC to ensure stability of connection failure reports */ + setenv("PGGSSENCMODE", "disable", 1); + ECPGdebug(1, stderr); = exec sql connect to ecpg2_regression as main; diff --git a/src/interfaces/ecpg/test/expected/connect-test5.c b/src/inter= faces/ecpg/test/expected/connect-test5.c index 6ae5b589de..a86a5e4331 100644 --- a/src/interfaces/ecpg/test/expected/connect-test5.c +++ b/src/interfaces/ecpg/test/expected/connect-test5.c @@ -38,37 +38,33 @@ main(void) #line 19 "test5.pgc" = = + /* disable GSSENC to ensure stability of connection failure reports */ + setenv("PGGSSENCMODE", "disable", 1); + ECPGdebug(1, stderr); = { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0);= } -#line 23 "test5.pgc" +#line 26 "test5.pgc" = { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter user regress_ecp= g_user2 encrypted password 'insecure'", ECPGt_EOIT, ECPGt_EORT);} -#line 24 "test5.pgc" +#line 27 "test5.pgc" = { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter user regress_ecp= g_user1 encrypted password 'connectpw'", ECPGt_EOIT, ECPGt_EORT);} -#line 25 "test5.pgc" +#line 28 "test5.pgc" = { ECPGtrans(__LINE__, NULL, "commit");} -#line 26 "test5.pgc" +#line 29 "test5.pgc" = { ECPGdisconnect(__LINE__, "CURRENT");} -#line 27 "test5.pgc" +#line 30 "test5.pgc" /* <-- "main" not specified */ = strcpy(db, "ecpg2_regression"); strcpy(id, "main"); { ECPGconnect(__LINE__, 0, db , NULL, NULL , id, 0); } -#line 31 "test5.pgc" - - { ECPGdisconnect(__LINE__, id);} -#line 32 "test5.pgc" - - - { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0);= } #line 34 "test5.pgc" = - { ECPGdisconnect(__LINE__, "main");} + { ECPGdisconnect(__LINE__, id);} #line 35 "test5.pgc" = = @@ -86,21 +82,21 @@ main(void) #line 41 "test5.pgc" = = - { ECPGconnect(__LINE__, 0, "" , "regress_ecpg_user2" , "insecure" , "mai= n", 0); } + { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0);= } #line 43 "test5.pgc" = { ECPGdisconnect(__LINE__, "main");} #line 44 "test5.pgc" = = - { ECPGconnect(__LINE__, 0, "ecpg2_regression" , "regress_ecpg_user1" , "= connectpw" , "main", 0); } + { ECPGconnect(__LINE__, 0, "" , "regress_ecpg_user2" , "insecure" , "mai= n", 0); } #line 46 "test5.pgc" = { ECPGdisconnect(__LINE__, "main");} #line 47 "test5.pgc" = = - { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression= " , "regress_ecpg_user1" , "connectpw" , "main", 0); } + { ECPGconnect(__LINE__, 0, "ecpg2_regression" , "regress_ecpg_user1" , "= connectpw" , "main", 0); } #line 49 "test5.pgc" = { ECPGdisconnect(__LINE__, "main");} @@ -114,48 +110,55 @@ main(void) #line 53 "test5.pgc" = = - { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression= " , user , "connectpw" , "main", 0); } + { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression= " , "regress_ecpg_user1" , "connectpw" , "main", 0); } #line 55 "test5.pgc" = { ECPGdisconnect(__LINE__, "main");} #line 56 "test5.pgc" = = - { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression= ?connect_timeout=3D180 & client_encoding=3Dlatin1" , "regress_ecpg_user1" = , "connectpw" , "main", 0); } + { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression= " , user , "connectpw" , "main", 0); } #line 58 "test5.pgc" = { ECPGdisconnect(__LINE__, "main");} #line 59 "test5.pgc" = = - { ECPGconnect(__LINE__, 0, "unix:postgresql://200.46.204.71/ecpg2_regres= sion" , "regress_ecpg_user1" , "connectpw" , "main", 0); } + { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/ecpg2_regression= ?connect_timeout=3D180 & client_encoding=3Dlatin1" , "regress_ecpg_user1" = , "connectpw" , "main", 0); } #line 61 "test5.pgc" = { ECPGdisconnect(__LINE__, "main");} #line 62 "test5.pgc" = = - { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/" , "regress_ecp= g_user2" , "insecure" , "main", 0); } + { ECPGconnect(__LINE__, 0, "unix:postgresql://200.46.204.71/ecpg2_regres= sion" , "regress_ecpg_user1" , "connectpw" , "main", 0); } #line 64 "test5.pgc" = { ECPGdisconnect(__LINE__, "main");} #line 65 "test5.pgc" = = + { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/" , "regress_ecp= g_user2" , "insecure" , "main", 0); } +#line 67 "test5.pgc" + + { ECPGdisconnect(__LINE__, "main");} +#line 68 "test5.pgc" + + /* connect twice */ { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0);= } -#line 68 "test5.pgc" +#line 71 "test5.pgc" = { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0);= } -#line 69 "test5.pgc" +#line 72 "test5.pgc" = { ECPGdisconnect(__LINE__, "main");} -#line 70 "test5.pgc" +#line 73 "test5.pgc" = = /* not connected */ { ECPGdisconnect(__LINE__, "nonexistent");} -#line 73 "test5.pgc" +#line 76 "test5.pgc" = = return 0; diff --git a/src/interfaces/ecpg/test/expected/connect-test5.stderr b/src/= interfaces/ecpg/test/expected/connect-test5.stderr index a15f344320..abab1ba5a2 100644 --- a/src/interfaces/ecpg/test/expected/connect-test5.stderr +++ b/src/interfaces/ecpg/test/expected/connect-test5.stderr @@ -2,19 +2,19 @@ [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ECPGconnect: opening database ecpg2_regression on por= t = [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 24: query: alter user regress_ecpg_user2 e= ncrypted password 'insecure'; with 0 parameter(s) on connection main +[NO_PID]: ecpg_execute on line 27: query: alter user regress_ecpg_user2 e= ncrypted password 'insecure'; with 0 parameter(s) on connection main [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 24: using PQexec +[NO_PID]: ecpg_execute on line 27: using PQexec [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_process_output on line 24: OK: ALTER ROLE +[NO_PID]: ecpg_process_output on line 27: OK: ALTER ROLE [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 25: query: alter user regress_ecpg_user1 e= ncrypted password 'connectpw'; with 0 parameter(s) on connection main +[NO_PID]: ecpg_execute on line 28: query: alter user regress_ecpg_user1 e= ncrypted password 'connectpw'; with 0 parameter(s) on connection main [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_execute on line 25: using PQexec +[NO_PID]: ecpg_execute on line 28: using PQexec [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ecpg_process_output on line 25: OK: ALTER ROLE +[NO_PID]: ecpg_process_output on line 28: OK: ALTER ROLE [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ECPGtrans on line 26: action "commit"; connection "main" +[NO_PID]: ECPGtrans on line 29: action "commit"; connection "main" [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_finish: connection main closed [NO_PID]: sqlca: code: 0, state: 00000 @@ -40,9 +40,9 @@ [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_finish: connection main closed [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: raising sqlcode -402 on line 43: could not connect to database = "" on line 43 +[NO_PID]: raising sqlcode -402 on line 46: could not connect to database = "" on line 46 [NO_PID]: sqlca: code: -402, state: 08001 -[NO_PID]: raising sqlcode -220 on line 44: connection "main" does not exi= st on line 44 +[NO_PID]: raising sqlcode -220 on line 47: connection "main" does not exi= st on line 47 [NO_PID]: sqlca: code: -220, state: 08003 [NO_PID]: ECPGconnect: opening database ecpg2_regression on por= t for user regress_ecpg_user1 [NO_PID]: sqlca: code: 0, state: 00000 @@ -64,11 +64,11 @@ [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_finish: connection main closed [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: ECPGconnect: non-localhost access via sockets on line 61 +[NO_PID]: ECPGconnect: non-localhost access via sockets on line 64 [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: raising sqlcode -402 on line 61: could not connect to database = "ecpg2_regression" on line 61 +[NO_PID]: raising sqlcode -402 on line 64: could not connect to database = "ecpg2_regression" on line 64 [NO_PID]: sqlca: code: -402, state: 08001 -[NO_PID]: raising sqlcode -220 on line 62: connection "main" does not exi= st on line 62 +[NO_PID]: raising sqlcode -220 on line 65: connection "main" does not exi= st on line 65 [NO_PID]: sqlca: code: -220, state: 08003 [NO_PID]: ECPGconnect: opening database on port for user regress_ecpg_user2 [NO_PID]: sqlca: code: 0, state: 00000 @@ -76,9 +76,9 @@ [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_finish: connection main closed [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: raising sqlcode -402 on line 64: could not connect to database = "" on line 64 +[NO_PID]: raising sqlcode -402 on line 67: could not connect to database = "" on line 67 [NO_PID]: sqlca: code: -402, state: 08001 -[NO_PID]: raising sqlcode -220 on line 65: connection "main" does not exi= st on line 65 +[NO_PID]: raising sqlcode -220 on line 68: connection "main" does not exi= st on line 68 [NO_PID]: sqlca: code: -220, state: 08003 [NO_PID]: ECPGconnect: opening database ecpg2_regression on por= t = [NO_PID]: sqlca: code: 0, state: 00000 @@ -86,5 +86,5 @@ [NO_PID]: sqlca: code: 0, state: 00000 [NO_PID]: ecpg_finish: connection main closed [NO_PID]: sqlca: code: 0, state: 00000 -[NO_PID]: raising sqlcode -220 on line 73: connection "nonexistent" does = not exist on line 73 +[NO_PID]: raising sqlcode -220 on line 76: connection "nonexistent" does = not exist on line 76 [NO_PID]: sqlca: code: -220, state: 08003 ------- =_aaaaaaaaaa0--