mirror of https://github.com/citusdata/citus.git
Use a fixed application_name while connecting to remote nodes
Citus heavily relies on application_name, see `IsCitusInitiatedRemoteBackend()`. But if the user set the application name, such as export PGAPPNAME=test_name, Citus uses that name while connecting to the remote node. With this commit, we ensure that Citus always connects with the "citus" user name to the remote nodes.error_2_on_name
parent
9bc0fd9479
commit
9d39cc90d0
|
@ -72,8 +72,8 @@ InitConnParams()
|
||||||
/*
|
/*
|
||||||
* ResetConnParams frees all strings in the keywords and parameters arrays,
|
* ResetConnParams frees all strings in the keywords and parameters arrays,
|
||||||
* sets their elements to null, and resets the ConnParamsSize to zero before
|
* sets their elements to null, and resets the ConnParamsSize to zero before
|
||||||
* adding back any hardcoded global connection settings (at present, only the
|
* adding back any hardcoded global connection settings (at present, there
|
||||||
* fallback_application_name of 'citus').
|
* are no).
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
ResetConnParams()
|
ResetConnParams()
|
||||||
|
@ -89,8 +89,6 @@ ResetConnParams()
|
||||||
ConnParams.size = 0;
|
ConnParams.size = 0;
|
||||||
|
|
||||||
InvalidateConnParamsHashEntries();
|
InvalidateConnParamsHashEntries();
|
||||||
|
|
||||||
AddConnParam("fallback_application_name", CITUS_APPLICATION_NAME);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -253,14 +251,16 @@ GetConnParams(ConnectionHashKey *key, char ***keywords, char ***values,
|
||||||
"port",
|
"port",
|
||||||
"dbname",
|
"dbname",
|
||||||
"user",
|
"user",
|
||||||
"client_encoding"
|
"client_encoding",
|
||||||
|
"application_name"
|
||||||
};
|
};
|
||||||
const char *runtimeValues[] = {
|
const char *runtimeValues[] = {
|
||||||
key->hostname,
|
key->hostname,
|
||||||
nodePortString,
|
nodePortString,
|
||||||
key->database,
|
key->database,
|
||||||
key->user,
|
key->user,
|
||||||
GetDatabaseEncodingName()
|
GetDatabaseEncodingName(),
|
||||||
|
CITUS_APPLICATION_NAME
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
CREATE SCHEMA mx_app_name;
|
||||||
|
CREATE TABLE output (line text);
|
||||||
|
-- a hack to run command with another user
|
||||||
|
\COPY output FROM PROGRAM 'PGAPPNAME=mx_app_name psql -c "CREATE TABLE dist_1(a int)" -h localhost -p 57636 -U postgres -d regression'
|
||||||
|
\COPY output FROM PROGRAM 'PGAPPNAME=mx_app_name psql -c "SELECT create_distributed_table(''dist_1'', ''a'');" -h localhost -p 57636 -U postgres -d regression'
|
||||||
|
-- ensure the command executed fine
|
||||||
|
SELECT count(*) FROM pg_dist_partition WHERE logicalrelid = 'dist_1'::regclass;
|
||||||
|
count
|
||||||
|
---------------------------------------------------------------------
|
||||||
|
1
|
||||||
|
(1 row)
|
||||||
|
|
||||||
|
\COPY output FROM PROGRAM 'PGAPPNAME=mx_app_name psql -c "DROP TABLE dist_1;" -h localhost -p 57636 -U postgres -d regression'
|
||||||
|
DROP SCHEMA mx_app_name CASCADE;
|
|
@ -59,6 +59,7 @@ test: locally_execute_intermediate_results
|
||||||
test: multi_mx_alter_distributed_table
|
test: multi_mx_alter_distributed_table
|
||||||
test: update_colocation_mx
|
test: update_colocation_mx
|
||||||
test: resync_metadata_with_sequences
|
test: resync_metadata_with_sequences
|
||||||
|
test: mx_application_name
|
||||||
|
|
||||||
# should be executed sequentially because it modifies metadata
|
# should be executed sequentially because it modifies metadata
|
||||||
test: local_shard_execution_dropped_column
|
test: local_shard_execution_dropped_column
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
CREATE SCHEMA mx_app_name;
|
||||||
|
|
||||||
|
CREATE TABLE output (line text);
|
||||||
|
|
||||||
|
-- a hack to run command with another user
|
||||||
|
\COPY output FROM PROGRAM 'PGAPPNAME=mx_app_name psql -c "CREATE TABLE dist_1(a int)" -h localhost -p 57636 -U postgres -d regression'
|
||||||
|
\COPY output FROM PROGRAM 'PGAPPNAME=mx_app_name psql -c "SELECT create_distributed_table(''dist_1'', ''a'');" -h localhost -p 57636 -U postgres -d regression'
|
||||||
|
|
||||||
|
-- ensure the command executed fine
|
||||||
|
SELECT count(*) FROM pg_dist_partition WHERE logicalrelid = 'dist_1'::regclass;
|
||||||
|
|
||||||
|
\COPY output FROM PROGRAM 'PGAPPNAME=mx_app_name psql -c "DROP TABLE dist_1;" -h localhost -p 57636 -U postgres -d regression'
|
||||||
|
|
||||||
|
DROP SCHEMA mx_app_name CASCADE;
|
Loading…
Reference in New Issue