Re: Multiple hosts in connection string failed to failover in non-hot standby mode - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Multiple hosts in connection string failed to failover in non-hot standby mode
Date
Msg-id 1372552.1623254710@sss.pgh.pa.us
Whole thread Raw
In response to Re: Multiple hosts in connection string failed to failover in non-hot standby mode  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Multiple hosts in connection string failed to failover in non-hot standby mode
List pgsql-hackers
I wrote:
> ...  I'd be okay with dropping that test; or maybe we could
> fix things so that the default case succeeds?

Here's a draft patch that renames regress_ecpg_user2 to ecpg2_regression,
which matches the name of one of the databases used, allowing the test
cases with defaulted database name to succeed.  That gets rid of one of
the problematic diffs.  As it stood, though, that meant that connect/test5
wasn't exercising the connection-failure code path at all, which didn't
seem like what we want.  So I adjusted the second place that had been
failing to again fail on no-such-database, and stuck in gssencmode=disable
so that we shouldn't get any test diff on hamerkop.

            regards, tom lane

diff --git a/src/interfaces/ecpg/test/Makefile b/src/interfaces/ecpg/test/Makefile
index be53b7b94d..abea3fcc85 100644
--- a/src/interfaces/ecpg/test/Makefile
+++ b/src/interfaces/ecpg/test/Makefile
@@ -77,7 +77,7 @@ $(remaining_files_build): $(abs_builddir)/%: $(srcdir)/%
 endif

 # Common options for tests. Also pick up anything passed in EXTRA_REGRESS_OPTS
-REGRESS_OPTS = --dbname=ecpg1_regression,ecpg2_regression --create-role=regress_ecpg_user1,regress_ecpg_user2
$(EXTRA_REGRESS_OPTS)
+REGRESS_OPTS = --dbname=ecpg1_regression,ecpg2_regression --create-role=regress_ecpg_user1,ecpg2_regression
$(EXTRA_REGRESS_OPTS)

 check: all
     $(with_temp_install) ./pg_regress $(REGRESS_OPTS) --temp-instance=./tmp_check $(TEMP_CONF) --bindir=
$(pg_regress_locale_flags)$(THREAD) --schedule=$(srcdir)/ecpg_schedule sql/twophase 
diff --git a/src/interfaces/ecpg/test/connect/test1.pgc b/src/interfaces/ecpg/test/connect/test1.pgc
index 961bd72ef2..77e571ec86 100644
--- a/src/interfaces/ecpg/test/connect/test1.pgc
+++ b/src/interfaces/ecpg/test/connect/test1.pgc
@@ -26,16 +26,16 @@ exec sql end declare section;
     exec sql connect to ecpg2_regression@localhost as main;
     exec sql disconnect main;

-    exec sql connect to @localhost as main user regress_ecpg_user2;
+    exec sql connect to @localhost as main user ecpg2_regression;
     exec sql disconnect main;

-    /* exec sql connect to :@TEMP_PORT@ as main user regress_ecpg_user2;
+    /* exec sql connect to :@TEMP_PORT@ as main user ecpg2_regression;
     exec sql disconnect main; */

     exec sql connect to tcp:postgresql://localhost/ecpg2_regression user regress_ecpg_user1 identified by connectpw;
     exec sql disconnect;

-    exec sql connect to tcp:postgresql://localhost/ user regress_ecpg_user2;
+    exec sql connect to tcp:postgresql://localhost/ user ecpg2_regression;
     exec sql disconnect;

     strcpy(pw, "connectpw");
diff --git a/src/interfaces/ecpg/test/connect/test5.pgc b/src/interfaces/ecpg/test/connect/test5.pgc
index e712fa8778..96a7b3e892 100644
--- a/src/interfaces/ecpg/test/connect/test5.pgc
+++ b/src/interfaces/ecpg/test/connect/test5.pgc
@@ -21,7 +21,7 @@ exec sql end declare section;
     ECPGdebug(1, stderr);

     exec sql connect to ecpg2_regression as main;
-    exec sql alter user regress_ecpg_user2 ENCRYPTED PASSWORD 'insecure';
+    exec sql alter user ecpg2_regression ENCRYPTED PASSWORD 'insecure';
     exec sql alter user regress_ecpg_user1 ENCRYPTED PASSWORD 'connectpw';
     exec sql commit;
     exec sql disconnect;  /* <-- "main" not specified */
@@ -40,7 +40,7 @@ exec sql end declare section;
     exec sql connect to 'ecpg2_regression' as main;
     exec sql disconnect main;

-    exec sql connect to as main user regress_ecpg_user2/insecure;
+    exec sql connect to as main user ecpg2_regression/insecure;
     exec sql disconnect main;

     exec sql connect to ecpg2_regression as main user regress_ecpg_user1/connectpw;
@@ -61,7 +61,7 @@ exec sql end declare section;
     exec sql connect to "unix:postgresql://200.46.204.71/ecpg2_regression" as main user regress_ecpg_user1/connectpw;
     exec sql disconnect main;

-    exec sql connect to unix:postgresql://localhost/ as main user regress_ecpg_user2 IDENTIFIED BY insecure;
+    exec sql connect to "unix:postgresql://localhost/no_such_db?gssencmode=disable" as main user ecpg2_regression
IDENTIFIEDBY insecure; 
     exec sql disconnect main;

     /* connect twice */
diff --git a/src/interfaces/ecpg/test/expected/connect-test1-minGW32.stderr
b/src/interfaces/ecpg/test/expected/connect-test1-minGW32.stderr
index c5b5248eb2..e5f16bd854 100644
--- a/src/interfaces/ecpg/test/expected/connect-test1-minGW32.stderr
+++ b/src/interfaces/ecpg/test/expected/connect-test1-minGW32.stderr
@@ -14,30 +14,18 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_finish: connection main closed
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port <DEFAULT>  for user regress_ecpg_user2
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: connection to server failed: FATAL:  database "regress_ecpg_user2" does not exist
+[NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port <DEFAULT>  for user ecpg2_regression
 [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 29: could not connect to database "<DEFAULT>" on line 29
-[NO_PID]: sqlca: code: -402, state: 08001
-[NO_PID]: raising sqlcode -220 on line 30: connection "main" does not exist on line 30
-[NO_PID]: sqlca: code: -220, state: 08003
 [NO_PID]: ECPGconnect: opening database ecpg2_regression on localhost port <DEFAULT>  for user regress_ecpg_user1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_finish: connection ecpg2_regression closed
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port <DEFAULT>  for user regress_ecpg_user2
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: connection to server failed: FATAL:  database "regress_ecpg_user2" does not exist
+[NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port <DEFAULT>  for user ecpg2_regression
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_finish: connection (null) closed
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: raising sqlcode -402 on line 38: could not connect to database "<DEFAULT>" on line 38
-[NO_PID]: sqlca: code: -402, state: 08001
-[NO_PID]: raising sqlcode -220 on line 39: connection "CURRENT" does not exist on line 39
-[NO_PID]: sqlca: code: -220, state: 08003
 [NO_PID]: ECPGconnect: opening database ecpg2_regression on localhost port <DEFAULT>  for user regress_ecpg_user1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_finish: connection ecpg2_regression closed
diff --git a/src/interfaces/ecpg/test/expected/connect-test1.c b/src/interfaces/ecpg/test/expected/connect-test1.c
index ffd24e2fc8..40d5aca4cd 100644
--- a/src/interfaces/ecpg/test/expected/connect-test1.c
+++ b/src/interfaces/ecpg/test/expected/connect-test1.c
@@ -53,14 +53,14 @@ main(void)
 #line 27 "test1.pgc"


-    { ECPGconnect(__LINE__, 0, "@localhost" , "regress_ecpg_user2" , NULL , "main", 0); }
+    { ECPGconnect(__LINE__, 0, "@localhost" , "ecpg2_regression" , NULL , "main", 0); }
 #line 29 "test1.pgc"

     { ECPGdisconnect(__LINE__, "main");}
 #line 30 "test1.pgc"


-    /* exec sql connect to :@TEMP_PORT@ as main user regress_ecpg_user2;
+    /* exec sql connect to :@TEMP_PORT@ as main user ecpg2_regression;
     exec sql disconnect main; */

     { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost/ecpg2_regression" , "regress_ecpg_user1" , "connectpw" ,
NULL,0); } 
@@ -70,7 +70,7 @@ main(void)
 #line 36 "test1.pgc"


-    { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost/" , "regress_ecpg_user2" , NULL , NULL, 0); }
+    { ECPGconnect(__LINE__, 0, "tcp:postgresql://localhost/" , "ecpg2_regression" , NULL , NULL, 0); }
 #line 38 "test1.pgc"

     { ECPGdisconnect(__LINE__, "CURRENT");}
diff --git a/src/interfaces/ecpg/test/expected/connect-test1.stderr
b/src/interfaces/ecpg/test/expected/connect-test1.stderr
index 073951c0ed..14f6a4ed5c 100644
--- a/src/interfaces/ecpg/test/expected/connect-test1.stderr
+++ b/src/interfaces/ecpg/test/expected/connect-test1.stderr
@@ -14,30 +14,18 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_finish: connection main closed
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port <DEFAULT>  for user regress_ecpg_user2
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: connection to server failed: FATAL:  database "regress_ecpg_user2" does not exist
+[NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port <DEFAULT>  for user ecpg2_regression
 [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 29: could not connect to database "<DEFAULT>" on line 29
-[NO_PID]: sqlca: code: -402, state: 08001
-[NO_PID]: raising sqlcode -220 on line 30: connection "main" does not exist on line 30
-[NO_PID]: sqlca: code: -220, state: 08003
 [NO_PID]: ECPGconnect: opening database ecpg2_regression on localhost port <DEFAULT>  for user regress_ecpg_user1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_finish: connection ecpg2_regression closed
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port <DEFAULT>  for user regress_ecpg_user2
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: connection to server failed: FATAL:  database "regress_ecpg_user2" does not exist
+[NO_PID]: ECPGconnect: opening database <DEFAULT> on localhost port <DEFAULT>  for user ecpg2_regression
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_finish: connection (null) closed
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: raising sqlcode -402 on line 38: could not connect to database "<DEFAULT>" on line 38
-[NO_PID]: sqlca: code: -402, state: 08001
-[NO_PID]: raising sqlcode -220 on line 39: connection "CURRENT" does not exist on line 39
-[NO_PID]: sqlca: code: -220, state: 08003
 [NO_PID]: ECPGconnect: opening database ecpg2_regression on localhost port <DEFAULT>  for user regress_ecpg_user1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_finish: connection ecpg2_regression closed
diff --git a/src/interfaces/ecpg/test/expected/connect-test5.c b/src/interfaces/ecpg/test/expected/connect-test5.c
index 6ae5b589de..c3543f4b57 100644
--- a/src/interfaces/ecpg/test/expected/connect-test5.c
+++ b/src/interfaces/ecpg/test/expected/connect-test5.c
@@ -43,7 +43,7 @@ main(void)
     { ECPGconnect(__LINE__, 0, "ecpg2_regression" , NULL, NULL , "main", 0); }
 #line 23 "test5.pgc"

-    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter user regress_ecpg_user2 encrypted password 'insecure'",
ECPGt_EOIT,ECPGt_EORT);} 
+    { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter user ecpg2_regression encrypted password 'insecure'",
ECPGt_EOIT,ECPGt_EORT);} 
 #line 24 "test5.pgc"

     { ECPGdo(__LINE__, 0, 1, NULL, 0, ECPGst_normal, "alter user regress_ecpg_user1 encrypted password 'connectpw'",
ECPGt_EOIT,ECPGt_EORT);} 
@@ -86,7 +86,7 @@ main(void)
 #line 41 "test5.pgc"


-    { ECPGconnect(__LINE__, 0, "" , "regress_ecpg_user2" , "insecure" , "main", 0); }
+    { ECPGconnect(__LINE__, 0, "" , "ecpg2_regression" , "insecure" , "main", 0); }
 #line 43 "test5.pgc"

     { ECPGdisconnect(__LINE__, "main");}
@@ -135,7 +135,7 @@ main(void)
 #line 62 "test5.pgc"


-    { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/" , "regress_ecpg_user2" , "insecure" , "main", 0); }
+    { ECPGconnect(__LINE__, 0, "unix:postgresql://localhost/no_such_db?gssencmode=disable" , "ecpg2_regression" ,
"insecure", "main", 0); } 
 #line 64 "test5.pgc"

     { ECPGdisconnect(__LINE__, "main");}
diff --git a/src/interfaces/ecpg/test/expected/connect-test5.stderr
b/src/interfaces/ecpg/test/expected/connect-test5.stderr
index a15f344320..c5fe86f4c5 100644
--- a/src/interfaces/ecpg/test/expected/connect-test5.stderr
+++ b/src/interfaces/ecpg/test/expected/connect-test5.stderr
@@ -2,7 +2,7 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ECPGconnect: opening database ecpg2_regression on <DEFAULT> port <DEFAULT>
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ecpg_execute on line 24: query: alter user regress_ecpg_user2 encrypted password 'insecure'; with 0
parameter(s)on connection main 
+[NO_PID]: ecpg_execute on line 24: query: alter user ecpg2_regression encrypted 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]: sqlca: code: 0, state: 00000
@@ -34,16 +34,10 @@
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_finish: connection main closed
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: opening database <DEFAULT> on <DEFAULT> port <DEFAULT>  for user regress_ecpg_user2
-[NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: connection to server failed: FATAL:  database "regress_ecpg_user2" does not exist
+[NO_PID]: ECPGconnect: opening database <DEFAULT> on <DEFAULT> port <DEFAULT>  for user ecpg2_regression
 [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 "<DEFAULT>" on line 43
-[NO_PID]: sqlca: code: -402, state: 08001
-[NO_PID]: raising sqlcode -220 on line 44: connection "main" does not exist on line 44
-[NO_PID]: sqlca: code: -220, state: 08003
 [NO_PID]: ECPGconnect: opening database ecpg2_regression on <DEFAULT> port <DEFAULT>  for user regress_ecpg_user1
 [NO_PID]: sqlca: code: 0, state: 00000
 [NO_PID]: ecpg_finish: connection main closed
@@ -70,13 +64,13 @@
 [NO_PID]: sqlca: code: -402, state: 08001
 [NO_PID]: raising sqlcode -220 on line 62: connection "main" does not exist on line 62
 [NO_PID]: sqlca: code: -220, state: 08003
-[NO_PID]: ECPGconnect: opening database <DEFAULT> on <DEFAULT> port <DEFAULT>  for user regress_ecpg_user2
+[NO_PID]: ECPGconnect: opening database no_such_db on <DEFAULT> port <DEFAULT> with options gssencmode=disable for
userecpg2_regression 
 [NO_PID]: sqlca: code: 0, state: 00000
-[NO_PID]: ECPGconnect: connection to server failed: FATAL:  database "regress_ecpg_user2" does not exist
+[NO_PID]: ECPGconnect: connection to server failed: FATAL:  database "no_such_db" does not exist
 [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 "<DEFAULT>" on line 64
+[NO_PID]: raising sqlcode -402 on line 64: could not connect to database "no_such_db" on line 64
 [NO_PID]: sqlca: code: -402, state: 08001
 [NO_PID]: raising sqlcode -220 on line 65: connection "main" does not exist on line 65
 [NO_PID]: sqlca: code: -220, state: 08003
diff --git a/src/interfaces/ecpg/test/regression.h b/src/interfaces/ecpg/test/regression.h
index 6b7fba1bfd..68ab1417a2 100644
--- a/src/interfaces/ecpg/test/regression.h
+++ b/src/interfaces/ecpg/test/regression.h
@@ -2,4 +2,4 @@ exec        sql define REGRESSDB1 ecpg1_regression;
 exec        sql define REGRESSDB2 ecpg2_regression;

 exec        sql define REGRESSUSER1 regress_ecpg_user1;
-exec        sql define REGRESSUSER2 regress_ecpg_user2;
+exec        sql define REGRESSUSER2 ecpg2_regression;
diff --git a/src/tools/msvc/vcregress.pl b/src/tools/msvc/vcregress.pl
index 35e8f67f01..e7a15bbaa6 100644
--- a/src/tools/msvc/vcregress.pl
+++ b/src/tools/msvc/vcregress.pl
@@ -179,7 +179,7 @@ sub ecpgcheck
         "../../../../$Config/pg_regress_ecpg/pg_regress_ecpg",
         "--bindir=",
         "--dbname=ecpg1_regression,ecpg2_regression",
-        "--create-role=regress_ecpg_user1,regress_ecpg_user2",
+        "--create-role=regress_ecpg_user1,ecpg2_regression",
         "--schedule=${schedule}_schedule",
         "--encoding=SQL_ASCII",
         "--no-locale",

pgsql-hackers by date:

Previous
From: Matthias van de Meent
Date:
Subject: Re: pg14b1 stuck in lazy_scan_prune/heap_page_prune of pg_statistic
Next
From: Robert Haas
Date:
Subject: Re: [bug?] Missed parallel safety checks, and wrong parallel safety