The new field is "1" if pgpool process is connected by a client and
the session uses the backend id as a load balance node. Users can
execute the commands to find out if there's any session that uses the
backend as the load balance node. If so, shutting down the backend may
cause session disconnection.
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2023-July/004353.html
Note: I accidentally pushed only doc part of the commit in
4658f84870e8edfd39920f273bab1a12d71d8986.
This is a follow-up commit for actual codes.
char pool_backendpid[POOLCONFIG_MAXCOUNTLEN + 1];
char pool_connected[POOLCONFIG_MAXCOUNTLEN + 1];
char status[POOLCONFIG_MAXPROCESSSTATUSLEN + 1];
+ char load_balance_node[POOLCONFIG_MAXPROCESSSTATUSLEN + 1];
} POOL_REPORT_POOLS;
/* version struct */
"Database", "Username", "Start time", "Client connection count",
"Major", "Minor", "Backend connection time", "Client connection time",
"Client idle duration", "Client disconnection time", "Pool Counter", "Backend PID",
- "Connected", "PID", "Backend ID", "Status"
+ "Connected", "PID", "Backend ID", "Status", "Load balance node"
};
const char *types[] = {
"s", "s", "s", "s",
"s", "s", "s", "s",
"s", "s", "s", "s",
- "s", "s", "s", "s"
+ "s", "s", "s", "s",
+ "s"
};
format = format_titles(titles, types, sizeof(titles)/sizeof(char *));
else
{
- format = "%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s\n";
+ format = "%s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s %s\n";
}
for (i = 0; i < array_size; i++)
pools->pool_connected,
pools->pool_pid,
pools->backend_id,
- pools->status);
+ pools->status,
+ pools->load_balance_node);
}
if (printed == false)
printf("No process information available\n\n");
offsetof(POOL_REPORT_POOLS, pool_counter),
offsetof(POOL_REPORT_POOLS, pool_backendpid),
offsetof(POOL_REPORT_POOLS, pool_connected),
- offsetof(POOL_REPORT_POOLS, status)
+ offsetof(POOL_REPORT_POOLS, status),
+ offsetof(POOL_REPORT_POOLS, load_balance_node)
};
*n = sizeof(offsettbl)/sizeof(int);
for (pool = 0; pool < pool_config->max_pool; pool++)
{
int idle_duration = pi->connection_info[pool * MAX_NUM_BACKENDS].client_idle_duration;
+ int load_balancing_node_id = pi->connection_info[pool * MAX_NUM_BACKENDS].load_balancing_node;
int cliet_idle_time = pool_config->client_idle_limit;
if (pool_config->client_idle_limit > 0)
*(pools[lines].status) = '\0';
}
+ if (pi->connection_info[poolBE].connected && backend_id == load_balancing_node_id)
+ StrNCpy(pools[lines].load_balance_node, "1", POOLCONFIG_MAXPROCESSSTATUSLEN);
+ else
+ StrNCpy(pools[lines].load_balance_node, "0", POOLCONFIG_MAXPROCESSSTATUSLEN);
lines++;
}
}
static char *field_names[] = {"pool_pid", "start_time", "client_connection_count", "pool_id",
"backend_id", "database", "username", "backend_connection_time",
"client_connection_time", "client_disconnection_time", "client_idle_duration",
- "majorversion", "minorversion", "pool_counter", "pool_backendpid", "pool_connected", "status"};
+ "majorversion", "minorversion", "pool_counter", "pool_backendpid", "pool_connected",
+ "status", "load_balance_node"};
int n;
int *offsettbl;
int nrows;