Last active
October 9, 2024 05:06
-
-
Save linuxmalaysia/1edd671311f3f7d75af110198279d791 to your computer and use it in GitHub Desktop.
Idle In Transaction Problem - Postgresql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Harisfazillah Jamel - 20211216 | |
# Part of script from https://wiki.lyrasis.org/display/DSPACE/Idle+In+Transaction+Problem | |
# Idle In Transaction Problem | |
pgprocess_array=( $( /usr/bin/pgrep -f 'idle in transaction' ) ) | |
/usr/bin/pgrep -f 'idle in transaction' | wc -l | logger | |
for r in "${pgprocess_array[@]}"; do | |
/usr/bin/test `/usr/bin/pgrep -f 'idle in transaction' | /usr/bin/wc \-l ` \-gt 0 && /usr/bin/pkill \-o \-f 'idle in transaction' | |
### /usr/bin/test `/usr/bin/pgrep -f 'idle in transaction' | /usr/bin/wc \-l ` \-gt 20 && /usr/bin/pkill \-o \-f 'idle in transaction' | |
### /usr/bin/pgrep -f 'idle in transaction' | wc -l | |
echo "PG $r" | |
done | |
/usr/bin/pgrep -f 'idle in transaction' | wc -l | logger | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To check
SELECT count(*),state FROM pg_stat_activity GROUP BY 2;