mirror of https://github.com/citusdata/citus.git
Merge branch 'main' into speed-up-SequenceUsedInDistributedTable
commit
7540e25760
|
@ -271,9 +271,24 @@ GetConnParams(ConnectionHashKey *key, char ***keywords, char ***values,
|
||||||
* We allocate everything in the provided context so as to facilitate using
|
* We allocate everything in the provided context so as to facilitate using
|
||||||
* pfree on all runtime parameters when connections using these entries are
|
* pfree on all runtime parameters when connections using these entries are
|
||||||
* invalidated during config reloads.
|
* invalidated during config reloads.
|
||||||
|
*
|
||||||
|
* Also, when "host" is already provided in global parameters, we use hostname
|
||||||
|
* from the key as "hostaddr" instead of "host" to avoid host name lookup. In
|
||||||
|
* that case, the value for "host" becomes useful only if the authentication
|
||||||
|
* method requires it.
|
||||||
*/
|
*/
|
||||||
|
bool gotHostParamFromGlobalParams = false;
|
||||||
|
for (Size paramIndex = 0; paramIndex < ConnParams.size; paramIndex++)
|
||||||
|
{
|
||||||
|
if (strcmp(ConnParams.keywords[paramIndex], "host") == 0)
|
||||||
|
{
|
||||||
|
gotHostParamFromGlobalParams = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const char *runtimeKeywords[] = {
|
const char *runtimeKeywords[] = {
|
||||||
"host",
|
gotHostParamFromGlobalParams ? "hostaddr" : "host",
|
||||||
"port",
|
"port",
|
||||||
"dbname",
|
"dbname",
|
||||||
"user",
|
"user",
|
||||||
|
|
|
@ -2929,6 +2929,7 @@ NodeConninfoGucCheckHook(char **newval, void **extra, GucSource source)
|
||||||
#if defined(ENABLE_GSS) && defined(ENABLE_SSPI)
|
#if defined(ENABLE_GSS) && defined(ENABLE_SSPI)
|
||||||
"gsslib",
|
"gsslib",
|
||||||
#endif
|
#endif
|
||||||
|
"host",
|
||||||
"keepalives",
|
"keepalives",
|
||||||
"keepalives_count",
|
"keepalives_count",
|
||||||
"keepalives_idle",
|
"keepalives_idle",
|
||||||
|
|
|
@ -520,5 +520,61 @@ show citus.node_conninfo;
|
||||||
|
|
||||||
-- Should work again
|
-- Should work again
|
||||||
ALTER TABLE test ADD COLUMN e INT;
|
ALTER TABLE test ADD COLUMN e INT;
|
||||||
|
-- show that we allow providing "host" param via citus.node_conninfo
|
||||||
|
ALTER SYSTEM SET citus.node_conninfo = 'sslmode=require host=nosuchhost';
|
||||||
|
SELECT pg_reload_conf();
|
||||||
|
pg_reload_conf
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT pg_sleep(0.1);
|
||||||
|
pg_sleep
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- fails due to invalid host
|
||||||
|
SELECT COUNT(*)>=0 FROM test;
|
||||||
|
WARNING: connection to the remote node postgres@localhost:xxxxx failed with the following error: could not parse network address "localhost": Name or service not known
|
||||||
|
ERROR: connection to the remote node postgres@localhost:xxxxx failed with the following error: could not parse network address "localhost": Name or service not known
|
||||||
|
SELECT array_agg(nodeid) as updated_nodeids from pg_dist_node WHERE nodename = 'localhost' \gset
|
||||||
|
UPDATE pg_dist_node SET nodename = '127.0.0.1' WHERE nodeid = ANY(:'updated_nodeids'::int[]);
|
||||||
|
ALTER SYSTEM SET citus.node_conninfo = 'sslmode=require host=localhost';
|
||||||
|
SELECT pg_reload_conf();
|
||||||
|
pg_reload_conf
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
SELECT pg_sleep(0.1);
|
||||||
|
pg_sleep
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- works when hostaddr is specified in pg_dist_node after providing host in citus.node_conninfo
|
||||||
|
SELECT COUNT(*)>=0 FROM test;
|
||||||
|
?column?
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
-- restore original nodenames into pg_dist_node
|
||||||
|
UPDATE pg_dist_node SET nodename = 'localhost' WHERE nodeid = ANY(:'updated_nodeids'::int[]);
|
||||||
|
-- reset it
|
||||||
|
ALTER SYSTEM RESET citus.node_conninfo;
|
||||||
|
select pg_reload_conf();
|
||||||
|
pg_reload_conf
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
t
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
select pg_sleep(0.1); -- wait for config reload to apply
|
||||||
|
pg_sleep
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
|
||||||
|
(1 row)
|
||||||
|
|
||||||
DROP SCHEMA node_conninfo_reload CASCADE;
|
DROP SCHEMA node_conninfo_reload CASCADE;
|
||||||
NOTICE: drop cascades to table test
|
NOTICE: drop cascades to table test
|
||||||
|
|
|
@ -205,4 +205,30 @@ show citus.node_conninfo;
|
||||||
-- Should work again
|
-- Should work again
|
||||||
ALTER TABLE test ADD COLUMN e INT;
|
ALTER TABLE test ADD COLUMN e INT;
|
||||||
|
|
||||||
|
-- show that we allow providing "host" param via citus.node_conninfo
|
||||||
|
ALTER SYSTEM SET citus.node_conninfo = 'sslmode=require host=nosuchhost';
|
||||||
|
SELECT pg_reload_conf();
|
||||||
|
SELECT pg_sleep(0.1);
|
||||||
|
|
||||||
|
-- fails due to invalid host
|
||||||
|
SELECT COUNT(*)>=0 FROM test;
|
||||||
|
|
||||||
|
SELECT array_agg(nodeid) as updated_nodeids from pg_dist_node WHERE nodename = 'localhost' \gset
|
||||||
|
UPDATE pg_dist_node SET nodename = '127.0.0.1' WHERE nodeid = ANY(:'updated_nodeids'::int[]);
|
||||||
|
|
||||||
|
ALTER SYSTEM SET citus.node_conninfo = 'sslmode=require host=localhost';
|
||||||
|
SELECT pg_reload_conf();
|
||||||
|
SELECT pg_sleep(0.1);
|
||||||
|
|
||||||
|
-- works when hostaddr is specified in pg_dist_node after providing host in citus.node_conninfo
|
||||||
|
SELECT COUNT(*)>=0 FROM test;
|
||||||
|
|
||||||
|
-- restore original nodenames into pg_dist_node
|
||||||
|
UPDATE pg_dist_node SET nodename = 'localhost' WHERE nodeid = ANY(:'updated_nodeids'::int[]);
|
||||||
|
|
||||||
|
-- reset it
|
||||||
|
ALTER SYSTEM RESET citus.node_conninfo;
|
||||||
|
select pg_reload_conf();
|
||||||
|
select pg_sleep(0.1); -- wait for config reload to apply
|
||||||
|
|
||||||
DROP SCHEMA node_conninfo_reload CASCADE;
|
DROP SCHEMA node_conninfo_reload CASCADE;
|
||||||
|
|
Loading…
Reference in New Issue