Is there any tool that allows to restart PostgreSQL when there is no more connection slots -
is there automated tool allows restart postgresql or kill pending queries on readers when there no more connection slots? problem connections readers in use because of unknown reason (slow query may be) , need quick , dirty solution monitor readers , kill queries when such event occurs. know it's more workaround masking real problem task have write script doing this, pretty sure there tool can use instead. research i've done led me following result: nagios. unfortunately, i'm still waiting ticket processed server support team.
postgresql version 9.4
select pid, query pg_stat_activity waiting='t'; ref function-admin: pg_cancel_backend
select pg_cancel_backend(pid of postgres process); a simple bash script. pass in paramters command line
#!/bin/bash dbname="test" username="postgres" vartest=`psql -d $dbname -u $username -h localhost -p 5432 -t -c "select pid pg_stat_activity waiting='f';"` p_var in ${vartest[@]} # admin function please read more on function-admin in postgres documentation # q_result= `psql -d $dbname -u $username -h localhost -p 5432 -t -c "select pg_cancel_backend('$p_var');"` # sanitiy check grabs pid , related query q_result=`psql -d $dbname -u $username -h localhost -p 5432 -t -c "select pid, query pg_stat_activity pid='$p_var';"` done
Comments
Post a Comment