pgpool / pgpool2_on_k8s

57 stars 36 forks source link

pgpool container restart #10

Open jhy070997 opened 2 years ago

jhy070997 commented 2 years ago

Helm chart version postgresql-ha-7.8.2

Describe pgpool container (inside of Pod) restart when many client session

Reproduce Deploy chart with configs.

maxConnections: "1000" in postgresql chart value
default pgpool.conf
postgresql replicas: 3
pgpool replicas: 1 (or 3)

Create python script

from sqlalchemy import create_engine
from sqlalchemy.orm import scoped_session, sessionmaker
import os
from urllib.parse import quote

for i in range(500):
    engine = create_engine("postgresql://[USER]:%s@[IP]:[PORT]/[DB]" % quote('pass'))
    db = scoped_session(sessionmaker(bind=engine))
    pid = os.getpid()
    cmd_sql = "INSERT INTO test (pid) VALUES ('"+str(pid)+"');"
    print(cmd_sql)
    db.execute(cmd_sql)
    db.commit()
    db.close()

Execute script with different shell terminal (create multiple process) Data will be inserted. and stop when 80~90 records were inserted and container will restart with log below

2021-09-16 03:56:27: pid 1: LOG:  shutting down
2021-09-16 03:56:27: pid 1: LOG:  terminating all child processes

Expected behavior A clear and concise description of what you expected to happen. child process of pgpool is 32. max_pool is 15. so pgpool can accept 480 sessions. (at least 480 data would be inserted)

Version of Helm and Kubernetes: Output of helm version:

version.BuildInfo{Version:"v3.6.3", GitCommit:"d506314abfb5d21419df8c7e7e68012379db2354", GitTreeState:"clean", GoVersion:"go1.16.5"}

Output of kubectl version:

Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.0", GitCommit:"cb303e613a121a29364f75cc67d3d580833a7479", GitTreeState:"clean", BuildDate:"2021-04-08T16:31:21Z", GoVersion:"go1.16.1", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.3", GitCommit:"ca643a4d1f7bfe34773c74f79527be4afd95bf39", GitTreeState:"clean", BuildDate:"2021-07-15T20:59:07Z", GoVersion:"go1.16.6", Compiler:"gc", Platform:"linux/amd64"}
jhy070997 commented 2 years ago

before the container restart, I saw the number of processes (about 16 processes) with same command (result via ps aux)

1001      6273  0.0  0.0   3740  2816 ?        Ss   06:26   0:00 bash -ec PGPASSWORD=${PGPOOL_POSTGRES_PASSWORD} psql -U "postgres" -d "postgres" -h /opt/bitnami/pgpool/tmp -tA -c "SELECT 1" >/dev/null
1001      6284  0.0  0.1  17636  5260 ?        S    06:26   0:00 psql -U postgres -d postgres -h /opt/bitnami/pgpool/tmp -tA -c SELECT 1