pgpool-II的conn_info 指针的结构
main.c 中,有如下说明:
/* * shmem connection info table * this is a three dimension array. i.e.: * con_info[pool_config->num_init_children][pool_config->max_pool][MAX_NUM_BACKENDS] */ ConnectionInfo *con_info;
从 pool_process_context 的代码中也可以看到这一点:
/* * Return pointer to i th child, j th connection pool and k th backend * of connection info on shmem. */ ConnectionInfo *pool_coninfo(int child, int connection_pool, int backend){ pool_log("Gao001…..child in pool_coninfo is: %d", child); if (child < 0 || child >= pool_config->num_init_children){ pool_error("pool_coninfo: invalid child number: %d", child); return NULL; } if (connection_pool < 0 || connection_pool >= pool_config->max_pool){ pool_error("pool_coninfo: invalid connection_pool number: %d",
connection_pool); return NULL; } if (backend < 0 || backend >= MAX_NUM_BACKENDS){ pool_error("pool_coninfo: invalid backend number: %d", backend); return NULL; } return &con_info [ child*pool_config->max_pool*MAX_NUM_BACKENDS+ connection_pool*MAX_NUM_BACKENDS+ backend]; }
我们可以把con_info的pool想象成这个样子:
child--0 connection--pool--0 backend--0 backend--1 connection--pool--1 backend--0 backend--1 connection--pool--2 backend--0 backend--1 connection--pool--3 backend--0 backend--1 child--1 connection--pool--0 backend--0 backend--1 connection--pool--1 backend--0 backend--1 connection--pool--2 backend--0 backend--1 connection--pool--3 backend--0 backend--1 …… child--127 connection--pool--0 backend--0 backend--1 connection--pool--1 backend--0 backend--1 connection--pool--2 backend--0 backend--1 connection--pool--3 backend--0 backend--1
从这个意义上说,pgpool-II并不是一个真正的connection pool,它只是一个child 对应几个连接(比如4个),各个child之间是不会混用某个 connection 的。