Skip to content

Commit 5fa4a7a

Browse files
committed
reconcile an oom-fixer into place
1 parent 4679ad0 commit 5fa4a7a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

internal/postgres/reconcile.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,19 @@ func InstancePod(ctx context.Context,
168168
Image: config.PostgresContainerImage(inCluster),
169169
ImagePullPolicy: inCluster.Spec.ImagePullPolicy,
170170
Resources: inInstanceSpec.Resources,
171+
Command: []string{
172+
`echo "for pid in $(pgrep -f \"/usr/pgsql-16/bin/postgres\"); do
173+
current=$(cat /proc/$pid/oom_score_adj 2>/dev/null || echo \"\")
174+
if [ \"$current\" != \"-900\" ]; then
175+
echo \"adjusting oom score for pid $pid\"
176+
echo -900 > /proc/$pid/oom_score_adj
177+
fi
178+
done
179+
180+
sleep 30
181+
done" > /oom-fixer.sh && chmod +x /oom-fixer.sh`,
182+
"/oom-fixer.sh & /usr/bin/patroni",
183+
},
171184

172185
Ports: []corev1.ContainerPort{{
173186
Name: naming.PortPostgreSQL,

0 commit comments

Comments
 (0)