diff --git a/doc.ja/src/sgml/connection-settings.sgml b/doc.ja/src/sgml/connection-settings.sgml index deb37b8..cba426e 100644 --- a/doc.ja/src/sgml/connection-settings.sgml +++ b/doc.ja/src/sgml/connection-settings.sgml @@ -778,7 +778,7 @@ backend_clustering_mode = 'slony' もし同票で、2つ以上のグループで同じノード数だった場合は、マスターノード(最も若いDBノード番号のバックエンドノード)を含むグループが優先されます。 @@ -883,7 +883,7 @@ backend_clustering_mode = 'slony' 結果(R:レプリケーション、M:マスターのみに送信、L:負荷分散) @@ -1355,10 +1355,10 @@ S2/N2: COMMIT; end of the parameter name (e.g.backend_hostname0). This number is referred to as "DB node ID", and it starts from 0. The backend which was given the DB node ID of 0 will be - called "master node". When multiple backends are defined, the - service can be continued even if the master node is down (not + called "main node". When multiple backends are defined, the + service can be continued even if the main node is down (not true in some modes). In this case, the youngest DB node ID - alive will be the new master node. + alive will be the new main node. --> パラメータ名の末尾に数字を付加することで複数のバックエンドを指定することができます(たとえばbackend_hostname0)。 この数字のことを「DBノードID」と呼び、0から開始します。 diff --git a/doc.ja/src/sgml/misc-config.sgml b/doc.ja/src/sgml/misc-config.sgml index 07d7ed8..ea9cdf7 100644 --- a/doc.ja/src/sgml/misc-config.sgml +++ b/doc.ja/src/sgml/misc-config.sgml @@ -225,8 +225,8 @@ リカバリされるバックエンドノードのデータベースクラスタへのパス @@ -183,7 +183,7 @@ スクリプトのパスおよびファイル名は固定されており、マスタ(プライマリ)ノード上で$PGDATA/pgpool_remote_startが実行されます。 @@ -338,7 +338,7 @@ マスター(プライマリ)ノードのデータベースクラスタへのパス @@ -385,7 +385,7 @@ マスター(プライマリ)ノードのポート番号(Pgpool-II 3.4以降) @@ -465,7 +465,7 @@ マスター(プライマリ)ノードのデータベースクラスタへのパス @@ -515,7 +515,7 @@ マスター(プライマリ)ノードのポート番号(Pgpool-II 3.4以降) diff --git a/doc.ja/src/sgml/ref/show_pool_health_check_stats.sgml b/doc.ja/src/sgml/ref/show_pool_health_check_stats.sgml index a3512e9..eaa38e3 100644 --- a/doc.ja/src/sgml/ref/show_pool_health_check_stats.sgml +++ b/doc.ja/src/sgml/ref/show_pool_health_check_stats.sgml @@ -86,7 +86,7 @@ role このノードの役割。ストリーミングレプリケーションモードではprimaryあるいはstandbyです。 - 他のモードでは、masterあるいはslaveです。 + 他のモードでは、mainあるいはreplicaです。 diff --git a/doc.ja/src/sgml/runtime.sgml b/doc.ja/src/sgml/runtime.sgml index fd71281..edd04bc 100644 --- a/doc.ja/src/sgml/runtime.sgml +++ b/doc.ja/src/sgml/runtime.sgml @@ -506,10 +506,10 @@ end of the parameter name (e.g.backend_hostname0). This number is referred to as "DB node ID", and it starts from 0. The backend which was given the DB node ID of 0 will be - called "Master DB". When multiple backends are defined, the - service can be continued even if the Master DB is down (not + called "Main DB". When multiple backends are defined, the + service can be continued even if the Main DB is down (not true in some modes). In this case, the youngest DB node ID - alive will be the new Master DB. + alive will be the new Main DB. diff --git a/doc/src/sgml/connection-settings.sgml b/doc/src/sgml/connection-settings.sgml index 76d879a..c7ccc94 100644 --- a/doc/src/sgml/connection-settings.sgml +++ b/doc/src/sgml/connection-settings.sgml @@ -626,7 +626,7 @@ backend_clustering_mode = 'native_replication' - results(R:replication, M: send only to master, L: load balance) + results(R:replication, M: send only to main, L: load balance) R M @@ -1004,10 +1004,10 @@ S2/N2: COMMIT; end of the parameter name (e.g.backend_hostname0). This number is referred to as "DB node ID", and it starts from 0. The backend which was given the DB node ID of 0 will be - called "master node". When multiple backends are defined, the - service can be continued even if the master node is down (not + called "main node". When multiple backends are defined, the + service can be continued even if the main node is down (not true in some modes). In this case, the youngest DB node ID - alive will be the new master node. + alive will be the new main node. diff --git a/doc/src/sgml/loadbalance.sgml b/doc/src/sgml/loadbalance.sgml index a6242ee..2b738b2 100644 --- a/doc/src/sgml/loadbalance.sgml +++ b/doc/src/sgml/loadbalance.sgml @@ -27,7 +27,7 @@ arbitrary comment(/*NO LOAD BALANCE*/ is usually used) before the SELECT statement. This will disable the load balance of the particular query and Pgpool-II - will send it to the master node (the primary node in Native Replication mode). + will send it to the main node (the primary node in Native Replication mode). @@ -224,7 +224,7 @@ If writing queries appear, succeeding read queries may not be load balanced. i.e. sent to primary node (in streaming - replication mode) or master node (in other mode) depending on the + replication mode) or main node (in other mode) depending on the setting of . diff --git a/doc/src/sgml/misc-config.sgml b/doc/src/sgml/misc-config.sgml index 32d400c..918b32f 100644 --- a/doc/src/sgml/misc-config.sgml +++ b/doc/src/sgml/misc-config.sgml @@ -167,9 +167,9 @@ check in the SELECT statements. To check the temporary table Pgpool-II queries the system catalog of - primary/master PostgreSQL backend + primary/main PostgreSQL backend if catalog is specified, which - increases the load on the primary/master server. + increases the load on the primary/main server. If trace is @@ -220,8 +220,8 @@ Setting to on, enables the unlogged table check in the SELECT statements. To check the unlogged table Pgpool-II - queries the system catalog of primary/master PostgreSQL backend which increases - the load on the primary/master server. + queries the system catalog of primary/main PostgreSQL backend which increases + the load on the primary/main server. If you are absolutely sure that your system never uses the unlogged tables (for example, you are using 9.0 or earlier version of PostgreSQL) then you can safely turn off the check_unlogged_table. diff --git a/doc/src/sgml/online-recovery.sgml b/doc/src/sgml/online-recovery.sgml index 9cd2471..98e7aee 100644 --- a/doc/src/sgml/online-recovery.sgml +++ b/doc/src/sgml/online-recovery.sgml @@ -31,7 +31,7 @@ Make sure that autovacuum is stopped on the - master node (the first node which is up and running) before starting the + main node (the first node which is up and running) before starting the online recovery. Autovacuum can change the contents of the database which can cause the inconsistency after the online recovery. @@ -115,14 +115,14 @@ - Path to the database cluster of the master(primary) node. + Path to the database cluster of the main(primary) node. The script example can be found in . - The script path and filename are hard coded, $PGDATA/pgpool_remote_start is executed on master(primary) node. + The script path and filename are hard coded, $PGDATA/pgpool_remote_start is executed on main(primary) node. @@ -221,7 +221,7 @@ - Specifies a command to be run by master (primary) node at the + Specifies a command to be run by main (primary) node at the first stage of online recovery. The command file must be placed in the database cluster directory for security reasons. For example, if recovery_1st_stage_command = @@ -236,7 +236,7 @@ - Path to the database cluster of the master (primary) node. + Path to the database cluster of the main (primary) node. @@ -251,7 +251,7 @@ - Port number of the master (primary) node (Pgpool-II 3.4 or after). + Port number of the main (primary) node (Pgpool-II 3.4 or after). @@ -306,7 +306,7 @@ - Specifies a command to be run by master node at the second + Specifies a command to be run by main node at the second stage of online recovery. This command is required only , so for other modes don't need to provide a command file. The command file must be placed in the @@ -323,7 +323,7 @@ - Path to the database cluster of the master(primary) node. + Path to the database cluster of the main(primary) node. @@ -338,7 +338,7 @@ - Port number of the master (primary) node (Pgpool-II 3.4 or after). + Port number of the main (primary) node (Pgpool-II 3.4 or after). diff --git a/doc/src/sgml/ref/show_pool_health_check_stats.sgml b/doc/src/sgml/ref/show_pool_health_check_stats.sgml index ce85516..ff2a0e3 100644 --- a/doc/src/sgml/ref/show_pool_health_check_stats.sgml +++ b/doc/src/sgml/ref/show_pool_health_check_stats.sgml @@ -91,7 +91,7 @@ role Role of the node. Either primary or standby in streaming - replication mode. Either master or slave in other mode. + replication mode. Either main or replica in other mode. diff --git a/doc/src/sgml/restrictions.sgml b/doc/src/sgml/restrictions.sgml index 9ff520c..a09b52c 100644 --- a/doc/src/sgml/restrictions.sgml +++ b/doc/src/sgml/restrictions.sgml @@ -31,7 +31,7 @@ Multi-statement queries (multiple SQL commands on single line) are always sent to primary node (in streaming replication mode) - or master node (in other + or main node (in other modes). Usually Pgpool-II dispatch query to appropriate node, but it's not applied to multi-statement queries. diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml index c1d2741..696ceaf 100644 --- a/doc/src/sgml/runtime.sgml +++ b/doc/src/sgml/runtime.sgml @@ -355,10 +355,10 @@ end of the parameter name (e.g.backend_hostname0). This number is referred to as "DB node ID", and it starts from 0. The backend which was given the DB node ID of 0 will be - called "Master DB". When multiple backends are defined, the - service can be continued even if the Master DB is down (not + called "Main DB". When multiple backends are defined, the + service can be continued even if the Main DB is down (not true in some modes). In this case, the youngest DB node ID - alive will be the new Master DB. + alive will be the new Main DB. diff --git a/src/auth/pool_auth.c b/src/auth/pool_auth.c index bc04626..b60842d 100644 --- a/src/auth/pool_auth.c +++ b/src/auth/pool_auth.c @@ -345,7 +345,7 @@ pool_do_auth(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp) StartupPacket *sp; - protoMajor = MASTER_CONNECTION(cp)->sp->major; + protoMajor = MAIN_CONNECTION(cp)->sp->major; kind = pool_read_kind(cp); if (kind < 0) @@ -433,7 +433,7 @@ pool_do_auth(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp) msglen = htonl(0); pool_write_and_flush(frontend, &msglen, sizeof(msglen)); - MASTER(cp)->auth_kind = AUTH_REQ_OK; + MAIN(cp)->auth_kind = AUTH_REQ_OK; } /* clear text password authentication? */ @@ -498,7 +498,7 @@ pool_do_auth(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp) */ if (!RAW_MODE && NUM_BACKENDS > 1) { - if (get_auth_password(MASTER(cp), frontend, 0, + if (get_auth_password(MAIN(cp), frontend, 0, &password, &passwordType) == false) { /* @@ -514,7 +514,7 @@ pool_do_auth(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp) errhint("you can disable this behavior by setting allow_clear_text_frontend_auth to off"))); authenticate_frontend_clear_text(frontend); /* now check again if we have a password now */ - if (get_auth_password(MASTER(cp), frontend, 0, + if (get_auth_password(MAIN(cp), frontend, 0, &password, &passwordType) == false) { ereport(ERROR, @@ -560,7 +560,7 @@ pool_do_auth(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp) char *password; PasswordType passwordType = PASSWORD_TYPE_UNKNOWN; - if (get_auth_password(MASTER(cp), frontend, 0, + if (get_auth_password(MAIN(cp), frontend, 0, &password, &passwordType) == false) { /* @@ -575,7 +575,7 @@ pool_do_auth(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp) errhint("you can disable this behavior by setting allow_clear_text_frontend_auth to off"))); authenticate_frontend_clear_text(frontend); /* now check again if we have a password now */ - if (get_auth_password(MASTER(cp), frontend, 0, + if (get_auth_password(MAIN(cp), frontend, 0, &password, &passwordType) == false) { ereport(ERROR, @@ -675,7 +675,7 @@ pool_do_auth(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp) break; case 'N': - if (pool_extract_error_message(false, MASTER(cp), protoMajor, true, &message) == 1) + if (pool_extract_error_message(false, MAIN(cp), protoMajor, true, &message) == 1) { ereport(NOTICE, (errmsg("notice from backend"), @@ -693,7 +693,7 @@ pool_do_auth(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp) /* process error message */ case 'E': - if (pool_extract_error_message(false, MASTER(cp), protoMajor, true, &message) == 1) + if (pool_extract_error_message(false, MAIN(cp), protoMajor, true, &message) == 1) { ereport(LOG, (errmsg("backend throws an error message"), @@ -758,7 +758,7 @@ pool_do_auth(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp) /* * OK, read pid and secret key */ - sp = MASTER_CONNECTION(cp)->sp; + sp = MAIN_CONNECTION(cp)->sp; pid = -1; for (i = 0; i < NUM_BACKENDS; i++) @@ -826,7 +826,7 @@ pool_do_reauth(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp) */ if (!frontend->frontend_authenticated) { - switch (MASTER(cp)->auth_kind) + switch (MAIN(cp)->auth_kind) { case AUTH_REQ_OK: /* trust */ @@ -834,26 +834,26 @@ pool_do_reauth(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp) case AUTH_REQ_PASSWORD: /* clear text password */ - do_clear_text_password(MASTER(cp), frontend, 1, protoMajor); + do_clear_text_password(MAIN(cp), frontend, 1, protoMajor); break; case AUTH_REQ_CRYPT: /* crypt password */ - do_crypt(MASTER(cp), frontend, 1, protoMajor); + do_crypt(MAIN(cp), frontend, 1, protoMajor); break; case AUTH_REQ_MD5: /* md5 password */ - authenticate_frontend_md5(MASTER(cp), frontend, 1, protoMajor); + authenticate_frontend_md5(MAIN(cp), frontend, 1, protoMajor); break; case AUTH_REQ_SASL: /* SCRAM */ - authenticate_frontend_SCRAM(MASTER(cp), frontend, 1); + authenticate_frontend_SCRAM(MAIN(cp), frontend, 1); break; default: ereport(ERROR, (errmsg("authentication failed"), - errdetail("unknown authentication request code %d", MASTER(cp)->auth_kind))); + errdetail("unknown authentication request code %d", MAIN(cp)->auth_kind))); } } @@ -867,7 +867,7 @@ pool_do_reauth(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp) msglen = htonl(0); pool_write_and_flush(frontend, &msglen, sizeof(msglen)); - pool_send_backend_key_data(frontend, MASTER_CONNECTION(cp)->pid, MASTER_CONNECTION(cp)->key, protoMajor); + pool_send_backend_key_data(frontend, MAIN_CONNECTION(cp)->pid, MAIN_CONNECTION(cp)->key, protoMajor); return 0; } @@ -885,11 +885,11 @@ pool_send_auth_fail(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * cp) protoMajor = MAJOR(cp); - messagelen = strlen(MASTER_CONNECTION(cp)->sp->user) + 100; + messagelen = strlen(MAIN_CONNECTION(cp)->sp->user) + 100; errmessage = (char *) palloc(messagelen + 1); snprintf(errmessage, messagelen, "password authentication failed for user \"%s\"", - MASTER_CONNECTION(cp)->sp->user); + MAIN_CONNECTION(cp)->sp->user); if (send_error_to_frontend) pool_send_fatal_message(frontend, protoMajor, "XX000", errmessage, "", "", __FILE__, __LINE__); @@ -1100,7 +1100,7 @@ do_clear_text_password(POOL_CONNECTION * backend, POOL_CONNECTION * frontend, in /* if authenticated, save info */ if (kind == AUTH_REQ_OK) { - if (IS_MASTER_NODE_ID(backend->db_node_id)) + if (IS_MAIN_NODE_ID(backend->db_node_id)) { send_auth_ok(frontend, protoMajor); } @@ -1136,8 +1136,8 @@ do_crypt(POOL_CONNECTION * backend, POOL_CONNECTION * frontend, int reauth, int memcpy(salt, backend->salt, sizeof(salt)); } - /* master? */ - if (IS_MASTER_NODE_ID(backend->db_node_id)) + /* main? */ + if (IS_MAIN_NODE_ID(backend->db_node_id)) { pool_write(frontend, "R", 1); /* authentication */ if (protoMajor == PROTO_MAJOR_V3) @@ -1780,8 +1780,8 @@ do_md5(POOL_CONNECTION * backend, POOL_CONNECTION * frontend, int reauth, int pr errdetail("unable to get the password"))); } - /* master? */ - if (IS_MASTER_NODE_ID(backend->db_node_id) && frontend->frontend_authenticated == false) + /* main? */ + if (IS_MAIN_NODE_ID(backend->db_node_id) && frontend->frontend_authenticated == false) { /* * If frontend is not authenticated and do it it first. but if we have @@ -1834,7 +1834,7 @@ do_md5(POOL_CONNECTION * backend, POOL_CONNECTION * frontend, int reauth, int pr if (!reauth && kind == 0) { - if (IS_MASTER_NODE_ID(backend->db_node_id)) + if (IS_MAIN_NODE_ID(backend->db_node_id)) { /* Send auth ok to frontend */ send_auth_ok(frontend, protoMajor); @@ -2107,8 +2107,8 @@ do_SCRAM(POOL_CONNECTION * frontend, POOL_CONNECTION * backend, int protoMajor, errdetail("password not found"))); } - /* master? */ - if (frontend && IS_MASTER_NODE_ID(backend->db_node_id) && frontend->frontend_authenticated == false) + /* main? */ + if (frontend && IS_MAIN_NODE_ID(backend->db_node_id) && frontend->frontend_authenticated == false) { /* * If frontend is not authenticated and do it it first. but if we have diff --git a/src/context/pool_query_context.c b/src/context/pool_query_context.c index 151edf4..bf9b9b9 100644 --- a/src/context/pool_query_context.c +++ b/src/context/pool_query_context.c @@ -59,7 +59,7 @@ typedef enum static POOL_DEST send_to_where(Node *node, char *query); static void where_to_send_deallocate(POOL_QUERY_CONTEXT * query_context, Node *node); static char *remove_read_write(int len, const char *contents, int *rewritten_len); -static void set_virtual_master_node(POOL_QUERY_CONTEXT *query_context); +static void set_virtual_main_node(POOL_QUERY_CONTEXT *query_context); static void set_load_balance_info(POOL_QUERY_CONTEXT *query_context); static bool is_in_list(char *name, List *list); @@ -157,8 +157,8 @@ pool_start_query(POOL_QUERY_CONTEXT * query_context, char *query, int len, Node query_context->original_query = pstrdup(query); query_context->rewritten_query = NULL; query_context->parse_tree = node; - query_context->virtual_master_node_id = my_master_node_id; - query_context->load_balance_node_id = my_master_node_id; + query_context->virtual_main_node_id = my_main_node_id; + query_context->load_balance_node_id = my_main_node_id; query_context->is_cache_safe = false; query_context->num_original_params = -1; if (pool_config->memory_cache_enabled) @@ -304,7 +304,7 @@ pool_is_node_to_be_sent_in_current_query(int node_id) POOL_SESSION_CONTEXT *sc; if (RAW_MODE) - return node_id == REAL_MASTER_NODE_ID; + return node_id == REAL_MAIN_NODE_ID; sc = pool_get_session_context(true); if (!sc) @@ -318,10 +318,10 @@ pool_is_node_to_be_sent_in_current_query(int node_id) } /* - * Returns virtual master DB node id, + * Returns virtual main DB node id, */ int -pool_virtual_master_db_node_id(void) +pool_virtual_main_db_node_id(void) { POOL_SESSION_CONTEXT *sc; @@ -344,19 +344,19 @@ pool_virtual_master_db_node_id(void) sc = pool_get_session_context(true); if (!sc) { - return REAL_MASTER_NODE_ID; + return REAL_MAIN_NODE_ID; } if (sc->in_progress && sc->query_context) { - int node_id = sc->query_context->virtual_master_node_id; + int node_id = sc->query_context->virtual_main_node_id; if (SL_MODE) { /* - * Make sure that virtual_master_node_id is either primary node id + * Make sure that virtual_main_node_id is either primary node id * or load balance node id. If not, it is likely that - * virtual_master_node_id is not set up yet. Let's use the primary + * virtual_main_node_id is not set up yet. Let's use the primary * node id. except for the special case where we need to send the * query to the node which is not primary nor the load balance * node. Currently there is only one special such case that is @@ -369,7 +369,7 @@ pool_virtual_master_db_node_id(void) */ ereport(DEBUG5, - (errmsg("pool_virtual_master_db_node_id: virtual_master_node_id:%d load_balance_node_id:%d PRIMARY_NODE_ID:%d", + (errmsg("pool_virtual_main_db_node_id: virtual_main_node_id:%d load_balance_node_id:%d PRIMARY_NODE_ID:%d", node_id, sc->load_balance_node_id, PRIMARY_NODE_ID))); if (node_id != sc->query_context->load_balance_node_id && node_id != PRIMARY_NODE_ID) @@ -387,15 +387,15 @@ pool_virtual_master_db_node_id(void) } /* - * No query context exists. If in master/slave mode, returns primary node - * if exists. Otherwise returns my_master_node_id, which represents the - * last REAL_MASTER_NODE_ID. + * No query context exists. If in native replication mode, returns primary node + * if exists. Otherwise returns my_main_node_id, which represents the + * last REAL_MAIN_NODE_ID. */ - if (MASTER_SLAVE) + if (NATIVE_REPLICATION) { return PRIMARY_NODE_ID; } - return my_master_node_id; + return my_main_node_id; } /* @@ -416,7 +416,7 @@ pool_force_query_node_to_backend(POOL_QUERY_CONTEXT * query_context, int backend { if (query_context->where_to_send[i]) { - query_context->virtual_master_node_id = i; + query_context->virtual_main_node_id = i; break; } } @@ -443,17 +443,17 @@ pool_where_to_send(POOL_QUERY_CONTEXT * query_context, char *query, Node *node) pool_clear_node_to_be_sent(query_context); /* - * If there is "NO LOAD BALANCE" comment, we send only to master node. + * If there is "NO LOAD BALANCE" comment, we send only to main node. */ if (!strncasecmp(query, NO_LOAD_BALANCE, NO_LOAD_BALANCE_COMMENT_SZ)) { pool_set_node_to_be_sent(query_context, - MASTER_SLAVE ? PRIMARY_NODE_ID : REAL_MASTER_NODE_ID); + NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MAIN_NODE_ID); for (i = 0; i < NUM_BACKENDS; i++) { if (query_context->where_to_send[i]) { - query_context->virtual_master_node_id = i; + query_context->virtual_main_node_id = i; break; } } @@ -461,16 +461,16 @@ pool_where_to_send(POOL_QUERY_CONTEXT * query_context, char *query, Node *node) } /* - * In raw mode, we send only to master node. Simple enough. + * In raw mode, we send only to main node. Simple enough. */ if (RAW_MODE) { - pool_set_node_to_be_sent(query_context, REAL_MASTER_NODE_ID); + pool_set_node_to_be_sent(query_context, REAL_MAIN_NODE_ID); } - else if (MASTER_SLAVE && query_context->is_multi_statement) + else if (NATIVE_REPLICATION && query_context->is_multi_statement) { /* - * If we are in master/slave mode and we have multi statement query, + * If we are in native replication mode and we have multi statement query, * we should send it to primary server only. Otherwise it is possible * to send a write query to standby servers because we only use the * first element of the multi statement query and don't care about the @@ -607,7 +607,7 @@ pool_where_to_send(POOL_QUERY_CONTEXT * query_context, char *query, Node *node) } /* * When query match the query patterns in primary_routing_query_pattern_list, we - * send only to master node. + * send only to main node. */ else if (pattern_compare(query, WRITELIST, "primary_routing_query_pattern_list") == 1) { @@ -665,7 +665,7 @@ pool_where_to_send(POOL_QUERY_CONTEXT * query_context, char *query, Node *node) if (pool_config->backend_clustering_mode == CM_SNAPSHOT_ISOLATION && pool_config->load_balance_mode) { - if (TSTATE(backend, MASTER_NODE_ID) == 'T') + if (TSTATE(backend, MAIN_NODE_ID) == 'T') { /* * We are in an explicit transaction. If the transaction is @@ -675,11 +675,11 @@ pool_where_to_send(POOL_QUERY_CONTEXT * query_context, char *query, Node *node) { /* Ok, we can load balance. We are done! */ set_load_balance_info(query_context); - set_virtual_master_node(query_context); + set_virtual_main_node(query_context); return; } } - else if (TSTATE(backend, MASTER_NODE_ID) == 'I') + else if (TSTATE(backend, MAIN_NODE_ID) == 'I') { /* * We are out side transaction. If default transaction is read only, @@ -689,7 +689,7 @@ pool_where_to_send(POOL_QUERY_CONTEXT * query_context, char *query, Node *node) POOL_SELECT_RESULT *res; bool load_balance = false; - do_query(CONNECTION(backend, MASTER_NODE_ID), si_query, &res, MAJOR(backend)); + do_query(CONNECTION(backend, MAIN_NODE_ID), si_query, &res, MAJOR(backend)); if (res) { if (res->data[0] && !strcmp(res->data[0], "on")) @@ -699,13 +699,13 @@ pool_where_to_send(POOL_QUERY_CONTEXT * query_context, char *query, Node *node) free_select_result(res); } - per_node_statement_log(backend, MASTER_NODE_ID, si_query); + per_node_statement_log(backend, MAIN_NODE_ID, si_query); if (load_balance) { /* Ok, we can load balance. We are done! */ set_load_balance_info(query_context); - set_virtual_master_node(query_context); + set_virtual_main_node(query_context); return; } } @@ -726,7 +726,7 @@ pool_where_to_send(POOL_QUERY_CONTEXT * query_context, char *query, Node *node) * isolation level is not SERIALIZABLE) we might be able to load * balance. */ - else if (TSTATE(backend, MASTER_NODE_ID) == 'I' || + else if (TSTATE(backend, MAIN_NODE_ID) == 'I' || (!pool_is_writing_transaction() && !pool_is_failed_transaction() && pool_get_transaction_isolation() != POOL_SERIALIZABLE)) @@ -735,8 +735,8 @@ pool_where_to_send(POOL_QUERY_CONTEXT * query_context, char *query, Node *node) } else { - /* only send to master node */ - pool_set_node_to_be_sent(query_context, REAL_MASTER_NODE_ID); + /* only send to main node */ + pool_set_node_to_be_sent(query_context, REAL_MAIN_NODE_ID); } } else @@ -744,8 +744,8 @@ pool_where_to_send(POOL_QUERY_CONTEXT * query_context, char *query, Node *node) if (is_select_query(node, query) && !pool_config->replicate_select && !pool_has_function_call(node)) { - /* only send to master node */ - pool_set_node_to_be_sent(query_context, REAL_MASTER_NODE_ID); + /* only send to main node */ + pool_set_node_to_be_sent(query_context, REAL_MAIN_NODE_ID); } else { @@ -784,8 +784,8 @@ pool_where_to_send(POOL_QUERY_CONTEXT * query_context, char *query, Node *node) where_to_send_deallocate(query_context, node); } - /* Set virtual master node according to the where_to_send map. */ - set_virtual_master_node(query_context); + /* Set virtual main node according to the where_to_send map. */ + set_virtual_main_node(query_context); return; } @@ -820,7 +820,7 @@ pool_send_and_wait(POOL_QUERY_CONTEXT * query_context, /* * If the query is BEGIN READ WRITE or BEGIN ... SERIALIZABLE in - * master/slave mode, we send BEGIN to slaves/standbys instead. + * native replication mode, we send BEGIN to standbys instead. * original_query which is BEGIN READ WRITE is sent to primary. * rewritten_query which is BEGIN is sent to standbys. */ @@ -853,10 +853,10 @@ pool_send_and_wait(POOL_QUERY_CONTEXT * query_context, continue; /* - * If in master/slave mode, we do not send COMMIT/ABORT to - * slaves/standbys if it's in I(idle) state. + * If in native replication mode, we do not send COMMIT/ABORT to + * standbys if it's in I(idle) state. */ - if (is_commit && MASTER_SLAVE && !IS_MASTER_NODE_ID(i) && TSTATE(backend, i) == 'I') + if (is_commit && NATIVE_REPLICATION && !IS_MAIN_NODE_ID(i) && TSTATE(backend, i) == 'I') { pool_unset_node_to_be_sent(query_context, i); continue; @@ -904,10 +904,10 @@ pool_send_and_wait(POOL_QUERY_CONTEXT * query_context, #ifdef NOT_USED /* - * If in master/slave mode, we do not send COMMIT/ABORT to - * slaves/standbys if it's in I(idle) state. + * If in native replication mode, we do not send COMMIT/ABORT to + * standbys if it's in I(idle) state. */ - if (is_commit && MASTER_SLAVE && !IS_MASTER_NODE_ID(i) && TSTATE(backend, i) == 'I') + if (is_commit && NATIVE_REPLICATION && !IS_MAIN_NODE_ID(i) && TSTATE(backend, i) == 'I') { continue; } @@ -924,8 +924,8 @@ pool_send_and_wait(POOL_QUERY_CONTEXT * query_context, wait_for_query_response_with_trans_cleanup(frontend, CONNECTION(backend, i), MAJOR(backend), - MASTER_CONNECTION(backend)->pid, - MASTER_CONNECTION(backend)->key); + MAIN_CONNECTION(backend)->pid, + MAIN_CONNECTION(backend)->key); /* * Check if some error detected. If so, emit log. This is useful when @@ -973,7 +973,7 @@ pool_extended_send_and_wait(POOL_QUERY_CONTEXT * query_context, /* * If the query is BEGIN READ WRITE or BEGIN ... SERIALIZABLE in - * master/slave mode, we send BEGIN to slaves/standbys instead. + * native replication mode, we send BEGIN to standbys instead. * original_query which is BEGIN READ WRITE is sent to primary. * rewritten_query which is BEGIN is sent to standbys. */ @@ -1114,10 +1114,10 @@ pool_extended_send_and_wait(POOL_QUERY_CONTEXT * query_context, continue; /* - * If in master/slave mode, we do not send COMMIT/ABORT to - * slaves/standbys if it's in I(idle) state. + * If in native replication mode, we do not send COMMIT/ABORT to + * standbys if it's in I(idle) state. */ - if (is_commit && MASTER_SLAVE && !IS_MASTER_NODE_ID(i) && TSTATE(backend, i) == 'I') + if (is_commit && NATIVE_REPLICATION && !IS_MAIN_NODE_ID(i) && TSTATE(backend, i) == 'I') { continue; } @@ -1133,8 +1133,8 @@ pool_extended_send_and_wait(POOL_QUERY_CONTEXT * query_context, wait_for_query_response_with_trans_cleanup(frontend, CONNECTION(backend, i), MAJOR(backend), - MASTER_CONNECTION(backend)->pid, - MASTER_CONNECTION(backend)->key); + MAIN_CONNECTION(backend)->pid, + MAIN_CONNECTION(backend)->key); /* * Check if some error detected. If so, emit log. This is useful @@ -1153,7 +1153,7 @@ pool_extended_send_and_wait(POOL_QUERY_CONTEXT * query_context, /* * From syntactically analysis decide the statement to be sent to the - * primary, the standby or either or both in master/slave+HR/SR mode. + * primary, the standby or either or both in native replication+HR/SR mode. */ static POOL_DEST send_to_where(Node *node, char *query) @@ -1738,15 +1738,15 @@ is_serializable(TransactionStmt *node) /* * If the query is BEGIN READ WRITE or - * BEGIN ... SERIALIZABLE in master/slave mode, - * we send BEGIN to slaves/standbys instead. + * BEGIN ... SERIALIZABLE in native replication mode, + * we send BEGIN to standbys instead. * original_query which is BEGIN READ WRITE is sent to primary. * rewritten_query which is BEGIN is sent to standbys. */ bool pool_need_to_treat_as_if_default_transaction(POOL_QUERY_CONTEXT * query_context) { - return (MASTER_SLAVE && + return (NATIVE_REPLICATION && is_start_transaction_query(query_context->parse_tree) && (is_read_write((TransactionStmt *) query_context->parse_tree) || is_serializable((TransactionStmt *) query_context->parse_tree))); @@ -2061,10 +2061,10 @@ pool_is_transaction_read_only(Node *node) } /* - * Set virtual master node according to the where_to_send map. + * Set virtual main node according to the where_to_send map. */ static void -set_virtual_master_node(POOL_QUERY_CONTEXT *query_context) +set_virtual_main_node(POOL_QUERY_CONTEXT *query_context) { int i; @@ -2072,7 +2072,7 @@ set_virtual_master_node(POOL_QUERY_CONTEXT *query_context) { if (query_context->where_to_send[i]) { - query_context->virtual_master_node_id = i; + query_context->virtual_main_node_id = i; break; } } diff --git a/src/context/pool_session_context.c b/src/context/pool_session_context.c index 3f47218..29d6503 100644 --- a/src/context/pool_session_context.c +++ b/src/context/pool_session_context.c @@ -102,7 +102,7 @@ pool_init_session_context(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * bac } else { - node_id = SL_MODE ? PRIMARY_NODE_ID : MASTER_NODE_ID; + node_id = SL_MODE ? PRIMARY_NODE_ID : MAIN_NODE_ID; } session_context->load_balance_node_id = node_id; @@ -169,8 +169,8 @@ pool_init_session_context(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * bac pool_temp_tables_init(); #ifdef NOT_USED - /* Initialize preferred master node id */ - pool_reset_preferred_master_node_id(); + /* Initialize preferred main node id */ + pool_reset_preferred_main_node_id(); #endif /* Snapshot isolation state */ @@ -849,7 +849,7 @@ pool_get_transaction_isolation(void) /* No cached data is available. Ask backend. */ - do_query(MASTER(session_context->backend), + do_query(MAIN(session_context->backend), "SELECT current_setting('transaction_isolation')", &res, MAJOR(session_context->backend)); error_context_stack = callback.previous; @@ -1824,33 +1824,33 @@ pool_unset_suspend_reading_from_frontend(void) #ifdef NOT_USED /* - * Set preferred "master" node id. + * Set preferred "main" node id. * Only used for SimpleForwardToFrontend. */ void -pool_set_preferred_master_node_id(int node_id) +pool_set_preferred_main_node_id(int node_id) { - session_context->preferred_master_node_id = node_id; + session_context->preferred_main_node_id = node_id; } /* - * Return preferred "master" node id. + * Return preferred "main" node id. * Only used for SimpleForwardToFrontend. */ int -pool_get_preferred_master_node_id(void) +pool_get_preferred_main_node_id(void) { - return session_context->preferred_master_node_id; + return session_context->preferred_main_node_id; } /* - * Reset preferred "master" node id. + * Reset preferred "main" node id. * Only used for SimpleForwardToFrontend. */ void -pool_reset_preferred_master_node_id(void) +pool_reset_preferred_main_node_id(void) { - session_context->preferred_master_node_id = -1; + session_context->preferred_main_node_id = -1; } #endif diff --git a/src/include/context/pool_query_context.h b/src/include/context/pool_query_context.h index 73fef91..b732c90 100644 --- a/src/include/context/pool_query_context.h +++ b/src/include/context/pool_query_context.h @@ -63,7 +63,7 @@ typedef struct bool where_to_send[MAX_NUM_BACKENDS]; /* DB node map to send * query */ int load_balance_node_id; /* load balance node id per statement */ - int virtual_master_node_id; /* the 1st DB node to send query */ + int virtual_main_node_id; /* the 1st DB node to send query */ POOL_QUERY_STATE query_state[MAX_NUM_BACKENDS]; /* for extended query * protocol */ bool is_cache_safe; /* true if SELECT is safe to cache */ diff --git a/src/include/context/pool_session_context.h b/src/include/context/pool_session_context.h index 995d9f1..14aaadf 100644 --- a/src/include/context/pool_session_context.h +++ b/src/include/context/pool_session_context.h @@ -293,8 +293,8 @@ typedef struct List *transaction_temp_write_list; #ifdef NOT_USED - /* Preferred "master" node id. Only used for SimpleForwardToFrontend. */ - int preferred_master_node_id; + /* Preferred "main" node id. Only used for SimpleForwardToFrontend. */ + int preferred_main_node_id; #endif /* Whether snapshot is aquired in this transaction. Only used by Snapshot Isolation mode. */ @@ -386,9 +386,9 @@ extern void pool_temp_tables_remove_pending(void); extern void pool_temp_tables_dump(void); #ifdef NOT_USED -extern void pool_set_preferred_master_node_id(int node_id); -extern int pool_get_preferred_master_node_id(void); -extern void pool_reset_preferred_master_node_id(void); +extern void pool_set_preferred_main_node_id(int node_id); +extern int pool_get_preferred_main_node_id(void); +extern void pool_reset_preferred_main_node_id(void); #endif #ifdef NOT_USED diff --git a/src/include/pcp/libpcp_ext.h b/src/include/pcp/libpcp_ext.h index e816656..c0d88a5 100644 --- a/src/include/pcp/libpcp_ext.h +++ b/src/include/pcp/libpcp_ext.h @@ -69,8 +69,8 @@ typedef struct typedef enum { - ROLE_MASTER, - ROLE_SLAVE, + ROLE_MAIN, + ROLE_REPLICA, ROLE_PRIMARY, ROLE_STANDBY } SERVER_ROLE; diff --git a/src/include/pool.h b/src/include/pool.h index 1aa44d3..aca86ef 100644 --- a/src/include/pool.h +++ b/src/include/pool.h @@ -295,13 +295,13 @@ extern int pool_get_major_version(void); * no query is in progress and the DB node is healthy */ extern bool pool_is_node_to_be_sent_in_current_query(int node_id); -extern int pool_virtual_master_db_node_id(void); +extern int pool_virtual_main_db_node_id(void); extern BACKEND_STATUS * my_backend_status[]; -extern int my_master_node_id; +extern int my_main_node_id; #define VALID_BACKEND(backend_id) \ - ((RAW_MODE && (backend_id) == REAL_MASTER_NODE_ID) || \ + ((RAW_MODE && (backend_id) == REAL_MAIN_NODE_ID) || \ (pool_is_node_to_be_sent_in_current_query((backend_id)) && \ ((*(my_backend_status[(backend_id)]) == CON_UP) || \ (*(my_backend_status[(backend_id)]) == CON_CONNECT_WAIT)))) @@ -320,15 +320,15 @@ extern int my_master_node_id; * The first DB node id appears in pgpool.conf or the first "live" DB * node otherwise. */ -#define REAL_MASTER_NODE_ID (Req_info->master_node_id) +#define REAL_MAIN_NODE_ID (Req_info->main_node_id) /* * The primary node id in streaming replication mode. If not in the * mode or there's no primary node, this macro returns - * REAL_MASTER_NODE_ID. + * REAL_MAIN_NODE_ID. */ #define PRIMARY_NODE_ID (Req_info->primary_node_id >=0 && VALID_BACKEND_RAW(Req_info->primary_node_id) ? \ - Req_info->primary_node_id:REAL_MASTER_NODE_ID) + Req_info->primary_node_id:REAL_MAIN_NODE_ID) #define IS_PRIMARY_NODE_ID(node_id) (node_id == PRIMARY_NODE_ID) /* @@ -338,14 +338,14 @@ extern int my_master_node_id; #define REAL_PRIMARY_NODE_ID (Req_info->primary_node_id) /* - * "Virtual" master node id. It's same as REAL_MASTER_NODE_ID if not + * "Virtual" main node id. It's same as REAL_MAIN_NODE_ID if not * in load balance mode. If in load balance, it's the first load * balance node. */ -#define MASTER_NODE_ID (pool_virtual_master_db_node_id()) -#define IS_MASTER_NODE_ID(node_id) (MASTER_NODE_ID == (node_id)) -#define MASTER_CONNECTION(p) ((p)->slots[MASTER_NODE_ID]) -#define MASTER(p) MASTER_CONNECTION(p)->con +#define MAIN_NODE_ID (pool_virtual_main_db_node_id()) +#define IS_MAIN_NODE_ID(node_id) (MAIN_NODE_ID == (node_id)) +#define MAIN_CONNECTION(p) ((p)->slots[MAIN_NODE_ID]) +#define MAIN(p) MAIN_CONNECTION(p)->con /* * Backend node status in streaming replication mode. @@ -361,13 +361,13 @@ typedef enum /* Clustering mode macros */ #define REPLICATION (pool_config->backend_clustering_mode == CM_NATIVE_REPLICATION || \ pool_config->backend_clustering_mode == CM_SNAPSHOT_ISOLATION) -#define MASTER_SLAVE (pool_config->backend_clustering_mode == CM_STREAMING_REPLICATION || \ +#define NATIVE_REPLICATION (pool_config->backend_clustering_mode == CM_STREAMING_REPLICATION || \ pool_config->backend_clustering_mode == CM_LOGICAL_REPLICATION || \ pool_config->backend_clustering_mode == CM_SLONY) #define STREAM (pool_config->backend_clustering_mode == CM_STREAMING_REPLICATION) #define LOGICAL (pool_config->backend_clustering_mode == CM_LOGICAL_REPLICATION) #define SLONY (pool_config->backend_clustering_mode == CM_SLONY) -#define DUAL_MODE (REPLICATION || MASTER_SLAVE) +#define DUAL_MODE (REPLICATION || NATIVE_REPLICATION) #define RAW_MODE (pool_config->backend_clustering_mode == CM_RAW) #define SL_MODE (STREAM || LOGICAL) /* streaming or logical replication mode */ @@ -441,7 +441,7 @@ typedef struct POOL_REQUEST_NODE request[MAX_REQUEST_QUEUE_SIZE]; int request_queue_head; int request_queue_tail; - int master_node_id; /* the youngest node id which is not in down + int main_node_id; /* the youngest node id which is not in down * status */ int primary_node_id; /* the primary node id in streaming * replication mode */ @@ -623,7 +623,7 @@ extern int write_status_file(void); extern POOL_NODE_STATUS * verify_backend_node_status(POOL_CONNECTION_POOL_SLOT * *slots); extern POOL_NODE_STATUS * pool_get_node_status(void); extern void pool_set_backend_status_changed_time(int backend_id); -extern int get_next_master_node(void); +extern int get_next_main_node(void); diff --git a/src/main/pgpool_main.c b/src/main/pgpool_main.c index f15a00d..8f848b6 100644 --- a/src/main/pgpool_main.c +++ b/src/main/pgpool_main.c @@ -206,7 +206,7 @@ static pid_t wd_lifecheck_pid = 0; /* pid for child process handling watchdog * lifecheck */ BACKEND_STATUS *my_backend_status[MAX_NUM_BACKENDS]; /* Backend status buffer */ -int my_master_node_id; /* Master node id buffer */ +int my_main_node_id; /* Main node id buffer */ /* * Dummy varibale to suppress compiler warnings by discarding return values @@ -1151,11 +1151,11 @@ static RETSIGTYPE exit_handler(int sig) } /* - * Calculate next valid master node id. + * Calculate next valid main node id. * If no valid node found, returns -1. */ int -get_next_master_node(void) +get_next_main_node(void) { int i; @@ -1414,7 +1414,7 @@ failover(void) wd_failover_start(); /* - * if not in replication mode/master slave mode, we treat this a + * if not in replication mode/native replication mode, we treat this a * restart request. otherwise we need to check if we have already * failovered. */ @@ -1464,11 +1464,11 @@ failover(void) search_primary = false; /* - * recalculate the master node id after setting the backend + * recalculate the main node id after setting the backend * status of quarantined node, this will bring us to the old - * master_node_id that was beofre the quarantine state + * main_node_id that was beofre the quarantine state */ - Req_info->master_node_id = get_next_master_node(); + Req_info->main_node_id = get_next_main_node(); if (Req_info->primary_node_id == -1 && BACKEND_INFO(node_id).role == ROLE_PRIMARY) { @@ -1515,7 +1515,7 @@ failover(void) (void) write_status_file(); trigger_failover_command(node_id, pool_config->failback_command, - MASTER_NODE_ID, get_next_master_node(), PRIMARY_NODE_ID); + MAIN_NODE_ID, get_next_main_node(), PRIMARY_NODE_ID); } sync_required = true; @@ -1596,7 +1596,7 @@ failover(void) } } - new_master = get_next_master_node(); + new_master = get_next_main_node(); if (new_master < 0) { @@ -1732,7 +1732,7 @@ failover(void) if (nodes[i]) { trigger_failover_command(i, pool_config->failover_command, - MASTER_NODE_ID, new_master, REAL_PRIMARY_NODE_ID); + MAIN_NODE_ID, new_master, REAL_PRIMARY_NODE_ID); sync_required = true; } } @@ -1843,7 +1843,7 @@ failover(void) else { /* update new master node */ - new_master = get_next_master_node(); + new_master = get_next_main_node(); ereport(LOG, (errmsg("failover: %d follow backends have been degenerated", follow_cnt))); } @@ -1876,10 +1876,10 @@ failover(void) if (new_master >= 0) { - Req_info->master_node_id = new_master; + Req_info->main_node_id = new_master; sync_required = true; ereport(LOG, - (errmsg("failover: set new master node: %d", Req_info->master_node_id))); + (errmsg("failover: set new master node: %d", Req_info->main_node_id))); } @@ -2718,7 +2718,7 @@ trigger_failover_command(int node, const char *command_line, break; case 'r': /* new master port */ - newmaster = pool_get_node_info(get_next_master_node()); + newmaster = pool_get_node_info(get_next_main_node()); if (newmaster) { snprintf(port_buf, sizeof(port_buf), "%d", newmaster->backend_port); @@ -2730,7 +2730,7 @@ trigger_failover_command(int node, const char *command_line, break; case 'R': /* new master database directory */ - newmaster = pool_get_node_info(get_next_master_node()); + newmaster = pool_get_node_info(get_next_main_node()); if (newmaster) string_append_char(exec_cmd, newmaster->backend_data_directory); else @@ -3309,7 +3309,7 @@ initialize_shared_mem_objects(bool clear_memcache_oidmaps) /* * Initialize backend status area. From now on, VALID_BACKEND macro can be - * used. (get_next_master_node() uses VALID_BACKEND) + * used. (get_next_main_node() uses VALID_BACKEND) */ for (i = 0; i < MAX_NUM_BACKENDS; i++) @@ -3318,7 +3318,7 @@ initialize_shared_mem_objects(bool clear_memcache_oidmaps) } /* initialize Req_info */ - Req_info->master_node_id = get_next_master_node(); + Req_info->main_node_id = get_next_main_node(); Req_info->conn_counter = 0; Req_info->switching = false; Req_info->request_queue_head = Req_info->request_queue_tail = -1; @@ -3925,7 +3925,7 @@ sync_backend_from_watchdog(void) if (reload_maste_node_id) { - Req_info->master_node_id = get_next_master_node(); + Req_info->main_node_id = get_next_main_node(); } /* We don't need to do anything else if the Pgpool-II is starting up */ diff --git a/src/pcp_con/pcp_worker.c b/src/pcp_con/pcp_worker.c index 24edf19..b315afa 100644 --- a/src/pcp_con/pcp_worker.c +++ b/src/pcp_con/pcp_worker.c @@ -872,10 +872,10 @@ inform_node_info(PCP_CONNECTION * frontend, char *buf) } else { - if (Req_info->master_node_id == node_id) - role = ROLE_MASTER; + if (Req_info->main_node_id == node_id) + role = ROLE_MAIN; else - role = ROLE_SLAVE; + role = ROLE_REPLICA; } snprintf(role_str, sizeof(role_str), "%d", role); diff --git a/src/pcp_con/recovery.c b/src/pcp_con/recovery.c index faee71a..d4ca20a 100644 --- a/src/pcp_con/recovery.c +++ b/src/pcp_con/recovery.c @@ -57,7 +57,7 @@ extern volatile sig_atomic_t pcp_worker_wakeup_request; /* * Start online recovery. * "recovery_node" is the node to be recovered. - * Master or primary node is chosen in this function. + * Main or primary node is chosen in this function. */ void start_recovery(int recovery_node) @@ -85,8 +85,8 @@ start_recovery(int recovery_node) ereport(ERROR, (errmsg("node recovery failed, node id: %d is alive", recovery_node))); - /* select master/primary node */ - node_id = MASTER_SLAVE ? PRIMARY_NODE_ID : REAL_MASTER_NODE_ID; + /* select main/primary node */ + node_id = NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MAIN_NODE_ID; backend = &pool_config->backend_desc->backend_info[node_id]; /* get node info to be recovered */ @@ -95,7 +95,7 @@ start_recovery(int recovery_node) conn = connect_backend_libpq(backend); if (conn == NULL) ereport(ERROR, - (errmsg("node recovery failed, unable to connect to master node: %d ", node_id))); + (errmsg("node recovery failed, unable to connect to main node: %d ", node_id))); PG_TRY(); { diff --git a/src/protocol/CommandComplete.c b/src/protocol/CommandComplete.c index 41ec0ab..f4339a2 100644 --- a/src/protocol/CommandComplete.c +++ b/src/protocol/CommandComplete.c @@ -121,11 +121,11 @@ CommandComplete(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, bool } /* - * Otherwise just read from master node. + * Otherwise just read from main node. */ else { - con = MASTER(backend); + con = MAIN(backend); if (pool_read(con, &len, sizeof(len)) < 0) return POOL_END; @@ -196,7 +196,7 @@ CommandComplete(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, bool } query = session_context->query_context->query_w_hex; node = pool_get_parse_tree(); - state = TSTATE(backend, MASTER_NODE_ID); + state = TSTATE(backend, MAIN_NODE_ID); pool_handle_query_cache(backend, query, node, state); } } @@ -350,7 +350,7 @@ handle_query_context(POOL_CONNECTION_POOL * backend) /* Is this a temporary table? */ if (stmt->relation->relpersistence == 't') { - if (TSTATE(backend, MASTER_NODE_ID ) == 'T') /* Are we inside a transaction? */ + if (TSTATE(backend, MAIN_NODE_ID ) == 'T') /* Are we inside a transaction? */ { state = TEMP_TABLE_CREATING; } @@ -375,7 +375,7 @@ handle_query_context(POOL_CONNECTION_POOL * backend) ListCell *cell; ListCell *next; - if (TSTATE(backend, MASTER_NODE_ID ) == 'T') /* Are we inside a transaction? */ + if (TSTATE(backend, MAIN_NODE_ID ) == 'T') /* Are we inside a transaction? */ { state = TEMP_TABLE_DROPPING; } @@ -440,14 +440,14 @@ static POOL_STATUS handle_mismatch_tuples(POOL_CONNECTION * frontend, POOL_CONNE rows = extract_ntuples(packet); /* - * Save number of affected tuples of master node. + * Save number of affected tuples of main node. */ - session_context->ntuples[MASTER_NODE_ID] = rows; + session_context->ntuples[MAIN_NODE_ID] = rows; for (i = 0; i < NUM_BACKENDS; i++) { - if (!IS_MASTER_NODE_ID(i)) + if (!IS_MAIN_NODE_ID(i)) { if (!VALID_BACKEND(i)) { @@ -468,7 +468,7 @@ static POOL_STATUS handle_mismatch_tuples(POOL_CONNECTION * frontend, POOL_CONNE { ereport(DEBUG1, (errmsg("processing command complete"), - errdetail("length does not match between backends master(%d) %d th backend(%d)", + errdetail("length does not match between backends main(%d) %d th backend(%d)", len, i, packetlen))); } @@ -500,7 +500,7 @@ static POOL_STATUS handle_mismatch_tuples(POOL_CONNECTION * frontend, POOL_CONNE string_append_char(msg, "\""); pool_send_error_message(frontend, MAJOR(backend), "XX001", msg->data, "", - "check data consistency between master and other db node", __FILE__, __LINE__); + "check data consistency between main and other db node", __FILE__, __LINE__); ereport(LOG, (errmsg("%s", msg->data))); free_string(msg); diff --git a/src/protocol/child.c b/src/protocol/child.c index 4b2bd43..7b167cb 100644 --- a/src/protocol/child.c +++ b/src/protocol/child.c @@ -400,7 +400,7 @@ do_child(int *fds) /* * show ps status */ - sp = MASTER_CONNECTION(backend)->sp; + sp = MAIN_CONNECTION(backend)->sp; snprintf(psbuf, sizeof(psbuf), "%s %s %s idle", sp->user, sp->database, remote_ps_data); set_ps_display(psbuf, false); @@ -492,7 +492,7 @@ backend_cleanup(POOL_CONNECTION * volatile *frontend, POOL_CONNECTION_POOL * vol if (backend == NULL) return false; - sp = MASTER_CONNECTION(backend)->sp; + sp = MAIN_CONNECTION(backend)->sp; /* * cach connection if connection cache configuration parameter is enabled @@ -809,8 +809,8 @@ connect_using_existing_connection(POOL_CONNECTION * frontend, if (VALID_BACKEND(i)) if (do_command(frontend, CONNECTION(backend, i), command_buf, MAJOR(backend), - MASTER_CONNECTION(backend)->pid, - MASTER_CONNECTION(backend)->key, 0) != POOL_CONTINUE) + MAIN_CONNECTION(backend)->pid, + MAIN_CONNECTION(backend)->key, 0) != POOL_CONTINUE) { ereport(ERROR, (errmsg("unable to process command for backend connection"), @@ -818,7 +818,7 @@ connect_using_existing_connection(POOL_CONNECTION * frontend, } } - pool_add_param(&MASTER(backend)->params, "application_name", sp->application_name); + pool_add_param(&MAIN(backend)->params, "application_name", sp->application_name); set_application_name_with_string(sp->application_name); } @@ -835,7 +835,7 @@ connect_using_existing_connection(POOL_CONNECTION * frontend, len = htonl(5); pool_write(frontend, &len, sizeof(len)); - tstate = TSTATE(backend, MASTER_NODE_ID); + tstate = TSTATE(backend, MAIN_NODE_ID); pool_write(frontend, &tstate, 1); } @@ -1144,19 +1144,19 @@ static RETSIGTYPE close_idle_connection(int sig) for (j = 0; j < pool_config->max_pool; j++, p++) { - if (!MASTER_CONNECTION(p)) + if (!MAIN_CONNECTION(p)) continue; - if (!MASTER_CONNECTION(p)->sp) + if (!MAIN_CONNECTION(p)->sp) continue; - if (MASTER_CONNECTION(p)->sp->user == NULL) + if (MAIN_CONNECTION(p)->sp->user == NULL) continue; - if (MASTER_CONNECTION(p)->closetime > 0) /* idle connection? */ + if (MAIN_CONNECTION(p)->closetime > 0) /* idle connection? */ { #ifdef NOT_USED ereport(DEBUG1, (errmsg("closing idle connection"), - errdetail("user: %s database: %s", MASTER_CONNECTION(p)->sp->user, MASTER_CONNECTION(p)->sp->database))); + errdetail("user: %s database: %s", MAIN_CONNECTION(p)->sp->user, MAIN_CONNECTION(p)->sp->database))); #endif pool_send_frontend_exits(p); @@ -1231,7 +1231,7 @@ send_params(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend) sendlen; index = 0; - while (pool_get_param(&MASTER(backend)->params, index++, &name, &value) == 0) + while (pool_get_param(&MAIN(backend)->params, index++, &name, &value) == 0) { pool_write(frontend, "S", 1); len = sizeof(sendlen) + strlen(name) + 1 + strlen(value) + 1; @@ -1392,7 +1392,7 @@ check_stop_request(void) } /* - * Initialize my backend status and master node id. + * Initialize my backend status and main node id. * We copy the backend status to private area so that * they are not changed while I am alive. */ @@ -1411,7 +1411,7 @@ pool_initialize_private_backend_status(void) my_backend_status[i] = &private_backend_status[i]; } - my_master_node_id = REAL_MASTER_NODE_ID; + my_main_node_id = REAL_MAIN_NODE_ID; } static void @@ -1968,7 +1968,7 @@ retry_startup: * however we should make sure that the startup packet contents are * identical. OPTION data and others might be different. */ - if (sp->len != MASTER_CONNECTION(backend)->sp->len) + if (sp->len != MAIN_CONNECTION(backend)->sp->len) { ereport(DEBUG1, (errmsg("selecting backend connection"), @@ -1976,7 +1976,7 @@ retry_startup: found = 0; } - else if (memcmp(sp->startup_packet, MASTER_CONNECTION(backend)->sp->startup_packet, sp->len) != 0) + else if (memcmp(sp->startup_packet, MAIN_CONNECTION(backend)->sp->startup_packet, sp->len) != 0) { ereport(DEBUG1, (errmsg("selecting backend connection"), diff --git a/src/protocol/pool_connection_pool.c b/src/protocol/pool_connection_pool.c index cb50267..f00b563 100644 --- a/src/protocol/pool_connection_pool.c +++ b/src/protocol/pool_connection_pool.c @@ -115,18 +115,18 @@ pool_get_cp(char *user, char *database, int protoMajor, int check_socket) for (i = 0; i < pool_config->max_pool; i++) { - if (MASTER_CONNECTION(connection_pool) && - MASTER_CONNECTION(connection_pool)->sp && - MASTER_CONNECTION(connection_pool)->sp->major == protoMajor && - MASTER_CONNECTION(connection_pool)->sp->user != NULL && - strcmp(MASTER_CONNECTION(connection_pool)->sp->user, user) == 0 && - strcmp(MASTER_CONNECTION(connection_pool)->sp->database, database) == 0) + if (MAIN_CONNECTION(connection_pool) && + MAIN_CONNECTION(connection_pool)->sp && + MAIN_CONNECTION(connection_pool)->sp->major == protoMajor && + MAIN_CONNECTION(connection_pool)->sp->user != NULL && + strcmp(MAIN_CONNECTION(connection_pool)->sp->user, user) == 0 && + strcmp(MAIN_CONNECTION(connection_pool)->sp->database, database) == 0) { int sock_broken = 0; int j; /* mark this connection is under use */ - MASTER_CONNECTION(connection_pool)->closetime = 0; + MAIN_CONNECTION(connection_pool)->closetime = 0; for (j = 0; j < NUM_BACKENDS; j++) { connection_pool->info[j].counter++; @@ -259,7 +259,7 @@ pool_create_cp(void) for (i = 0; i < pool_config->max_pool; i++) { - if (MASTER_CONNECTION(p) == NULL) + if (MAIN_CONNECTION(p) == NULL) { ret = new_connection(p); if (ret) @@ -277,7 +277,7 @@ pool_create_cp(void) * discard it. */ oldestp = p = pool_connection_pool; - closetime = MASTER_CONNECTION(p)->closetime; + closetime = MAIN_CONNECTION(p)->closetime; pool_index = 0; for (i = 0; i < pool_config->max_pool; i++) @@ -285,13 +285,13 @@ pool_create_cp(void) ereport(DEBUG1, (errmsg("creating connection pool"), errdetail("user: %s database: %s closetime: %ld", - MASTER_CONNECTION(p)->sp->user, - MASTER_CONNECTION(p)->sp->database, - MASTER_CONNECTION(p)->closetime))); + MAIN_CONNECTION(p)->sp->user, + MAIN_CONNECTION(p)->sp->database, + MAIN_CONNECTION(p)->closetime))); - if (MASTER_CONNECTION(p)->closetime < closetime) + if (MAIN_CONNECTION(p)->closetime < closetime) { - closetime = MASTER_CONNECTION(p)->closetime; + closetime = MAIN_CONNECTION(p)->closetime; oldestp = p; pool_index = i; } @@ -305,8 +305,8 @@ pool_create_cp(void) (errmsg("creating connection pool"), errdetail("discarding old %zd th connection. user: %s database: %s", oldestp - pool_connection_pool, - MASTER_CONNECTION(p)->sp->user, - MASTER_CONNECTION(p)->sp->database))); + MAIN_CONNECTION(p)->sp->user, + MAIN_CONNECTION(p)->sp->database))); for (i = 0; i < NUM_BACKENDS; i++) { @@ -360,14 +360,14 @@ pool_connection_pool_timer(POOL_CONNECTION_POOL * backend) /* look for any other timeout */ for (i = 0; i < pool_config->max_pool; i++, p++) { - if (!MASTER_CONNECTION(p)) + if (!MAIN_CONNECTION(p)) continue; - if (!MASTER_CONNECTION(p)->sp) + if (!MAIN_CONNECTION(p)->sp) continue; - if (MASTER_CONNECTION(p)->sp->user == NULL) + if (MAIN_CONNECTION(p)->sp->user == NULL) continue; - if (p != backend && MASTER_CONNECTION(p)->closetime) + if (p != backend && MAIN_CONNECTION(p)->closetime) return; } @@ -409,30 +409,30 @@ pool_backend_timer(void) for (i = 0; i < pool_config->max_pool; i++, p++) { - if (!MASTER_CONNECTION(p)) + if (!MAIN_CONNECTION(p)) continue; - if (!MASTER_CONNECTION(p)->sp) + if (!MAIN_CONNECTION(p)->sp) continue; - if (MASTER_CONNECTION(p)->sp->user == NULL) + if (MAIN_CONNECTION(p)->sp->user == NULL) continue; /* timer expire? */ - if (MASTER_CONNECTION(p)->closetime) + if (MAIN_CONNECTION(p)->closetime) { int freed = 0; ereport(DEBUG1, (errmsg("backend timer handler called"), errdetail("expire time: %ld", - MASTER_CONNECTION(p)->closetime + pool_config->connection_life_time))); + MAIN_CONNECTION(p)->closetime + pool_config->connection_life_time))); - if (now >= (MASTER_CONNECTION(p)->closetime + pool_config->connection_life_time)) + if (now >= (MAIN_CONNECTION(p)->closetime + pool_config->connection_life_time)) { /* discard expired connection */ ereport(DEBUG1, (errmsg("backend timer handler called"), errdetail("expired user: \"%s\" database: \"%s\"", - MASTER_CONNECTION(p)->sp->user, MASTER_CONNECTION(p)->sp->database))); + MAIN_CONNECTION(p)->sp->user, MAIN_CONNECTION(p)->sp->database))); pool_send_frontend_exits(p); for (j = 0; j < NUM_BACKENDS; j++) @@ -457,8 +457,8 @@ pool_backend_timer(void) else { /* look for nearest timer */ - if (MASTER_CONNECTION(p)->closetime < nearest) - nearest = MASTER_CONNECTION(p)->closetime; + if (MAIN_CONNECTION(p)->closetime < nearest) + nearest = MAIN_CONNECTION(p)->closetime; } } } @@ -931,16 +931,16 @@ static POOL_CONNECTION_POOL * new_connection(POOL_CONNECTION_POOL * p) /* set down status to local status area */ *(my_backend_status[i]) = CON_DOWN; - /* if master_node_id is not updated, then update it */ - if (Req_info->master_node_id == i) + /* if main_node_id is not updated, then update it */ + if (Req_info->main_node_id == i) { - int old_master = Req_info->master_node_id; + int old_main = Req_info->main_node_id; - Req_info->master_node_id = get_next_master_node(); + Req_info->main_node_id = get_next_main_node(); ereport(LOG, - (errmsg("master node %d is down. Update master node to %d", - old_master, Req_info->master_node_id))); + (errmsg("main node %d is down. Update main node to %d", + old_main, Req_info->main_node_id))); } /* @@ -1048,11 +1048,11 @@ close_all_backend_connections(void) for (i = 0; i < pool_config->max_pool; i++, p++) { - if (!MASTER_CONNECTION(p)) + if (!MAIN_CONNECTION(p)) continue; - if (!MASTER_CONNECTION(p)->sp) + if (!MAIN_CONNECTION(p)->sp) continue; - if (MASTER_CONNECTION(p)->sp->user == NULL) + if (MAIN_CONNECTION(p)->sp->user == NULL) continue; pool_send_frontend_exits(p); } diff --git a/src/protocol/pool_pg_utils.c b/src/protocol/pool_pg_utils.c index 50bcd41..9a41141 100644 --- a/src/protocol/pool_pg_utils.c +++ b/src/protocol/pool_pg_utils.c @@ -319,7 +319,7 @@ select_load_balancing_node(void) */ if (SL_MODE && pool_config->redirect_dbnames) { - char *database = MASTER_CONNECTION(ses->backend)->sp->database; + char *database = MAIN_CONNECTION(ses->backend)->sp->database; /* * Check to see if the database matches any of @@ -346,7 +346,7 @@ select_load_balancing_node(void) */ if (SL_MODE && pool_config->redirect_app_names) { - char *app_name = MASTER_CONNECTION(ses->backend)->sp->application_name; + char *app_name = MAIN_CONNECTION(ses->backend)->sp->application_name; /* * Check only if application name is set. Old applications may not @@ -417,7 +417,7 @@ select_load_balancing_node(void) } /* Choose a backend in random manner with weight */ - selected_slot = MASTER_NODE_ID; + selected_slot = MAIN_NODE_ID; total_weight = 0.0; for (i = 0; i < NUM_BACKENDS; i++) @@ -625,14 +625,14 @@ Pgversion(POOL_CONNECTION_POOL * backend) * standby: any of standby node * numeric: physical node id * - * If specified node does exist, returns MASTER_NODE_ID. If "standby" is + * If specified node does exist, returns MAIN_NODE_ID. If "standby" is * specified, returns -1. Caller should choose one of standby nodes * appropriately. */ static int choose_db_node_id(char *str) { - int node_id = MASTER_NODE_ID; + int node_id = MAIN_NODE_ID; if (!strcmp("primary", str) && PRIMARY_NODE_ID >= 0) { diff --git a/src/protocol/pool_process_query.c b/src/protocol/pool_process_query.c index e55396b..640f5db 100644 --- a/src/protocol/pool_process_query.c +++ b/src/protocol/pool_process_query.c @@ -300,8 +300,8 @@ pool_process_query(POOL_CONNECTION * frontend, * If we have pending data in master, we need to process * it */ - if (pool_ssl_pending(MASTER(backend)) || - !pool_read_buffer_is_empty(MASTER(backend))) + if (pool_ssl_pending(MAIN(backend)) || + !pool_read_buffer_is_empty(MAIN(backend))) { status = ProcessBackendResponse(frontend, backend, &state, &num_fields); if (status != POOL_CONTINUE) @@ -321,7 +321,7 @@ pool_process_query(POOL_CONNECTION * frontend, * If we have pending data in master, we need * to process it */ - if (IS_MASTER_NODE_ID(i)) + if (IS_MAIN_NODE_ID(i)) { status = ProcessBackendResponse(frontend, backend, &state, &num_fields); if (status != POOL_CONTINUE) @@ -355,7 +355,7 @@ pool_process_query(POOL_CONNECTION * frontend, * only from primary node. But * since we have sent the query to * the standby, so the current - * MASTER_NODE_ID will be pointing + * MAIN_NODE_ID will be pointing * to the standby node. And we * will get stuck if we keep * waiting for the current master @@ -398,10 +398,10 @@ pool_process_query(POOL_CONNECTION * frontend, (errmsg("pool process query"), errdetail("received %c packet from backend %d. Don't dicard and read %c packet from master", kind, i, kind))); - pool_read_with_error(CONNECTION(backend, MASTER_NODE_ID), &kind, sizeof(kind), + pool_read_with_error(CONNECTION(backend, MAIN_NODE_ID), &kind, sizeof(kind), "reading message kind from backend"); - pool_unread(CONNECTION(backend, MASTER_NODE_ID), &kind, sizeof(kind)); + pool_unread(CONNECTION(backend, MAIN_NODE_ID), &kind, sizeof(kind)); } } else if (SL_MODE) @@ -704,13 +704,13 @@ SimpleForwardToFrontend(char kind, POOL_CONNECTION * frontend, int sendlen; int i; - pool_read(MASTER(backend), &len, sizeof(len)); + pool_read(MAIN(backend), &len, sizeof(len)); len = ntohl(len); len -= 4; len1 = len; - p = pool_read2(MASTER(backend), len); + p = pool_read2(MAIN(backend), len); if (p == NULL) ereport(ERROR, (errmsg("unable to forward message to frontend"), @@ -732,7 +732,7 @@ SimpleForwardToFrontend(char kind, POOL_CONNECTION * frontend, continue; #endif - if (VALID_BACKEND(i) && !IS_MASTER_NODE_ID(i)) + if (VALID_BACKEND(i) && !IS_MAIN_NODE_ID(i)) { #ifdef NOT_USED if (use_sync_map == POOL_SYNC_MAP_IS_VALID && !pool_is_set_sync_map(i)) @@ -904,7 +904,7 @@ ParameterStatus(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend) (errmsg("unable to process parameter status"), errdetail("read on backend failed"))); - len = len_array[MASTER_NODE_ID]; + len = len_array[MAIN_NODE_ID]; sendlen = htonl(len); pool_write(frontend, &sendlen, sizeof(sendlen)); @@ -927,7 +927,7 @@ ParameterStatus(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend) (errmsg("process parameter status"), errdetail("backend:%d name:\"%s\" value:\"%s\"", i, name, value))); - if (IS_MASTER_NODE_ID(i)) + if (IS_MAIN_NODE_ID(i)) { len1 = len; int pos; @@ -942,7 +942,7 @@ ParameterStatus(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend) } #ifdef DEBUG - pool_param_debug_print(&MASTER(backend)->params); + pool_param_debug_print(&MAIN(backend)->params); #endif } } @@ -2671,30 +2671,30 @@ insert_lock(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, char *qu } } - per_node_statement_log(backend, MASTER_NODE_ID, qbuf); + per_node_statement_log(backend, MAIN_NODE_ID, qbuf); if (lock_kind == 1) { if (pool_get_session_context(true) && pool_is_doing_extended_query_message()) { - do_query(MASTER(backend), qbuf, &result, MAJOR(backend)); + do_query(MAIN(backend), qbuf, &result, MAJOR(backend)); } else { - status = do_command(frontend, MASTER(backend), qbuf, MAJOR(backend), MASTER_CONNECTION(backend)->pid, - MASTER_CONNECTION(backend)->key, 0); + status = do_command(frontend, MAIN(backend), qbuf, MAJOR(backend), MAIN_CONNECTION(backend)->pid, + MAIN_CONNECTION(backend)->key, 0); } } else if (lock_kind == 2) { - do_query(MASTER(backend), qbuf, &result, MAJOR(backend)); + do_query(MAIN(backend), qbuf, &result, MAJOR(backend)); } else { POOL_SELECT_RESULT *result; /* issue row lock command */ - do_query(MASTER(backend), qbuf, &result, MAJOR(backend)); + do_query(MAIN(backend), qbuf, &result, MAJOR(backend)); if (status == POOL_CONTINUE) { /* does oid exist in insert_lock table? */ @@ -2707,10 +2707,10 @@ insert_lock(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, char *qu status = add_lock_target(frontend, backend, table); if (status == POOL_CONTINUE) { - per_node_statement_log(backend, MASTER_NODE_ID, qbuf); + per_node_statement_log(backend, MAIN_NODE_ID, qbuf); /* issue row lock command */ - do_query(MASTER(backend), qbuf, &result, MAJOR(backend)); + do_query(MAIN(backend), qbuf, &result, MAJOR(backend)); if (!(result && result->data[0] && !strcmp(result->data[0], "1"))) ereport(FATAL, @@ -2729,18 +2729,18 @@ insert_lock(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, char *qu /* try to lock table finally, if row lock failed */ lock_kind = 1; snprintf(qbuf, sizeof(qbuf), "LOCK TABLE %s IN SHARE ROW EXCLUSIVE MODE", table); - per_node_statement_log(backend, MASTER_NODE_ID, qbuf); + per_node_statement_log(backend, MAIN_NODE_ID, qbuf); if (pool_get_session_context(true) && pool_is_doing_extended_query_message()) { - do_query(MASTER(backend), qbuf, &result, MAJOR(backend)); + do_query(MAIN(backend), qbuf, &result, MAJOR(backend)); if (result) free_select_result(result); } else { - status = do_command(frontend, MASTER(backend), qbuf, MAJOR(backend), MASTER_CONNECTION(backend)->pid, - MASTER_CONNECTION(backend)->key, 0); + status = do_command(frontend, MAIN(backend), qbuf, MAJOR(backend), MAIN_CONNECTION(backend)->pid, + MAIN_CONNECTION(backend)->key, 0); } } } @@ -2754,11 +2754,11 @@ insert_lock(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, char *qu for (i = 0; i < NUM_BACKENDS; i++) { - if (VALID_BACKEND(i) && !IS_MASTER_NODE_ID(i)) + if (VALID_BACKEND(i) && !IS_MAIN_NODE_ID(i)) { if (deadlock_detected) status = do_command(frontend, CONNECTION(backend, i), POOL_ERROR_QUERY, PROTO_MAJOR_V3, - MASTER_CONNECTION(backend)->pid, MASTER_CONNECTION(backend)->key, 0); + MAIN_CONNECTION(backend)->pid, MAIN_CONNECTION(backend)->key, 0); else { if (lock_kind == 1) @@ -2766,14 +2766,14 @@ insert_lock(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, char *qu per_node_statement_log(backend, i, qbuf); if (pool_get_session_context(true) && pool_is_doing_extended_query_message()) { - do_query(MASTER(backend), qbuf, &result, MAJOR(backend)); + do_query(MAIN(backend), qbuf, &result, MAJOR(backend)); if (result) free_select_result(result); } else { status = do_command(frontend, CONNECTION(backend, i), qbuf, PROTO_MAJOR_V3, - MASTER_CONNECTION(backend)->pid, MASTER_CONNECTION(backend)->key, 0); + MAIN_CONNECTION(backend)->pid, MAIN_CONNECTION(backend)->key, 0); } } else if (lock_kind == 2) @@ -2845,10 +2845,10 @@ static POOL_STATUS add_lock_target(POOL_CONNECTION * frontend, POOL_CONNECTION_P ereport(LOG, (errmsg("add lock target: not lock the row where reloid is 0"))); - per_node_statement_log(backend, MASTER_NODE_ID, "LOCK TABLE pgpool_catalog.insert_lock IN SHARE ROW EXCLUSIVE MODE"); + per_node_statement_log(backend, MAIN_NODE_ID, "LOCK TABLE pgpool_catalog.insert_lock IN SHARE ROW EXCLUSIVE MODE"); - if (do_command(frontend, MASTER(backend), "LOCK TABLE pgpool_catalog.insert_lock IN SHARE ROW EXCLUSIVE MODE", - PROTO_MAJOR_V3, MASTER_CONNECTION(backend)->pid, MASTER_CONNECTION(backend)->key, 0) != POOL_CONTINUE) + if (do_command(frontend, MAIN(backend), "LOCK TABLE pgpool_catalog.insert_lock IN SHARE ROW EXCLUSIVE MODE", + PROTO_MAJOR_V3, MAIN_CONNECTION(backend)->pid, MAIN_CONNECTION(backend)->key, 0) != POOL_CONTINUE) ereport(ERROR, (errmsg("unable to add lock target"), errdetail("do_command returned DEADLOCK status"))); @@ -2918,8 +2918,8 @@ has_lock_target(POOL_CONNECTION * frontend, snprintf(qbuf, sizeof(qbuf), "SELECT 1 FROM pgpool_catalog.insert_lock WHERE reloid = 0%s", suffix); } - per_node_statement_log(backend, MASTER_NODE_ID, qbuf); - do_query(MASTER(backend), qbuf, &result, MAJOR(backend)); + per_node_statement_log(backend, MAIN_NODE_ID, qbuf); + do_query(MAIN(backend), qbuf, &result, MAJOR(backend)); if (result && result->data[0] && !strcmp(result->data[0], "1")) { free_select_result(result); @@ -2956,9 +2956,9 @@ static POOL_STATUS insert_oid_into_insert_lock(POOL_CONNECTION * frontend, snprintf(qbuf, sizeof(qbuf), "INSERT INTO pgpool_catalog.insert_lock VALUES (0)"); } - per_node_statement_log(backend, MASTER_NODE_ID, qbuf); - status = do_command(frontend, MASTER(backend), qbuf, PROTO_MAJOR_V3, - MASTER_CONNECTION(backend)->pid, MASTER_CONNECTION(backend)->key, 0); + per_node_statement_log(backend, MAIN_NODE_ID, qbuf); + status = do_command(frontend, MAIN(backend), qbuf, PROTO_MAJOR_V3, + MAIN_CONNECTION(backend)->pid, MAIN_CONNECTION(backend)->key, 0); return status; } @@ -3281,9 +3281,9 @@ read_kind_from_backend(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backen { ereport(DEBUG5, (errmsg("reading backend data packet kind"), - errdetail("master node id: %d", MASTER_NODE_ID))); + errdetail("master node id: %d", MAIN_NODE_ID))); - read_kind_from_one_backend(frontend, backend, (char *) &kind, MASTER_NODE_ID); + read_kind_from_one_backend(frontend, backend, (char *) &kind, MAIN_NODE_ID); /* * If we received a notification message in native replication mode, other @@ -3297,12 +3297,12 @@ read_kind_from_backend(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backen ereport(DEBUG5, (errmsg("reading backend data packet kind"), errdetail("received notification message for master node %d", - MASTER_NODE_ID))); + MAIN_NODE_ID))); if (msg) pool_pending_message_free_pending_message(msg); return; } - pool_unread(CONNECTION(backend, MASTER_NODE_ID), &kind, sizeof(kind)); + pool_unread(CONNECTION(backend, MAIN_NODE_ID), &kind, sizeof(kind)); } for (i = 0; i < NUM_BACKENDS; i++) @@ -3367,7 +3367,7 @@ read_kind_from_backend(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backen (errmsg("reading backend data packet kind"), errdetail("parameter name: %s value: \"%s\"", p, value))); - if (IS_MASTER_NODE_ID(i)) + if (IS_MAIN_NODE_ID(i)) { int pos; pool_add_param(&CONNECTION(backend, i)->params, p, value); @@ -3508,8 +3508,8 @@ read_kind_from_backend(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backen * received. In this case we need to re-sync either master or standby. * So we check not only the standby but master node. */ - if (session_context->load_balance_node_id != MASTER_NODE_ID && - (kind_list[MASTER_NODE_ID] == 'Z' || + if (session_context->load_balance_node_id != MAIN_NODE_ID && + (kind_list[MAIN_NODE_ID] == 'Z' || kind_list[session_context->load_balance_node_id] == 'Z') && SL_MODE) { @@ -3517,10 +3517,10 @@ read_kind_from_backend(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backen char *buf; int len; - if (kind_list[MASTER_NODE_ID] == 'Z') + if (kind_list[MAIN_NODE_ID] == 'Z') s = CONNECTION(backend, session_context->load_balance_node_id); else - s = CONNECTION(backend, MASTER_NODE_ID); + s = CONNECTION(backend, MAIN_NODE_ID); /* skip len and contents corresponding standby data */ pool_read(s, &len, sizeof(len)); @@ -3590,10 +3590,10 @@ read_kind_from_backend(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backen */ else if (NATIVE_REPLICATION && query_context->parse_tree && is_commit_query(query_context->parse_tree) && - kind_list[MASTER_NODE_ID] == 'E' && - is_all_standbys_command_complete(kind_list, NUM_BACKENDS, MASTER_NODE_ID)) + kind_list[MAIN_NODE_ID] == 'E' && + is_all_standbys_command_complete(kind_list, NUM_BACKENDS, MAIN_NODE_ID)) { - *decided_kind = kind_list[MASTER_NODE_ID]; + *decided_kind = kind_list[MAIN_NODE_ID]; ereport(LOG, (errmsg("reading backend data packet kind. Error on primary while all standbys are normal"), errdetail("do not degenerate because it is likely caused by a delayed commit"))); @@ -3605,7 +3605,7 @@ read_kind_from_backend(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backen else if (max_count <= NUM_BACKENDS / 2.0) { /* no one gets majority. We trust master node's kind */ - trust_kind = kind_list[MASTER_NODE_ID]; + trust_kind = kind_list[MAIN_NODE_ID]; } else /* max_count > NUM_BACKENDS / 2.0 */ { @@ -3850,7 +3850,7 @@ query_ps_status(char *query, POOL_CONNECTION_POOL * backend) if (*query == '\0') return; - sp = MASTER_CONNECTION(backend)->sp; + sp = MAIN_CONNECTION(backend)->sp; if (sp) i = snprintf(psbuf, sizeof(psbuf) - 1, "%s %s %s ", sp->user, sp->database, remote_ps_data); @@ -4044,7 +4044,7 @@ start_internal_transaction(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * ba per_node_statement_log(backend, i, "BEGIN"); if (do_command(frontend, CONNECTION(backend, i), "BEGIN", MAJOR(backend), - MASTER_CONNECTION(backend)->pid, MASTER_CONNECTION(backend)->key, 0) != POOL_CONTINUE) + MAIN_CONNECTION(backend)->pid, MAIN_CONNECTION(backend)->key, 0) != POOL_CONTINUE) ereport(ERROR, (errmsg("unable to start the internal transaction"), errdetail("do_command returned DEADLOCK status"))); @@ -4080,7 +4080,7 @@ end_internal_transaction(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * back /* We need to commit from secondary to master. */ for (i = 0; i < NUM_BACKENDS; i++) { - if (VALID_BACKEND(i) && !IS_MASTER_NODE_ID(i) && + if (VALID_BACKEND(i) && !IS_MAIN_NODE_ID(i) && TSTATE(backend, i) != 'I' && INTERNAL_TRANSACTION_STARTED(backend, i)) { @@ -4097,7 +4097,7 @@ end_internal_transaction(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * back PG_TRY(); { if (do_command(frontend, CONNECTION(backend, i), "COMMIT", MAJOR(backend), - MASTER_CONNECTION(backend)->pid, MASTER_CONNECTION(backend)->key, 1) != POOL_CONTINUE) + MAIN_CONNECTION(backend)->pid, MAIN_CONNECTION(backend)->key, 1) != POOL_CONTINUE) { ereport(ERROR, (errmsg("unable to COMMIT the transaction"), @@ -4116,23 +4116,23 @@ end_internal_transaction(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * back } /* Commit on master */ - if (TSTATE(backend, MASTER_NODE_ID) != 'I' && - INTERNAL_TRANSACTION_STARTED(backend, MASTER_NODE_ID)) + if (TSTATE(backend, MAIN_NODE_ID) != 'I' && + INTERNAL_TRANSACTION_STARTED(backend, MAIN_NODE_ID)) { if (MAJOR(backend) == PROTO_MAJOR_V3) { /* * Skip rest of Ready for Query packet */ - pool_read(CONNECTION(backend, MASTER_NODE_ID), &len, sizeof(len)); - pool_read(CONNECTION(backend, MASTER_NODE_ID), &tstate, sizeof(tstate)); + pool_read(CONNECTION(backend, MAIN_NODE_ID), &len, sizeof(len)); + pool_read(CONNECTION(backend, MAIN_NODE_ID), &tstate, sizeof(tstate)); } - per_node_statement_log(backend, MASTER_NODE_ID, "COMMIT"); + per_node_statement_log(backend, MAIN_NODE_ID, "COMMIT"); PG_TRY(); { - if (do_command(frontend, MASTER(backend), "COMMIT", MAJOR(backend), - MASTER_CONNECTION(backend)->pid, MASTER_CONNECTION(backend)->key, 1) != POOL_CONTINUE) + if (do_command(frontend, MAIN(backend), "COMMIT", MAJOR(backend), + MAIN_CONNECTION(backend)->pid, MAIN_CONNECTION(backend)->key, 1) != POOL_CONTINUE) { ereport(ERROR, (errmsg("unable to COMMIT the transaction"), @@ -4141,11 +4141,11 @@ end_internal_transaction(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * back } PG_CATCH(); { - INTERNAL_TRANSACTION_STARTED(backend, MASTER_NODE_ID) = false; + INTERNAL_TRANSACTION_STARTED(backend, MAIN_NODE_ID) = false; PG_RE_THROW(); } PG_END_TRY(); - INTERNAL_TRANSACTION_STARTED(backend, MASTER_NODE_ID) = false; + INTERNAL_TRANSACTION_STARTED(backend, MAIN_NODE_ID) = false; } } PG_CATCH(); @@ -4959,12 +4959,12 @@ SELECT_RETRY: } } - if (FD_ISSET(MASTER(backend)->fd, &exceptmask)) + if (FD_ISSET(MAIN(backend)->fd, &exceptmask)) ereport(FATAL, (errmsg("unable to read from backend socket"), errdetail("exception occured on backend socket"))); - else if (FD_ISSET(MASTER(backend)->fd, &readmask)) + else if (FD_ISSET(MAIN(backend)->fd, &readmask)) { status = ProcessBackendResponse(frontend, backend, state, num_fields); if (status != POOL_CONTINUE) @@ -4980,8 +4980,8 @@ void pool_dump_valid_backend(int backend_id) { ereport(LOG, - (errmsg("RAW_MODE:%d REAL_MASTER_NODE_ID:%d pool_is_node_to_be_sent_in_current_query:%d my_backend_status:%d", - RAW_MODE, REAL_MASTER_NODE_ID, pool_is_node_to_be_sent_in_current_query(backend_id), + (errmsg("RAW_MODE:%d REAL_MAIN_NODE_ID:%d pool_is_node_to_be_sent_in_current_query:%d my_backend_status:%d", + RAW_MODE, REAL_MAIN_NODE_ID, pool_is_node_to_be_sent_in_current_query(backend_id), *my_backend_status[backend_id]))); } diff --git a/src/protocol/pool_proto2.c b/src/protocol/pool_proto2.c index b7c85c3..ffca996 100644 --- a/src/protocol/pool_proto2.c +++ b/src/protocol/pool_proto2.c @@ -58,11 +58,11 @@ AsciiRow(POOL_CONNECTION * frontend, return POOL_CONTINUE; /* NULL map */ - pool_read(MASTER(backend), nullmap, nbytes); + pool_read(MAIN(backend), nullmap, nbytes); memcpy(nullmap1, nullmap, nbytes); for (i = 0; i < NUM_BACKENDS; i++) { - if (VALID_BACKEND(i) && !IS_MASTER_NODE_ID(i)) + if (VALID_BACKEND(i) && !IS_MAIN_NODE_ID(i)) { pool_read(CONNECTION(backend, i), nullmap, nbytes); if (memcmp(nullmap, nullmap1, nbytes)) @@ -75,7 +75,7 @@ AsciiRow(POOL_CONNECTION * frontend, */ ereport(DEBUG1, (errmsg("processing ASCII row"), - errdetail("NULLMAP is different between master and backend no %d", i))); + errdetail("NULLMAP is different between main and backend no %d", i))); } } } @@ -94,7 +94,7 @@ AsciiRow(POOL_CONNECTION * frontend, if (mask & nullmap[i / 8]) { /* field size */ - if (pool_read(MASTER(backend), &size, sizeof(int)) < 0) + if (pool_read(MAIN(backend), &size, sizeof(int)) < 0) return POOL_END; size1 = ntohl(size) - 4; @@ -102,7 +102,7 @@ AsciiRow(POOL_CONNECTION * frontend, /* read and send actual data only when size > 0 */ if (size1 > 0) { - sendbuf = pool_read2(MASTER(backend), size1); + sendbuf = pool_read2(MAIN(backend), size1); if (sendbuf == NULL) return POOL_END; } @@ -119,7 +119,7 @@ AsciiRow(POOL_CONNECTION * frontend, for (j = 0; j < NUM_BACKENDS; j++) { - if (VALID_BACKEND(j) && !IS_MASTER_NODE_ID(j)) + if (VALID_BACKEND(j) && !IS_MAIN_NODE_ID(j)) { /* field size */ if (pool_read(CONNECTION(backend, j), &size, sizeof(int)) < 0) @@ -137,7 +137,7 @@ AsciiRow(POOL_CONNECTION * frontend, if (size != size1) ereport(DEBUG1, (errmsg("processing ASCII row"), - errdetail("size of field no %d does not match between master [size:%d] and backend no %d [size:%d]", + errdetail("size of field no %d does not match between main [size:%d] and backend no %d [size:%d]", i, ntohl(size), j, ntohl(size1)))); /* read and send actual data only when size > 0 */ @@ -183,13 +183,13 @@ BinaryRow(POOL_CONNECTION * frontend, return POOL_CONTINUE; /* NULL map */ - pool_read(MASTER(backend), nullmap, nbytes); + pool_read(MAIN(backend), nullmap, nbytes); if (pool_write(frontend, nullmap, nbytes) < 0) return POOL_END; memcpy(nullmap1, nullmap, nbytes); for (i = 0; i < NUM_BACKENDS; i++) { - if (VALID_BACKEND(i) && !IS_MASTER_NODE_ID(i)) + if (VALID_BACKEND(i) && !IS_MAIN_NODE_ID(i)) { pool_read(CONNECTION(backend, i), nullmap, nbytes); if (memcmp(nullmap, nullmap1, nbytes)) @@ -202,7 +202,7 @@ BinaryRow(POOL_CONNECTION * frontend, */ ereport(DEBUG1, (errmsg("processing binary row"), - errdetail("NULLMAP is different between master and backend no %d", i))); + errdetail("NULLMAP is different between main and backend no %d", i))); } } } @@ -218,11 +218,11 @@ BinaryRow(POOL_CONNECTION * frontend, if (mask & nullmap[i / 8]) { /* field size */ - if (pool_read(MASTER(backend), &size, sizeof(int)) < 0) + if (pool_read(MAIN(backend), &size, sizeof(int)) < 0) return POOL_END; for (j = 0; j < NUM_BACKENDS; j++) { - if (VALID_BACKEND(j) && !IS_MASTER_NODE_ID(j)) + if (VALID_BACKEND(j) && !IS_MAIN_NODE_ID(j)) { /* field size */ if (pool_read(CONNECTION(backend, i), &size, sizeof(int)) < 0) @@ -237,14 +237,14 @@ BinaryRow(POOL_CONNECTION * frontend, if (size != size1) ereport(DEBUG1, (errmsg("processing binary row"), - errdetail("size of field no %d does not match between master [size:%d] and backend no %d [size:%d]", + errdetail("size of field no %d does not match between main [size:%d] and backend no %d [size:%d]", i, ntohl(size), j, ntohl(size1)))); } buf = NULL; /* forward to frontend */ - if (IS_MASTER_NODE_ID(j)) + if (IS_MAIN_NODE_ID(j)) pool_write(frontend, &size, sizeof(int)); size = ntohl(size) - 4; @@ -255,7 +255,7 @@ BinaryRow(POOL_CONNECTION * frontend, if (buf == NULL) return POOL_END; - if (IS_MASTER_NODE_ID(j)) + if (IS_MAIN_NODE_ID(j)) { pool_write(frontend, buf, size); } @@ -283,20 +283,20 @@ CompletedResponse(POOL_CONNECTION * frontend, len1 = 0; /* read command tag */ - string = pool_read_string(MASTER(backend), &len, 0); + string = pool_read_string(MAIN(backend), &len, 0); if (string == NULL) return POOL_END; else if (!strncmp(string, "BEGIN", 5)) - TSTATE(backend, MASTER_NODE_ID) = 'T'; + TSTATE(backend, MAIN_NODE_ID) = 'T'; else if (!strncmp(string, "COMMIT", 6) || !strncmp(string, "ROLLBACK", 8)) - TSTATE(backend, MASTER_NODE_ID) = 'I'; + TSTATE(backend, MAIN_NODE_ID) = 'I'; len1 = len; string1 = pstrdup(string); for (i = 0; i < NUM_BACKENDS; i++) { - if (!VALID_BACKEND(i) || IS_MASTER_NODE_ID(i)) + if (!VALID_BACKEND(i) || IS_MAIN_NODE_ID(i)) continue; /* read command tag */ @@ -316,7 +316,7 @@ CompletedResponse(POOL_CONNECTION * frontend, { ereport(DEBUG1, (errmsg("processing completed response"), - errdetail("message length does not match between master(%d \"%s\",) and %d th server (%d \"%s\",)", + errdetail("message length does not match between main(%d \"%s\",) and %d th server (%d \"%s\",)", len, string, i, len1, string1))); /* we except INSERT, because INSERT response has OID */ @@ -349,7 +349,7 @@ CursorResponse(POOL_CONNECTION * frontend, int i; /* read cursor name */ - string = pool_read_string(MASTER(backend), &len, 0); + string = pool_read_string(MAIN(backend), &len, 0); if (string == NULL) return POOL_END; len1 = len; @@ -357,7 +357,7 @@ CursorResponse(POOL_CONNECTION * frontend, for (i = 0; i < NUM_BACKENDS; i++) { - if (VALID_BACKEND(i) && !IS_MASTER_NODE_ID(i)) + if (VALID_BACKEND(i) && !IS_MAIN_NODE_ID(i)) { /* read cursor name */ string = pool_read_string(CONNECTION(backend, i), &len, 0); @@ -371,8 +371,8 @@ CursorResponse(POOL_CONNECTION * frontend, ereport(FATAL, (return_code(2), errmsg("unable to process cursor response"), - errdetail("length does not match between master(%d) and %d th backend(%d)", len, i, len1), - errhint("master(%s) %d th backend(%s)", string1, i, string))); + errdetail("length does not match between main(%d) and %d th backend(%d)", len, i, len1), + errhint("main(%s) %d th backend(%s)", string1, i, string))); } } } @@ -487,7 +487,7 @@ FunctionResultResponse(POOL_CONNECTION * frontend, if (VALID_BACKEND(i)) { /* result value itself */ - if ((result = pool_read2(MASTER(backend), len)) == NULL) + if ((result = pool_read2(MAIN(backend), len)) == NULL) ereport(FATAL, (return_code(2), errmsg("unable to process function result response"), @@ -508,7 +508,7 @@ FunctionResultResponse(POOL_CONNECTION * frontend, if (VALID_BACKEND(i)) { /* unused ('0') */ - pool_read(MASTER(backend), &dummy, 1); + pool_read(MAIN(backend), &dummy, 1); } } pool_write(frontend, "0", 1); @@ -575,7 +575,7 @@ NotificationResponse(POOL_CONNECTION * frontend, errmsg("unable to process Notification response"), errdetail("reading from backend node %d failed", i))); - if (IS_MASTER_NODE_ID(i)) + if (IS_MAIN_NODE_ID(i)) { pid1 = pid; len1 = len; @@ -610,11 +610,11 @@ RowDescription(POOL_CONNECTION * frontend, len1; int i; - pool_read(MASTER(backend), &num_fields, sizeof(short)); + pool_read(MAIN(backend), &num_fields, sizeof(short)); num_fields1 = num_fields; for (i = 0; i < NUM_BACKENDS; i++) { - if (VALID_BACKEND(i) && !IS_MASTER_NODE_ID(i)) + if (VALID_BACKEND(i) && !IS_MAIN_NODE_ID(i)) { /* # of fields (could be 0) */ pool_read(CONNECTION(backend, i), &num_fields, sizeof(short)); @@ -623,7 +623,7 @@ RowDescription(POOL_CONNECTION * frontend, ereport(FATAL, (return_code(2), errmsg("unable to process row description"), - errdetail("num_fields does not match between backends master(%d) and %d th backend(%d)", + errdetail("num_fields does not match between backends main(%d) and %d th backend(%d)", num_fields, i, num_fields1))); } } @@ -638,7 +638,7 @@ RowDescription(POOL_CONNECTION * frontend, int j; /* field name */ - string = pool_read_string(MASTER(backend), &len, 0); + string = pool_read_string(MAIN(backend), &len, 0); if (string == NULL) return POOL_END; len1 = len; @@ -646,7 +646,7 @@ RowDescription(POOL_CONNECTION * frontend, for (j = 0; j < NUM_BACKENDS; j++) { - if (VALID_BACKEND(j) && !IS_MASTER_NODE_ID(j)) + if (VALID_BACKEND(j) && !IS_MAIN_NODE_ID(j)) { string = pool_read_string(CONNECTION(backend, j), &len, 0); if (string == NULL) @@ -660,21 +660,21 @@ RowDescription(POOL_CONNECTION * frontend, ereport(FATAL, (return_code(2), errmsg("unable to process row description"), - errdetail("field length does not match between backends master(%d) and %d th backend(%d)", + errdetail("field length does not match between backends main(%d) and %d th backend(%d)", ntohl(len), j, ntohl(len1)))); } } } /* type oid */ - pool_read(MASTER(backend), &oid, sizeof(int)); + pool_read(MAIN(backend), &oid, sizeof(int)); oid1 = oid; ereport(DEBUG1, (errmsg("processing ROW DESCRIPTION"), errdetail("type oid: %d", ntohl(oid)))); for (j = 0; j < NUM_BACKENDS; j++) { - if (VALID_BACKEND(j) && !IS_MASTER_NODE_ID(j)) + if (VALID_BACKEND(j) && !IS_MAIN_NODE_ID(j)) { pool_read(CONNECTION(backend, j), &oid, sizeof(int)); @@ -683,7 +683,7 @@ RowDescription(POOL_CONNECTION * frontend, { ereport(DEBUG1, (errmsg("processing ROW DESCRIPTION"), - errdetail("field oid does not match between backends master(%d) and %d th backend(%d)", + errdetail("field oid does not match between backends main(%d) and %d th backend(%d)", ntohl(oid), j, ntohl(oid1)))); } } @@ -691,18 +691,18 @@ RowDescription(POOL_CONNECTION * frontend, pool_write(frontend, &oid1, sizeof(int)); /* size */ - pool_read(MASTER(backend), &size, sizeof(short)); + pool_read(MAIN(backend), &size, sizeof(short)); size1 = size; for (j = 0; j < NUM_BACKENDS; j++) { - if (VALID_BACKEND(j) && !IS_MASTER_NODE_ID(j)) + if (VALID_BACKEND(j) && !IS_MAIN_NODE_ID(j)) { pool_read(CONNECTION(backend, j), &size, sizeof(short)); if (size1 != size) { ereport(FATAL, (errmsg("data among backends are different"), - errdetail("field size does not match between backends master(%d) and %d th backend(%d", ntohs(size), j, ntohs(size1)))); + errdetail("field size does not match between backends main(%d) and %d th backend(%d", ntohs(size), j, ntohs(size1)))); } } @@ -713,21 +713,21 @@ RowDescription(POOL_CONNECTION * frontend, pool_write(frontend, &size1, sizeof(short)); /* modifier */ - pool_read(MASTER(backend), &mod, sizeof(int)); + pool_read(MAIN(backend), &mod, sizeof(int)); ereport(DEBUG1, (errmsg("processing ROW DESCRIPTION"), errdetail("modifier: %d", ntohs(mod)))); mod1 = mod; for (j = 0; j < NUM_BACKENDS; j++) { - if (VALID_BACKEND(j) && !IS_MASTER_NODE_ID(j)) + if (VALID_BACKEND(j) && !IS_MAIN_NODE_ID(j)) { pool_read(CONNECTION(backend, j), &mod, sizeof(int)); if (mod != mod1) { ereport(DEBUG1, (errmsg("processing ROW DESCRIPTION"), - errdetail("modifier does not match between backends master(%d) and %d th backend(%d)", + errdetail("modifier does not match between backends main(%d) and %d th backend(%d)", ntohl(mod), j, ntohl(mod1)))); } } diff --git a/src/protocol/pool_proto_modules.c b/src/protocol/pool_proto_modules.c index 189dff1..0a640f2 100644 --- a/src/protocol/pool_proto_modules.c +++ b/src/protocol/pool_proto_modules.c @@ -91,7 +91,7 @@ static POOL_STATUS parse_before_bind(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, POOL_SENT_MESSAGE * message, POOL_SENT_MESSAGE * bind_message); -static int *find_victim_nodes(int *ntuples, int nmembers, int master_node, int *number_of_nodes); +static int *find_victim_nodes(int *ntuples, int nmembers, int main_node, int *number_of_nodes); static POOL_STATUS close_standby_transactions(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend); @@ -228,7 +228,7 @@ SimpleQuery(POOL_CONNECTION * frontend, */ if (pool_config->memory_cache_enabled && is_likely_select && !pool_is_writing_transaction() && - TSTATE(backend, NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MASTER_NODE_ID) != 'E') + TSTATE(backend, NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MAIN_NODE_ID) != 'E') { bool foundp; @@ -697,9 +697,9 @@ SimpleQuery(POOL_CONNECTION * frontend, /* * Optimization effort: If there's only one session, we do not - * need to wait for the master node's response, and could execute + * need to wait for the main node's response, and could execute * the query concurrently. In snapshot isolation mode we cannot - * do this optimization because we need to wait for master node's + * do this optimization because we need to wait for main node's * response first. */ if (pool_config->num_init_children == 1 && @@ -711,11 +711,11 @@ SimpleQuery(POOL_CONNECTION * frontend, return status; } - /* Send the query to master node */ - pool_send_and_wait(query_context, 1, MASTER_NODE_ID); + /* Send the query to main node */ + pool_send_and_wait(query_context, 1, MAIN_NODE_ID); /* Check specific errors */ - specific_error = check_errors(backend, MASTER_NODE_ID); + specific_error = check_errors(backend, MAIN_NODE_ID); if (specific_error) { /* log error message */ @@ -733,7 +733,7 @@ SimpleQuery(POOL_CONNECTION * frontend, /* send query to other nodes */ query_context->rewritten_query = msg; query_context->rewritten_length = len; - pool_send_and_wait(query_context, -1, MASTER_NODE_ID); + pool_send_and_wait(query_context, -1, MAIN_NODE_ID); } else { @@ -747,19 +747,19 @@ SimpleQuery(POOL_CONNECTION * frontend, } /* - * Send the query to other than master node. + * Send the query to other than main node. */ - pool_send_and_wait(query_context, -1, MASTER_NODE_ID); + pool_send_and_wait(query_context, -1, MAIN_NODE_ID); } /* - * Send "COMMIT" or "ROLLBACK" to only master node if query is + * Send "COMMIT" or "ROLLBACK" to only main node if query is * "COMMIT" or "ROLLBACK" */ if (commit) { - pool_send_and_wait(query_context, 1, MASTER_NODE_ID); + pool_send_and_wait(query_context, 1, MAIN_NODE_ID); /* * If we are in the snapshot isolation mode, we need to declare @@ -776,7 +776,7 @@ SimpleQuery(POOL_CONNECTION * frontend, } else { - pool_send_and_wait(query_context, 1, MASTER_NODE_ID); + pool_send_and_wait(query_context, 1, MAIN_NODE_ID); } return POOL_CONTINUE; @@ -843,7 +843,7 @@ Execute(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, ereport(DEBUG1, (errmsg("Execute: pool_is_writing_transaction: %d TSTATE: %c", pool_is_writing_transaction(), - TSTATE(backend, NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MASTER_NODE_ID)))); + TSTATE(backend, NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MAIN_NODE_ID)))); /* log query to log file if necessary */ if (pool_config->log_statement) @@ -853,7 +853,7 @@ Execute(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, * Fetch memory cache if possible */ if (pool_config->memory_cache_enabled && !pool_is_writing_transaction() && - (TSTATE(backend, NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MASTER_NODE_ID) != 'E') + (TSTATE(backend, NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MAIN_NODE_ID) != 'E') && pool_is_likely_select(query)) { POOL_STATUS status; @@ -863,7 +863,7 @@ Execute(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, #define STR_ALLOC_SIZE 1024 ereport(DEBUG1, (errmsg("Execute: pool_is_likely_select: true pool_is_writing_transaction: %d TSTATE: %c", pool_is_writing_transaction(), - TSTATE(backend, NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MASTER_NODE_ID)))); + TSTATE(backend, NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MAIN_NODE_ID)))); len = strlen(query) + 1; search_query = MemoryContextStrdup(query_context->memory_context, query); @@ -985,11 +985,11 @@ Execute(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, */ if (!commit) { - /* Send the query to master node */ - pool_extended_send_and_wait(query_context, "E", len, contents, 1, MASTER_NODE_ID, false); + /* Send the query to main node */ + pool_extended_send_and_wait(query_context, "E", len, contents, 1, MAIN_NODE_ID, false); /* Check specific errors */ - specific_error = check_errors(backend, MASTER_NODE_ID); + specific_error = check_errors(backend, MAIN_NODE_ID); if (specific_error) { /* log error message */ @@ -1005,7 +1005,7 @@ Execute(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, memset(msg + len, 0, sizeof(int)); /* send query to other nodes */ - pool_extended_send_and_wait(query_context, "E", len, msg, -1, MASTER_NODE_ID, false); + pool_extended_send_and_wait(query_context, "E", len, msg, -1, MAIN_NODE_ID, false); } else { @@ -1018,16 +1018,16 @@ Execute(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, si_commit_request(); } - pool_extended_send_and_wait(query_context, "E", len, contents, -1, MASTER_NODE_ID, false); + pool_extended_send_and_wait(query_context, "E", len, contents, -1, MAIN_NODE_ID, false); } /* - * send "COMMIT" or "ROLLBACK" to only master node if query is + * send "COMMIT" or "ROLLBACK" to only main node if query is * "COMMIT" or "ROLLBACK" */ if (commit) { - pool_extended_send_and_wait(query_context, "E", len, contents, 1, MASTER_NODE_ID, false); + pool_extended_send_and_wait(query_context, "E", len, contents, 1, MAIN_NODE_ID, false); /* * If we are in the snapshot isolation mode, we need to declare @@ -1047,8 +1047,8 @@ Execute(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, if (!foundp) { - pool_extended_send_and_wait(query_context, "E", len, contents, 1, MASTER_NODE_ID, true); - pool_extended_send_and_wait(query_context, "E", len, contents, -1, MASTER_NODE_ID, true); + pool_extended_send_and_wait(query_context, "E", len, contents, 1, MAIN_NODE_ID, true); + pool_extended_send_and_wait(query_context, "E", len, contents, -1, MAIN_NODE_ID, true); } /* Add pending message */ @@ -1070,14 +1070,14 @@ Execute(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, { ereport(DEBUG1, (errmsg("Execute: TSTATE:%c", - TSTATE(backend, NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MASTER_NODE_ID)))); + TSTATE(backend, NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MAIN_NODE_ID)))); /* * If the query was not READ SELECT, and we are in an explicit * transaction, remember that we had a write query in this * transaction. */ - if (TSTATE(backend, NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MASTER_NODE_ID) == 'T' || + if (TSTATE(backend, NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MAIN_NODE_ID) == 'T' || pool_config->disable_load_balance_on_write == DLBOW_ALWAYS) { /* @@ -1335,7 +1335,7 @@ Parse(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, { char kind; - if (TSTATE(backend, MASTER_NODE_ID) != 'T') + if (TSTATE(backend, MAIN_NODE_ID) != 'T') { int i; @@ -1395,16 +1395,16 @@ Parse(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, * We must synchronize because Parse message acquires table locks. */ ereport(DEBUG1, - (errmsg("Parse: waiting for master completing the query"))); - pool_extended_send_and_wait(query_context, "P", len, contents, 1, MASTER_NODE_ID, false); + (errmsg("Parse: waiting for main node completing the query"))); + pool_extended_send_and_wait(query_context, "P", len, contents, 1, MAIN_NODE_ID, false); /* * We must check deadlock error because a aborted transaction by * detecting deadlock isn't same on all nodes. If a transaction is - * aborted on master node, pgpool send a error query to another nodes. + * aborted on main node, pgpool send a error query to another nodes. */ - deadlock_detected = detect_deadlock_error(MASTER(backend), MAJOR(backend)); + deadlock_detected = detect_deadlock_error(MAIN(backend), MAJOR(backend)); /* * Check if other than deadlock error detected. If so, emit log. This @@ -1412,7 +1412,7 @@ Parse(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, * PostgreSQL does not report what statement caused that error and * make users confused. */ - per_node_error_log(backend, MASTER_NODE_ID, stmt, "Parse: Error or notice message from backend: ", true); + per_node_error_log(backend, MAIN_NODE_ID, stmt, "Parse: Error or notice message from backend: ", true); if (deadlock_detected) { @@ -1425,9 +1425,9 @@ Parse(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, pool_copy_prep_where(query_context->where_to_send, error_qc->where_to_send); ereport(LOG, - (errmsg("Parse: received deadlock error message from master node"))); + (errmsg("Parse: received deadlock error message from main node"))); - pool_send_and_wait(error_qc, -1, MASTER_NODE_ID); + pool_send_and_wait(error_qc, -1, MAIN_NODE_ID); pool_query_context_destroy(error_qc); @@ -1437,7 +1437,7 @@ Parse(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, } else { - pool_extended_send_and_wait(query_context, "P", len, contents, -1, MASTER_NODE_ID, false); + pool_extended_send_and_wait(query_context, "P", len, contents, -1, MAIN_NODE_ID, false); } } else if (SL_MODE) @@ -1452,8 +1452,8 @@ Parse(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, #ifdef NOT_USED pool_clear_sync_map(); #endif - pool_extended_send_and_wait(query_context, "P", len, contents, 1, MASTER_NODE_ID, true); - pool_extended_send_and_wait(query_context, "P", len, contents, -1, MASTER_NODE_ID, true); + pool_extended_send_and_wait(query_context, "P", len, contents, 1, MAIN_NODE_ID, true); + pool_extended_send_and_wait(query_context, "P", len, contents, -1, MAIN_NODE_ID, true); pool_add_sent_message(session_context->uncompleted_message); /* Add pending message */ @@ -1466,7 +1466,7 @@ Parse(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, } else { - pool_extended_send_and_wait(query_context, "P", len, contents, 1, MASTER_NODE_ID, false); + pool_extended_send_and_wait(query_context, "P", len, contents, 1, MAIN_NODE_ID, false); } return POOL_CONTINUE; @@ -1549,7 +1549,7 @@ Bind(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, * primary node. */ if (pool_config->load_balance_mode && pool_is_writing_transaction() && - TSTATE(backend, NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MASTER_NODE_ID) == 'T' && + TSTATE(backend, NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MAIN_NODE_ID) == 'T' && pool_config->disable_load_balance_on_write != DLBOW_OFF) { if (!SL_MODE) @@ -1563,7 +1563,7 @@ Bind(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, } if (pool_config->disable_load_balance_on_write == DLBOW_DML_ADAPTIVE && - TSTATE(backend, NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MASTER_NODE_ID) == 'T') + TSTATE(backend, NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MAIN_NODE_ID) == 'T') { pool_where_to_send(query_context, query_context->original_query, query_context->parse_tree); @@ -1601,7 +1601,7 @@ Bind(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, } ereport(DEBUG1, - (errmsg("Bind: waiting for master completing the query"))); + (errmsg("Bind: waiting for main node completing the query"))); pool_set_query_in_progress(); @@ -1613,8 +1613,8 @@ Bind(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, else nowait = false; - pool_extended_send_and_wait(query_context, "B", len, contents, 1, MASTER_NODE_ID, nowait); - pool_extended_send_and_wait(query_context, "B", len, contents, -1, MASTER_NODE_ID, nowait); + pool_extended_send_and_wait(query_context, "B", len, contents, 1, MAIN_NODE_ID, nowait); + pool_extended_send_and_wait(query_context, "B", len, contents, -1, MAIN_NODE_ID, nowait); if (SL_MODE) { @@ -1696,13 +1696,13 @@ Describe(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, * leads to "portal not found" etc. errors. */ ereport(DEBUG1, - (errmsg("Describe: waiting for master completing the query"))); + (errmsg("Describe: waiting for main node completing the query"))); nowait = (SL_MODE ? true : false); pool_set_query_in_progress(); - pool_extended_send_and_wait(query_context, "D", len, contents, 1, MASTER_NODE_ID, nowait); - pool_extended_send_and_wait(query_context, "D", len, contents, -1, MASTER_NODE_ID, nowait); + pool_extended_send_and_wait(query_context, "D", len, contents, 1, MAIN_NODE_ID, nowait); + pool_extended_send_and_wait(query_context, "D", len, contents, -1, MAIN_NODE_ID, nowait); if (SL_MODE) { @@ -1794,14 +1794,14 @@ Close(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, */ ereport(DEBUG1, - (errmsg("Close: waiting for master completing the query"))); + (errmsg("Close: waiting for main node completing the query"))); pool_set_query_in_progress(); if (!SL_MODE) { - pool_extended_send_and_wait(query_context, "C", len, contents, 1, MASTER_NODE_ID, false); - pool_extended_send_and_wait(query_context, "C", len, contents, -1, MASTER_NODE_ID, false); + pool_extended_send_and_wait(query_context, "C", len, contents, 1, MAIN_NODE_ID, false); + pool_extended_send_and_wait(query_context, "C", len, contents, -1, MAIN_NODE_ID, false); } else { @@ -1823,8 +1823,8 @@ Close(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, query_context->where_to_send[session_context->load_balance_node_id] = true; } - pool_extended_send_and_wait(query_context, "C", len, contents, 1, MASTER_NODE_ID, true); - pool_extended_send_and_wait(query_context, "C", len, contents, -1, MASTER_NODE_ID, true); + pool_extended_send_and_wait(query_context, "C", len, contents, 1, MAIN_NODE_ID, true); + pool_extended_send_and_wait(query_context, "C", len, contents, -1, MAIN_NODE_ID, true); /* Add pending message */ pmsg = pool_pending_message_create('C', len, contents); @@ -1936,7 +1936,7 @@ ReadyForQuery(POOL_CONNECTION * frontend, char msgbuf[128]; victim_nodes = find_victim_nodes(session_context->ntuples, NUM_BACKENDS, - MASTER_NODE_ID, &number_of_nodes); + MAIN_NODE_ID, &number_of_nodes); if (victim_nodes) { int i; @@ -2033,7 +2033,7 @@ ReadyForQuery(POOL_CONNECTION * frontend, /* if (pool_is_query_in_progress() && allow_close_transaction) */ if (allow_close_transaction) { - bool internal_transaction_started = INTERNAL_TRANSACTION_STARTED(backend, MASTER_NODE_ID); + bool internal_transaction_started = INTERNAL_TRANSACTION_STARTED(backend, MAIN_NODE_ID); if (end_internal_transaction(frontend, backend) != POOL_CONTINUE) return POOL_END; @@ -2060,7 +2060,7 @@ ReadyForQuery(POOL_CONNECTION * frontend, * Set transaction state for each node */ state = TSTATE(backend, - NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MASTER_NODE_ID); + NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MAIN_NODE_ID); for (i = 0; i < NUM_BACKENDS; i++) { @@ -2076,9 +2076,9 @@ ReadyForQuery(POOL_CONNECTION * frontend, errdetail("transaction state '%c'(%02x)", state, state))); /* - * The transaction state to be returned to frontend is master's. + * The transaction state to be returned to frontend is main node's. */ - if (i == (NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MASTER_NODE_ID)) + if (i == (NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MAIN_NODE_ID)) { state = kind; } @@ -2154,7 +2154,7 @@ ReadyForQuery(POOL_CONNECTION * frontend, if (pool_is_doing_extended_query_message()) { if (session_context->query_context && - session_context->query_context->query_state[MASTER_NODE_ID] == POOL_EXECUTE_COMPLETE) + session_context->query_context->query_state[MAIN_NODE_ID] == POOL_EXECUTE_COMPLETE) { pool_handle_query_cache(backend, session_context->query_context->query_w_hex, node, state); if (session_context->query_context->query_w_hex) @@ -2183,7 +2183,7 @@ ReadyForQuery(POOL_CONNECTION * frontend, { if ((pool_is_doing_extended_query_message() && session_context->query_context && - session_context->query_context->query_state[MASTER_NODE_ID] != POOL_UNPARSED && + session_context->query_context->query_state[MAIN_NODE_ID] != POOL_UNPARSED && session_context->uncompleted_message) || (!pool_is_doing_extended_query_message() && session_context->uncompleted_message && session_context->uncompleted_message->kind != 0)) @@ -2226,12 +2226,12 @@ static POOL_STATUS close_standby_transactions(POOL_CONNECTION * frontend, if (CONNECTION_SLOT(backend, i) && TSTATE(backend, i) == 'T' && BACKEND_INFO(i).backend_status == CON_UP && - (NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MASTER_NODE_ID) != i) + (NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MAIN_NODE_ID) != i) { per_node_statement_log(backend, i, "COMMIT"); if (do_command(frontend, CONNECTION(backend, i), "COMMIT", MAJOR(backend), - MASTER_CONNECTION(backend)->pid, - MASTER_CONNECTION(backend)->key, 0) != POOL_CONTINUE) + MAIN_CONNECTION(backend)->pid, + MAIN_CONNECTION(backend)->key, 0) != POOL_CONTINUE) ereport(ERROR, (errmsg("unable to close standby transactions"), errdetail("do_command returned DEADLOCK status"))); @@ -2382,17 +2382,17 @@ ParameterDescription(POOL_CONNECTION * frontend, /* get number of parameters in original query */ num_params = session_context->query_context->num_original_params; - pool_read(MASTER(backend), &len, sizeof(len)); + pool_read(MAIN(backend), &len, sizeof(len)); len = ntohl(len); len -= sizeof(int32); len1 = len; /* number of parameters in rewritten query is just discarded */ - pool_read(MASTER(backend), &num_dmy, sizeof(int16)); + pool_read(MAIN(backend), &num_dmy, sizeof(int16)); len -= sizeof(int16); - p = pool_read2(MASTER(backend), len); + p = pool_read2(MAIN(backend), len); if (p == NULL) ereport(ERROR, (errmsg("ParameterDescription. connection error"), @@ -2404,7 +2404,7 @@ ParameterDescription(POOL_CONNECTION * frontend, for (i = 0; i < NUM_BACKENDS; i++) { - if (VALID_BACKEND(i) && !IS_MASTER_NODE_ID(i)) + if (VALID_BACKEND(i) && !IS_MAIN_NODE_ID(i)) { pool_read(CONNECTION(backend, i), &len, sizeof(len)); @@ -2420,7 +2420,7 @@ ParameterDescription(POOL_CONNECTION * frontend, if (len != len1) ereport(DEBUG1, (errmsg("ParameterDescription. backends does not match"), - errdetail("length does not match between backends master(%d) %d th backend(%d) kind:(%c)", len, i, len1, kind))); + errdetail("length does not match between backends main(%d) %d th backend(%d) kind:(%c)", len, i, len1, kind))); } } @@ -2955,7 +2955,7 @@ ProcessBackendResponse(POOL_CONNECTION * frontend, status = ErrorResponse3(frontend, backend); pool_unset_command_success(); if (TSTATE(backend, NATIVE_REPLICATION ? PRIMARY_NODE_ID : - REAL_MASTER_NODE_ID) != 'I') + REAL_MAIN_NODE_ID) != 'I') { pool_set_failed_transaction(); @@ -3043,7 +3043,7 @@ ProcessBackendResponse(POOL_CONNECTION * frontend, case 'E': /* ErrorResponse */ status = ErrorResponse(frontend, backend); if (TSTATE(backend, NATIVE_REPLICATION ? PRIMARY_NODE_ID : - REAL_MASTER_NODE_ID) != 'I') + REAL_MAIN_NODE_ID) != 'I') pool_set_failed_transaction(); break; @@ -3311,7 +3311,7 @@ raise_intentional_error_if_need(POOL_CONNECTION_POOL * backend) if (NATIVE_REPLICATION && TSTATE(backend, PRIMARY_NODE_ID) == 'T' && - PRIMARY_NODE_ID != MASTER_NODE_ID && + PRIMARY_NODE_ID != MAIN_NODE_ID && query_context && is_select_query(query_context->parse_tree, query_context->original_query)) { @@ -3330,7 +3330,7 @@ raise_intentional_error_if_need(POOL_CONNECTION_POOL * backend) } if (REPLICATION && - TSTATE(backend, REAL_MASTER_NODE_ID) == 'T' && + TSTATE(backend, REAL_MAIN_NODE_ID) == 'T' && !pool_config->replicate_select && query_context && is_select_query(query_context->parse_tree, query_context->original_query)) @@ -3383,7 +3383,7 @@ check_errors(POOL_CONNECTION_POOL * backend, int backend_id) { /* - * Check dead lock error on the master node and abort transactions on all + * Check dead lock error on the main node and abort transactions on all * nodes if so. */ if (detect_deadlock_error(CONNECTION(backend, backend_id), MAJOR(backend)) == SPECIFIED_ERROR) @@ -3393,7 +3393,7 @@ check_errors(POOL_CONNECTION_POOL * backend, int backend_id) * Check serialization failure error and abort * transactions on all nodes if so. Otherwise we allow * data inconsistency among DB nodes. See following - * scenario: (M:master, S:slave) + * scenario: (M:main, S:replica) * * M:S1:BEGIN; * M:S2:BEGIN; @@ -3421,7 +3421,7 @@ check_errors(POOL_CONNECTION_POOL * backend, int backend_id) * * M:S1:BEGIN; * S:S1:BEGIN; - * M:S1:SELECT 1; <-- only sent to MASTER + * M:S1:SELECT 1; <-- only sent to MAIN * M:S1:SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; * S:S1:SET TRANSACTION ISOLATION LEVEL SERIALIZABLE; * M: <-- error @@ -3449,10 +3449,10 @@ generate_error_message(char *prefix, int specific_error, char *query) return; static char *error_messages[] = { - "received deadlock error message from master node. query: %s", - "received serialization failure error message from master node. query: %s", + "received deadlock error message from main node. query: %s", + "received serialization failure error message from main node. query: %s", "received SET TRANSACTION ISOLATION LEVEL must be called before any query error. query: %s", - "received query cancel error message from master node. query: %s" + "received query cancel error message from main node. query: %s" }; String *msg; @@ -3515,8 +3515,8 @@ per_node_error_log(POOL_CONNECTION_POOL * backend, int node_id, char *query, cha } /* - * Send parse message to primary/master node and wait for reply if particular - * message is not yet parsed on the primary/master node but parsed on other + * Send parse message to primary/main node and wait for reply if particular + * message is not yet parsed on the primary/main node but parsed on other * node. Caller must provide the parse message data as "message". */ static POOL_STATUS parse_before_bind(POOL_CONNECTION * frontend, @@ -3630,7 +3630,7 @@ static POOL_STATUS parse_before_bind(POOL_CONNECTION * frontend, } else { - /* expect to send to master node only */ + /* expect to send to main node only */ for (i = 0; i < NUM_BACKENDS; i++) { if (qc->where_to_send[i] && statecmp(qc->query_state[i], POOL_PARSE_COMPLETE) < 0) @@ -3688,18 +3688,18 @@ static POOL_STATUS parse_before_bind(POOL_CONNECTION * frontend, * Arguments: * ntuples: Array of number of affected tuples. -1 represents down node. * nmembers: Number of elements in ntuples. - * master_node: The master node id. Less than 0 means ignore this parameter. + * main_node: The main node id. Less than 0 means ignore this parameter. * number_of_nodes: Number of elements in victim nodes array. * - * Note: If no one wins and master_node >= 0, winner would be the - * master and other nodes who has same number of tuples as the master. + * Note: If no one wins and main_node >= 0, winner would be the + * main and other nodes who has same number of tuples as the main. * * Caution: Returned victim node array is allocated in static memory * of this function. Subsequent calls to this function will overwrite * the memory. */ static int * -find_victim_nodes(int *ntuples, int nmembers, int master_node, int *number_of_nodes) +find_victim_nodes(int *ntuples, int nmembers, int main_node, int *number_of_nodes) { static int victim_nodes[MAX_NUM_BACKENDS]; static int votes[MAX_NUM_BACKENDS]; @@ -3748,15 +3748,15 @@ find_victim_nodes(int *ntuples, int nmembers, int master_node, int *number_of_no /* Everyone is different */ if (maxvotes == 1) { - /* master node is specified? */ - if (master_node < 0) + /* Main node is specified? */ + if (main_node < 0) return NULL; /* - * If master node is specified, let it and others who has same ntuples + * If main node is specified, let it and others who has same ntuples * win. */ - majority_ntuples = ntuples[master_node]; + majority_ntuples = ntuples[main_node]; } else { @@ -3774,15 +3774,15 @@ find_victim_nodes(int *ntuples, int nmembers, int master_node, int *number_of_no { /* No one wins */ - /* Master node is specified? */ - if (master_node < 0) + /* Main node is specified? */ + if (main_node < 0) return NULL; /* - * If master node is specified, let it and others who has same + * If main node is specified, let it and others who has same * ntuples win. */ - majority_ntuples = ntuples[master_node]; + majority_ntuples = ntuples[main_node]; } } @@ -4127,7 +4127,7 @@ pool_at_command_success(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backe * transaction or disable_load_balance_on_write is 'ALWAYS', remember * that we had a write query in this transaction. */ - if (TSTATE(backend, NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MASTER_NODE_ID) == 'T' || + if (TSTATE(backend, NATIVE_REPLICATION ? PRIMARY_NODE_ID : REAL_MAIN_NODE_ID) == 'T' || pool_config->disable_load_balance_on_write == DLBOW_ALWAYS) { /* @@ -4168,17 +4168,17 @@ pool_read_message_length(POOL_CONNECTION_POOL * cp) length0; int i; - /* read message from master node */ - pool_read(CONNECTION(cp, MASTER_NODE_ID), &length0, sizeof(length0)); + /* read message from main node */ + pool_read(CONNECTION(cp, MAIN_NODE_ID), &length0, sizeof(length0)); length0 = ntohl(length0); ereport(DEBUG5, (errmsg("reading message length"), - errdetail("slot: %d length: %d", MASTER_NODE_ID, length0))); + errdetail("slot: %d length: %d", MAIN_NODE_ID, length0))); for (i = 0; i < NUM_BACKENDS; i++) { - if (!VALID_BACKEND(i) || IS_MASTER_NODE_ID(i)) + if (!VALID_BACKEND(i) || IS_MAIN_NODE_ID(i)) { continue; } @@ -4221,25 +4221,25 @@ pool_read_message_length2(POOL_CONNECTION_POOL * cp) int i; static int length_array[MAX_CONNECTION_SLOTS]; - /* read message from master node */ - pool_read(CONNECTION(cp, MASTER_NODE_ID), &length0, sizeof(length0)); + /* read message from main node */ + pool_read(CONNECTION(cp, MAIN_NODE_ID), &length0, sizeof(length0)); length0 = ntohl(length0); - length_array[MASTER_NODE_ID] = length0; + length_array[MAIN_NODE_ID] = length0; ereport(DEBUG5, (errmsg("reading message length"), - errdetail("master slot: %d length: %d", MASTER_NODE_ID, length0))); + errdetail("main slot: %d length: %d", MAIN_NODE_ID, length0))); for (i = 0; i < NUM_BACKENDS; i++) { - if (VALID_BACKEND(i) && !IS_MASTER_NODE_ID(i)) + if (VALID_BACKEND(i) && !IS_MAIN_NODE_ID(i)) { pool_read(CONNECTION(cp, i), &length, sizeof(length)); length = ntohl(length); ereport(DEBUG5, (errmsg("reading message length"), - errdetail("master slot: %d length: %d", i, length))); + errdetail("main slot: %d length: %d", i, length))); if (length != length0) { @@ -4281,7 +4281,7 @@ pool_read_kind(POOL_CONNECTION_POOL * cp) pool_read(CONNECTION(cp, i), &kind, sizeof(kind)); - if (IS_MASTER_NODE_ID(i)) + if (IS_MAIN_NODE_ID(i)) { kind0 = kind; } @@ -4293,10 +4293,10 @@ pool_read_kind(POOL_CONNECTION_POOL * cp) if (kind0 == 'E') { - if (pool_extract_error_message(false, MASTER(cp), MAJOR(cp), true, &message) == 1) + if (pool_extract_error_message(false, MAIN(cp), MAJOR(cp), true, &message) == 1) { ereport(LOG, - (errmsg("pool_read_kind: error message from master backend:%s", message))); + (errmsg("pool_read_kind: error message from main backend:%s", message))); pfree(message); } } @@ -4311,7 +4311,7 @@ pool_read_kind(POOL_CONNECTION_POOL * cp) } ereport(ERROR, (errmsg("unable to read message kind"), - errdetail("kind does not match between master(%x) slot[%d] (%x)", kind0, i, kind))); + errdetail("kind does not match between main(%x) slot[%d] (%x)", kind0, i, kind))); } } } @@ -4336,7 +4336,7 @@ pool_read_int(POOL_CONNECTION_POOL * cp) continue; } pool_read(CONNECTION(cp, i), &data, sizeof(data)); - if (IS_MASTER_NODE_ID(i)) + if (IS_MAIN_NODE_ID(i)) { data0 = data; } @@ -4346,7 +4346,7 @@ pool_read_int(POOL_CONNECTION_POOL * cp) { ereport(ERROR, (errmsg("unable to read int value"), - errdetail("data does not match between between master(%x) slot[%d] (%x)", data0, i, data))); + errdetail("data does not match between between main(%x) slot[%d] (%x)", data0, i, data))); } } @@ -4376,7 +4376,7 @@ si_get_snapshot(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend, Node * deadlock. */ if (pool_config->backend_clustering_mode == CM_SNAPSHOT_ISOLATION && - TSTATE(backend, MASTER_NODE_ID) == 'T' && + TSTATE(backend, MAIN_NODE_ID) == 'T' && si_snapshot_aquire_command(node) && !si_snapshot_prepared() && frontend && frontend->no_forward == 0) diff --git a/src/query_cache/pool_memqcache.c b/src/query_cache/pool_memqcache.c index 5d5a0c3..b96077b 100644 --- a/src/query_cache/pool_memqcache.c +++ b/src/query_cache/pool_memqcache.c @@ -801,7 +801,7 @@ pool_fetch_from_memory_cache(POOL_CONNECTION * frontend, /* * We keep previous transaction state. */ - state = MASTER(backend)->tstate; + state = MAIN(backend)->tstate; send_message(frontend, 'Z', 5, (char *) &state); } @@ -1523,7 +1523,7 @@ pool_get_database_oid(void) * Search relcache. */ oid = (int) (intptr_t) pool_search_relcache(relcache, backend, - MASTER_CONNECTION(backend)->sp->database); + MAIN_CONNECTION(backend)->sp->database); return oid; } @@ -1543,7 +1543,7 @@ pool_get_database_oid_from_dbname(char *dbname) backend = pool_get_session_context(false)->backend; snprintf(query, sizeof(query), DATABASE_TO_OID_QUERY, dbname); - do_query(MASTER(backend), query, &res, MAJOR(backend)); + do_query(MAIN(backend), query, &res, MAJOR(backend)); if (res->numrows != 1) { diff --git a/src/rewrite/pool_lobj.c b/src/rewrite/pool_lobj.c index 01e50a8..38187fe 100644 --- a/src/rewrite/pool_lobj.c +++ b/src/rewrite/pool_lobj.c @@ -172,9 +172,9 @@ pool_rewrite_lo_creat(char kind, char *packet, int packet_len, */ /* issue lock table command to lob_lock_table */ snprintf(qbuf, sizeof(qbuf), "LOCK TABLE %s IN SHARE ROW EXCLUSIVE MODE", pool_config->lobj_lock_table); - per_node_statement_log(backend, MASTER_NODE_ID, qbuf); - status = do_command(frontend, MASTER(backend), qbuf, MAJOR(backend), MASTER_CONNECTION(backend)->pid, - MASTER_CONNECTION(backend)->key, 0); + per_node_statement_log(backend, MAIN_NODE_ID, qbuf); + status = do_command(frontend, MAIN(backend), qbuf, MAJOR(backend), MAIN_CONNECTION(backend)->pid, + MAIN_CONNECTION(backend)->key, 0); if (status == POOL_END) { ereport(WARNING, @@ -185,7 +185,7 @@ pool_rewrite_lo_creat(char kind, char *packet, int packet_len, /* * If transaction state is E, do_command failed to execute command */ - if (TSTATE(backend, MASTER_NODE_ID) == 'E') + if (TSTATE(backend, MAIN_NODE_ID) == 'E') { ereport(LOG, (errmsg("failed while rewriting LO CREATE"), @@ -194,8 +194,8 @@ pool_rewrite_lo_creat(char kind, char *packet, int packet_len, } /* get max lobj id */ - per_node_statement_log(backend, MASTER_NODE_ID, GET_MAX_LOBJ_KEY); - do_query(MASTER(backend), GET_MAX_LOBJ_KEY, &result, MAJOR(backend)); + per_node_statement_log(backend, MAIN_NODE_ID, GET_MAX_LOBJ_KEY); + do_query(MAIN(backend), GET_MAX_LOBJ_KEY, &result, MAJOR(backend)); if (!result) { diff --git a/src/rewrite/pool_timestamp.c b/src/rewrite/pool_timestamp.c index 58ef5f6..f218c42 100644 --- a/src/rewrite/pool_timestamp.c +++ b/src/rewrite/pool_timestamp.c @@ -478,7 +478,7 @@ rewrite_timestamp_walker(Node *node, void *context) /* - * Get `now()' from MASTER node + * Get `now()' from MAIN node */ static char * get_current_timestamp(POOL_CONNECTION_POOL * backend) @@ -486,7 +486,7 @@ get_current_timestamp(POOL_CONNECTION_POOL * backend) POOL_SELECT_RESULT *res; static char timestamp[64]; - do_query(MASTER(backend), "SELECT now()", &res, MAJOR(backend)); + do_query(MAIN(backend), "SELECT now()", &res, MAJOR(backend)); if (res->numrows != 1) { @@ -1227,7 +1227,7 @@ makeStringConstFromQuery(POOL_CONNECTION_POOL * backend, char *expression) char *str; snprintf(query, sizeof(query), "SELECT %s", expression); - do_query(MASTER(backend), query, &res, MAJOR(backend)); + do_query(MAIN(backend), query, &res, MAJOR(backend)); if (res->numrows != 1) { diff --git a/src/test/regression/libs.sh b/src/test/regression/libs.sh index f0e5939..40fdbee 100644 --- a/src/test/regression/libs.sh +++ b/src/test/regression/libs.sh @@ -16,7 +16,7 @@ function wait_for_pgpool_startup { } #------------------------------------------- -# wait for primary/master failover done +# wait for primary/main failover done #------------------------------------------- function wait_for_failover_done { timeout=20 @@ -25,7 +25,7 @@ function wait_for_failover_done { do $PGBIN/psql -p $PGPOOL_PORT -c "show pool_nodes" test >/dev/null 2>&1 if [ $? = 0 ];then - $PGBIN/psql -p $PGPOOL_PORT -c "show pool_nodes" test |egrep -i "primary|master">/dev/null 2>&1 + $PGBIN/psql -p $PGPOOL_PORT -c "show pool_nodes" test |egrep -i "primary|main">/dev/null 2>&1 if [ $? = 0 ];then break; fi diff --git a/src/test/regression/tests/003.failover/create_expected.sql b/src/test/regression/tests/003.failover/create_expected.sql index f175356..ea39f39 100644 --- a/src/test/regression/tests/003.failover/create_expected.sql +++ b/src/test/regression/tests/003.failover/create_expected.sql @@ -16,8 +16,8 @@ CREATE TEMP TABLE tmp ( INSERT INTO tmp VALUES ('0',:dir,'11002','up','0.500000','primary','0','false','0','','','XXXX-XX-XX XX:XX:XX','s'), ('1',:dir,'11003','down','0.500000','standby','0','false','0','','','XXXX-XX-XX XX:XX:XX','s'), -('0',:dir,'11002','up','0.500000','master','0','false','0','','','XXXX-XX-XX XX:XX:XX','r'), -('1',:dir,'11003','down','0.500000','slave','0','false','0','','','XXXX-XX-XX XX:XX:XX','r'); +('0',:dir,'11002','up','0.500000','main','0','false','0','','','XXXX-XX-XX XX:XX:XX','r'), +('1',:dir,'11003','down','0.500000','replica','0','false','0','','','XXXX-XX-XX XX:XX:XX','r'); SELECT node_id,hostname,port,status,lb_weight,role,select_cnt,load_balance_node,replication_delay,replication_state, replication_sync_state, last_status_change FROM tmp diff --git a/src/test/regression/tests/003.failover/create_expected_node0.sql b/src/test/regression/tests/003.failover/create_expected_node0.sql index 0a7af89..5a12e57 100644 --- a/src/test/regression/tests/003.failover/create_expected_node0.sql +++ b/src/test/regression/tests/003.failover/create_expected_node0.sql @@ -16,8 +16,8 @@ CREATE TEMP TABLE tmp ( INSERT INTO tmp VALUES ('0',:dir,'11002','down','0.500000','standby','0','false','0','','','XXXX-XX-XX XX:XX:XX','s'), ('1',:dir,'11003','up','0.500000','primary','0','false','0','','','XXXX-XX-XX XX:XX:XX','s'), -('0',:dir,'11002','down','0.500000','slave','0','false','0','','','XXXX-XX-XX XX:XX:XX','r'), -('1',:dir,'11003','up','0.500000','master','0','false','0','','','XXXX-XX-XX XX:XX:XX','r'); +('0',:dir,'11002','down','0.500000','replica','0','false','0','','','XXXX-XX-XX XX:XX:XX','r'), +('1',:dir,'11003','up','0.500000','main','0','false','0','','','XXXX-XX-XX XX:XX:XX','r'); SELECT node_id,hostname,port,status,lb_weight,role,select_cnt,load_balance_node,replication_delay,replication_state, replication_sync_state, last_status_change FROM tmp diff --git a/src/test/regression/tests/010.rewrite_timestamp/timestamp/main.c b/src/test/regression/tests/010.rewrite_timestamp/timestamp/main.c index 4c8d4e4..751f18f 100644 --- a/src/test/regression/tests/010.rewrite_timestamp/timestamp/main.c +++ b/src/test/regression/tests/010.rewrite_timestamp/timestamp/main.c @@ -10,7 +10,7 @@ #include "rewrite/pool_timestamp.h" #include "parser/parser.h" -/* for get_current_timestamp() (MASTER() macro) */ +/* for get_current_timestamp() (MAIN() macro) */ POOL_REQUEST_INFO _req_info; POOL_REQUEST_INFO *Req_info = &_req_info; diff --git a/src/test/regression/tests/016.node_0_is_not_primary/test.sh b/src/test/regression/tests/016.node_0_is_not_primary/test.sh index 6778416..5c365e4 100755 --- a/src/test/regression/tests/016.node_0_is_not_primary/test.sh +++ b/src/test/regression/tests/016.node_0_is_not_primary/test.sh @@ -37,12 +37,12 @@ do echo "Swapping the role of node 0 and node 1...done." $PSQL -c "show pool_nodes" - # make sure that node 1 is master/primary - test `$PSQL -c "show pool_nodes"|egrep "primary|master"|awk '{print $1}'` = 1 && - test `$PSQL -c "show pool_nodes"|egrep "primary|master"|awk '{print $7}'` = "up" + # make sure that node 1 is main/primary + test `$PSQL -c "show pool_nodes"|egrep "primary|main"|awk '{print $1}'` = 1 && + test `$PSQL -c "show pool_nodes"|egrep "primary|main"|awk '{print $7}'` = "up" if [ $? != 0 ] then - echo "node 1 is not primary or master" + echo "node 1 is not primary or main" ./shutdownall exit 1 fi diff --git a/src/tools/pcp/pcp_frontend_client.c b/src/tools/pcp/pcp_frontend_client.c index a992026..3f1957f 100644 --- a/src/tools/pcp/pcp_frontend_client.c +++ b/src/tools/pcp/pcp_frontend_client.c @@ -960,9 +960,9 @@ backend_status_to_string(BackendInfo * bi) char * role_to_str(SERVER_ROLE role) { - static char *role_str[] = {"master", "slave", "primary", "standby"}; + static char *role_str[] = {"main", "replica", "primary", "standby"}; - if (role < ROLE_MASTER || role > ROLE_STANDBY) + if (role < ROLE_MAIN || role > ROLE_STANDBY) return "unknown"; return role_str[role]; } diff --git a/src/utils/pool_process_reporting.c b/src/utils/pool_process_reporting.c index 5225a23..2620ae8 100644 --- a/src/utils/pool_process_reporting.c +++ b/src/utils/pool_process_reporting.c @@ -1941,10 +1941,10 @@ get_health_check_stats(int *nrows) } else { - if (i == REAL_MASTER_NODE_ID) - snprintf(stats[i].role, POOLCONFIG_MAXWEIGHTLEN, "%s", "master"); + if (i == REAL_MAIN_NODE_ID) + snprintf(stats[i].role, POOLCONFIG_MAXWEIGHTLEN, "%s", "main"); else - snprintf(stats[i].role, POOLCONFIG_MAXWEIGHTLEN, "%s", "slave"); + snprintf(stats[i].role, POOLCONFIG_MAXWEIGHTLEN, "%s", "replica"); } /* status last changed */ @@ -2155,10 +2155,10 @@ get_backend_stats(int *nrows) } else { - if (i == REAL_MASTER_NODE_ID) - snprintf(backend_stats[i].role, POOLCONFIG_MAXWEIGHTLEN, "%s", "master"); + if (i == REAL_MAIN_NODE_ID) + snprintf(backend_stats[i].role, POOLCONFIG_MAXWEIGHTLEN, "%s", "main"); else - snprintf(backend_stats[i].role, POOLCONFIG_MAXWEIGHTLEN, "%s", "slave"); + snprintf(backend_stats[i].role, POOLCONFIG_MAXWEIGHTLEN, "%s", "replica"); } } diff --git a/src/utils/pool_relcache.c b/src/utils/pool_relcache.c index abf5ed7..fc2e357 100644 --- a/src/utils/pool_relcache.c +++ b/src/utils/pool_relcache.c @@ -152,7 +152,7 @@ pool_search_relcache(POOL_RELCACHE * relcache, POOL_CONNECTION_POOL * backend, c } else { - dbname = MASTER_CONNECTION(backend)->sp->database; + dbname = MAIN_CONNECTION(backend)->sp->database; /* * If in streaming replication mode, prefer to send query to the @@ -161,7 +161,7 @@ pool_search_relcache(POOL_RELCACHE * relcache, POOL_CONNECTION_POOL * backend, c if (STREAM && PRIMARY_NODE_ID >= 0) node_id = PRIMARY_NODE_ID; else - node_id = MASTER_NODE_ID; + node_id = MAIN_NODE_ID; } now = time(NULL); diff --git a/src/utils/pool_select_walker.c b/src/utils/pool_select_walker.c index 9b27738..e61a0a9 100644 --- a/src/utils/pool_select_walker.c +++ b/src/utils/pool_select_walker.c @@ -916,7 +916,7 @@ pool_has_pgpool_regclass(void) char *user; backend = pool_get_session_context(false)->backend; - user = MASTER_CONNECTION(backend)->sp->user; + user = MAIN_CONNECTION(backend)->sp->user; if (!relcache) { diff --git a/src/utils/pool_stream.c b/src/utils/pool_stream.c index d957796..9f6fcb7 100644 --- a/src/utils/pool_stream.c +++ b/src/utils/pool_stream.c @@ -172,7 +172,7 @@ pool_read(POOL_CONNECTION * cp, void *buf, int len) */ if (pool_get_timeout() >= 0 && pool_check_fd(cp)) { - if (!IS_MASTER_NODE_ID(cp->db_node_id) && (getpid() != mypid)) + if (!IS_MAIN_NODE_ID(cp->db_node_id) && (getpid() != mypid)) { ereport(FATAL, (errmsg("unable to read data from DB node %d", cp->db_node_id), @@ -340,7 +340,7 @@ pool_read2(POOL_CONNECTION * cp, int len) */ if (pool_get_timeout() >= 0 && pool_check_fd(cp)) { - if (!IS_MASTER_NODE_ID(cp->db_node_id)) + if (!IS_MAIN_NODE_ID(cp->db_node_id)) { ereport(FATAL, (errmsg("unable to read data from DB node %d", cp->db_node_id), @@ -944,7 +944,7 @@ pool_read_string(POOL_CONNECTION * cp, int *len, int line) { if (pool_check_fd(cp)) { - if (!IS_MASTER_NODE_ID(cp->db_node_id)) + if (!IS_MAIN_NODE_ID(cp->db_node_id)) { ereport(FATAL, (errmsg("unable to read data from DB node %d", cp->db_node_id), diff --git a/src/utils/ps_status.c b/src/utils/ps_status.c index 1e12ec1..6d7d9ee 100644 --- a/src/utils/ps_status.c +++ b/src/utils/ps_status.c @@ -397,8 +397,8 @@ pool_ps_idle_display(POOL_CONNECTION_POOL * backend) StartupPacket *sp; char psbuf[1024]; - sp = MASTER_CONNECTION(backend)->sp; - if (MASTER(backend)->tstate == 'T') + sp = MAIN_CONNECTION(backend)->sp; + if (MAIN(backend)->tstate == 'T') snprintf(psbuf, sizeof(psbuf), "%s %s %s idle in transaction", sp->user, sp->database, remote_ps_data); else