Skip to content

Commit d1ff951

Browse files
Merge pull request #243 from jembi/TB-124-add-pgpool-connection-manager
TB-124 Add pgpool connection manager
2 parents c6a9110 + 2f7b2c1 commit d1ff951

File tree

14 files changed

+203
-24
lines changed

14 files changed

+203
-24
lines changed

.env.cluster

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ OPENHIM_MONGO_ATNAURL=mongodb://mongo-1:27017,mongo-2:27017,mongo-3:27017/openhi
2121
HAPI_FHIR_INSTANCES=3
2222
REPMGR_PARTNER_NODES=postgres-1,postgres-2,postgres-3
2323
POSTGRES_REPLICA_SET=postgres-1:5432,postgres-2:5432,postgres-3:5432
24+
HAPI_DB_SET=pgpool-1:5432,pgpool-2:5432,pgpool-3:5432
2425

2526
# Sante Datastore - Sante MPI
26-
REPMGR_PARTNER_NODES=santempi-psql-1,santempi-psql-2,santempi-psql-3
27+
SANTEMPI_REPMGR_PARTNER_NODES=santempi-psql-1,santempi-psql-2,santempi-psql-3
2728

2829
# Reverse Proxy - Nginx
2930
REVERSE_PROXY_INSTANCES=3

.env.remote

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ OPENHIM_TRANSACTION_API_PORT=<port>
77
OPENHIM_MEDIATOR_API_PORT=<OPENHIM_MEDIATOR_API_PORT>
88
MOCK_SERVER_HOST=<mock_service_hostname>
99
MOCK_SERVER_PORT=<port>
10-
POSTGRES_REPLICA_SET=postgres-1:5432,postgres-2:5432,postgres-3:5432
1110

1211
# Analytics Datastore - Elastic Search
1312
ES_HOSTS="\"analytics-datastore-elastic-search-01:9200","analytics-datastore-elastic-search-02:9200","analytics-datastore-elastic-search-03:9200\""
@@ -18,6 +17,7 @@ CLICKHOUSE_HOST=analytics-datastore-clickhouse-01
1817
# FHIR Datastore - HAPI FHIR
1918
REPMGR_PARTNER_NODES=postgres-1,postgres-2,postgres-3
2019
POSTGRES_REPLICA_SET=postgres-1:5432,postgres-2:5432,postgres-3:5432
20+
HAPI_DB_SET=postgres-1:5432,postgres-2:5432,postgres-3:5432
2121

2222
# Interoperability Layer - OpenHIM
2323
MONGO_SET_COUNT=3

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ jobs:
9595
- run: sed -i 's/OPENHIM_MEDIATOR_API_PORT=8080/OPENHIM_MEDIATOR_API_PORT=443/g' .env.local
9696
- run: sed -i 's/INSECURE=true/INSECURE=false/g' .env.local
9797
- run: sed -i 's/domain/${{ github.run_id }}.jembi.cloud/g' .env.local
98-
9998
- name: Install dependencies
10099
working-directory: ./test/cucumber
101100
run: yarn

analytics-datastore-elastic-search/swarm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ function create_certs() {
7878

7979
function add_docker_configs() {
8080
local -r TIMESTAMP="$(date "+%Y%m%d%H%M%S")"
81-
local -r path_config_certs="/usr/share/elasticsearch/config/certs/"
81+
local -r path_config_certs="/usr/share/elasticsearch/config/certs"
8282

8383
log info "Creating configs..."
8484

config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
projectName: platform
2-
image: jembi/platform:2.3.3
2+
image: jembi/platform:2.4.0
33
logPath: /tmp/logs
44

55
packages:
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
failover_on_backend_error='on'
2+
detach_false_primary='on'
3+
auto_failback='on'
4+
health_check_period=25
5+
health_check_max_retries=3
6+
health_check_user='postgres'
7+
reserved_connections=1
8+
max_pool=6
9+
client_idle_limit=300
10+
connection_life_time=300
11+
child_max_connections=25
12+
13+
use_watchdog='on'
14+
hostname0='pgpool-1'
15+
wd_port0=9000
16+
pgpool_port0=9999
17+
hostname1='pgpool-2'
18+
wd_port1=9000
19+
pgpool_port1=9999
20+
hostname2='pgpool-3'
21+
wd_port2=9000
22+
pgpool_port2=9999
23+
heartbeat_hostname0='pgpool-1'
24+
heartbeat_port0=9694
25+
heartbeat_hostname1='pgpool-2'
26+
heartbeat_port1=9694
27+
heartbeat_hostname2='pgpool-3'
28+
heartbeat_port2=9694
29+
trusted_servers='pgpool-1,pgpool-2,pgpool-3'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
2

fhir-datastore-hapi-fhir/docker-compose-postgres.cluster.yml

Lines changed: 127 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ services:
2121
REPMGR_NODE_NAME: postgres-2
2222
REPMGR_PRIMARY_HOST: ${REPMGR_PRIMARY_HOST}
2323
REPMGR_PARTNER_NODES: ${REPMGR_PARTNER_NODES}
24+
POSTGRESQL_POSTGRES_PASSWORD: ${HAPI_POSTGRES_PASSWORD}
2425
volumes:
2526
- 'hapi-postgres-2-data:/bitnami/postgresql'
2627
deploy:
@@ -37,9 +38,7 @@ services:
3738
memory: ${HF_POSTGRES_MEMORY_RESERVE}
3839
networks:
3940
default:
40-
hapi-fhir-postgres:
41-
pg_backup_net: {}
42-
41+
pg_backup_net:
4342

4443
postgres-3:
4544
image: bitnami/postgresql-repmgr:14
@@ -53,6 +52,7 @@ services:
5352
REPMGR_NODE_NAME: postgres-3
5453
REPMGR_PRIMARY_HOST: ${REPMGR_PRIMARY_HOST}
5554
REPMGR_PARTNER_NODES: ${REPMGR_PARTNER_NODES}
55+
POSTGRESQL_POSTGRES_PASSWORD: ${HAPI_POSTGRES_PASSWORD}
5656
volumes:
5757
- 'hapi-postgres-3-data:/bitnami/postgresql'
5858
deploy:
@@ -69,9 +69,131 @@ services:
6969
memory: ${HF_POSTGRES_MEMORY_RESERVE}
7070
networks:
7171
default:
72-
hapi-fhir-postgres:
73-
pg_backup_net: {}
72+
pg_backup_net:
73+
74+
pgpool-1:
75+
image: bitnami/pgpool:4.4.3
76+
deploy:
77+
placement:
78+
max_replicas_per_node: 1
79+
resources:
80+
limits:
81+
cpus: ${HF_PGPOOL_CPU_LIMIT}
82+
memory: ${HF_PGPOOL_MEMORY_LIMIT}
83+
reservations:
84+
cpus: ${HF_PGPOOL_CPU_RESERVE}
85+
memory: ${HF_PGPOOL_MEMORY_RESERVE}
86+
configs:
87+
- target: /config/custom_pgpool.conf
88+
source: pgpool.conf
89+
- target: /opt/bitnami/pgpool/conf/pgpool_node_id
90+
source: pgpool_node_id0.conf
91+
environment:
92+
PGPOOL_BACKEND_NODES: ${HF_PGPOOL_NODES}
93+
PGPOOL_BACKEND_APPLICATION_NAMES: ${REPMGR_PARTNER_NODES}
94+
PGPOOL_SR_CHECK_USER: postgres
95+
PGPOOL_SR_CHECK_PASSWORD: ${HAPI_POSTGRES_PASSWORD}
96+
PGPOOL_POSTGRES_USERNAME: postgres
97+
PGPOOL_POSTGRES_PASSWORD: ${HAPI_POSTGRES_PASSWORD}
98+
PGPOOL_ADMIN_USERNAME: ${HF_PGPOOL_USERNAME}
99+
PGPOOL_ADMIN_PASSWORD: ${HF_PGPOOL_PASSWORD}
100+
PGPOOL_POSTGRES_CUSTOM_USERS: ${HF_POSTGRESQL_USERNAME}
101+
PGPOOL_POSTGRES_CUSTOM_PASSWORDS: ${HF_POSTGRESQL_PASSWORD}
102+
PGPOOL_ENABLE_LOAD_BALANCING: "no"
103+
PGPOOL_AUTO_FAILBACK: "yes"
104+
PGPOOL_USER_CONF_FILE: "/config/custom_pgpool.conf"
105+
networks:
106+
default:
107+
108+
pgpool-2:
109+
image: bitnami/pgpool:4.4.3
110+
deploy:
111+
placement:
112+
max_replicas_per_node: 1
113+
resources:
114+
limits:
115+
cpus: ${HF_PGPOOL_CPU_LIMIT}
116+
memory: ${HF_PGPOOL_MEMORY_LIMIT}
117+
reservations:
118+
cpus: ${HF_PGPOOL_CPU_RESERVE}
119+
memory: ${HF_PGPOOL_MEMORY_RESERVE}
120+
configs:
121+
- target: /config/custom_pgpool.conf
122+
source: pgpool.conf
123+
- target: /opt/bitnami/pgpool/conf/pgpool_node_id
124+
source: pgpool_node_id1.conf
125+
environment:
126+
PGPOOL_BACKEND_NODES: ${HF_PGPOOL_NODES}
127+
PGPOOL_BACKEND_APPLICATION_NAMES: ${REPMGR_PARTNER_NODES}
128+
PGPOOL_SR_CHECK_USER: postgres
129+
PGPOOL_SR_CHECK_PASSWORD: ${HAPI_POSTGRES_PASSWORD}
130+
PGPOOL_POSTGRES_USERNAME: postgres
131+
PGPOOL_POSTGRES_PASSWORD: ${HAPI_POSTGRES_PASSWORD}
132+
PGPOOL_ADMIN_USERNAME: ${HF_PGPOOL_USERNAME}
133+
PGPOOL_ADMIN_PASSWORD: ${HF_PGPOOL_PASSWORD}
134+
PGPOOL_POSTGRES_CUSTOM_USERS: ${HF_POSTGRESQL_USERNAME}
135+
PGPOOL_POSTGRES_CUSTOM_PASSWORDS: ${HF_POSTGRESQL_PASSWORD}
136+
PGPOOL_ENABLE_LOAD_BALANCING: "no"
137+
PGPOOL_AUTO_FAILBACK: "yes"
138+
PGPOOL_USER_CONF_FILE: "/config/custom_pgpool.conf"
139+
networks:
140+
default:
141+
142+
pgpool-3:
143+
image: bitnami/pgpool:4.4.3
144+
deploy:
145+
placement:
146+
max_replicas_per_node: 1
147+
resources:
148+
limits:
149+
cpus: ${HF_PGPOOL_CPU_LIMIT}
150+
memory: ${HF_PGPOOL_MEMORY_LIMIT}
151+
reservations:
152+
cpus: ${HF_PGPOOL_CPU_RESERVE}
153+
memory: ${HF_PGPOOL_MEMORY_RESERVE}
154+
configs:
155+
- target: /config/custom_pgpool.conf
156+
source: pgpool.conf
157+
- target: /opt/bitnami/pgpool/conf/pgpool_node_id
158+
source: pgpool_node_id2.conf
159+
environment:
160+
PGPOOL_BACKEND_NODES: ${HF_PGPOOL_NODES}
161+
PGPOOL_BACKEND_APPLICATION_NAMES: ${REPMGR_PARTNER_NODES}
162+
PGPOOL_SR_CHECK_USER: postgres
163+
PGPOOL_SR_CHECK_PASSWORD: ${HAPI_POSTGRES_PASSWORD}
164+
PGPOOL_POSTGRES_USERNAME: postgres
165+
PGPOOL_POSTGRES_PASSWORD: ${HAPI_POSTGRES_PASSWORD}
166+
PGPOOL_ADMIN_USERNAME: ${HF_PGPOOL_USERNAME}
167+
PGPOOL_ADMIN_PASSWORD: ${HF_PGPOOL_PASSWORD}
168+
PGPOOL_POSTGRES_CUSTOM_USERS: ${HF_POSTGRESQL_USERNAME}
169+
PGPOOL_POSTGRES_CUSTOM_PASSWORDS: ${HF_POSTGRESQL_PASSWORD}
170+
PGPOOL_ENABLE_LOAD_BALANCING: "no"
171+
PGPOOL_AUTO_FAILBACK: "yes"
172+
PGPOOL_USER_CONF_FILE: "/config/custom_pgpool.conf"
173+
networks:
174+
default:
74175

176+
configs:
177+
pgpool.conf:
178+
name: pgpool_conf-${pgpool_conf_DIGEST:?err}
179+
file: ./config/custom_pgpool.conf
180+
labels:
181+
name: hapi-fhir
182+
pgpool_node_id0.conf:
183+
name: pgpool_node_id0-${pgpool_node_id0_DIGEST:?err}
184+
file: ./config/pgpool_node_id0
185+
labels:
186+
name: hapi-fhir
187+
pgpool_node_id1.conf:
188+
name: pgpool_node_id1-${pgpool_node_id1_DIGEST:?err}
189+
file: ./config/pgpool_node_id1
190+
labels:
191+
name: hapi-fhir
192+
pgpool_node_id2.conf:
193+
name: pgpool_node_id2-${pgpool_node_id2_DIGEST:?err}
194+
file: ./config/pgpool_node_id2
195+
labels:
196+
name: hapi-fhir
75197

76198
volumes:
77199
hapi-postgres-2-data:

0 commit comments

Comments
 (0)