-
Notifications
You must be signed in to change notification settings - Fork 2
Added ENV for autovacuum_vacuum_scale_factor and autovacuum_analyze_scale_factor #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
615b950
45506bd
cfbace9
98e0202
4ec7a80
ccd0648
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ ARG PG_MAJOR_PREVIOUS=14 | |
ARG PG_MAJOR=15 | ||
|
||
FROM timescaledev/timescaledb-ha:pg15-multi as trimmed | ||
MAINTAINER [email protected] | ||
LABEL org.opencontainers.image.authors="[email protected]" | ||
|
||
USER root | ||
|
||
|
@@ -78,7 +78,9 @@ ENV PGROOT=/var/lib/postgresql \ | |
OR_REINDEX_COUNTER=${OR_REINDEX_COUNTER} \ | ||
OR_DISABLE_REINDEX=${OR_DISABLE_REINDEX:-false} \ | ||
POSTGRES_MAX_CONNECTIONS=${POSTGRES_MAX_CONNECTIONS:-50} \ | ||
OR_DISABLE_AUTO_UPGRADE=${OR_DISABLE_AUTO_UPGRADE:-false} | ||
OR_DISABLE_AUTO_UPGRADE=${OR_DISABLE_AUTO_UPGRADE:-false} \ | ||
OR_AUTOVACUUM_VACUUM_SCALE_FACTOR=${OR_AUTOVACUUM_VACUUM_SCALE_FACTOR:-0.2} \ | ||
OR_AUTOVACUUM_ANALYZE_SCALE_FACTOR=${OR_AUTOVACUUM_ANALYZE_SCALE_FACTOR:-0.1} | ||
|
||
WORKDIR /var/lib/postgresql | ||
EXPOSE 5432 8008 8081 | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
echo "-------------------------------------------------------------------------------------" | ||
echo "Setting autovacuum parameters during initialization..." | ||
echo "-------------------------------------------------------------------------------------" | ||
|
||
# Set vacuum parameters | ||
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL | ||
ALTER SYSTEM SET autovacuum_vacuum_scale_factor = $OR_AUTOVACUUM_VACUUM_SCALE_FACTOR; | ||
ALTER SYSTEM SET autovacuum_analyze_scale_factor = $OR_AUTOVACUUM_ANALYZE_SCALE_FACTOR; | ||
SELECT pg_reload_conf(); | ||
EOSQL | ||
|
||
echo "-----------------------------------------------------------------------------------" | ||
echo "Autovacuum parameters set: " | ||
echo " - autovacuum_vacuum_scale_factor = $OR_AUTOVACUUM_VACUUM_SCALE_FACTOR" | ||
echo " - autovacuum_analyze_scale_factor = $OR_AUTOVACUUM_ANALYZE_SCALE_FACTOR" | ||
echo "-----------------------------------------------------------------------------------" | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,54 @@ if [ -n "$DATABASE_ALREADY_EXISTS" ]; then | |
echo "timescaledb.telemetry_level=off" >> "$PGDATA/postgresql.conf" | ||
fi | ||
|
||
# Check and update autovacuum_vacuum_scale_factor if needed | ||
echo "--------------------------------------------------------------------" | ||
echo "Checking autovacuum_vacuum_scale_factor setting..." | ||
echo "--------------------------------------------------------------------" | ||
|
||
# Extract current setting if it exists (commented or uncommented) | ||
CURRENT_AUTOVAC_SETTING=$(grep -E "^[#]*autovacuum_vacuum_scale_factor" "$PGDATA/postgresql.conf" | grep -oE "[0-9]\.[0-9]+" || echo "") | ||
|
||
if [ -z "$CURRENT_AUTOVAC_SETTING" ] || [ "$CURRENT_AUTOVAC_SETTING" != "$OR_AUTOVACUUM_VACUUM_SCALE_FACTOR" ]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check |
||
echo "------------------------------------------------------------------------" | ||
echo "Setting autovacuum_vacuum_scale_factor to $OR_AUTOVACUUM_VACUUM_SCALE_FACTOR" | ||
echo "------------------------------------------------------------------------" | ||
|
||
# Remove any existing setting (commented or uncommented) | ||
sed -i "/^[#]*autovacuum_vacuum_scale_factor/d" "$PGDATA/postgresql.conf" | ||
|
||
# Add the new setting | ||
echo "autovacuum_vacuum_scale_factor = $OR_AUTOVACUUM_VACUUM_SCALE_FACTOR" >> "$PGDATA/postgresql.conf" | ||
else | ||
echo "-----------------------------------------------------------------------" | ||
echo "autovacuum_vacuum_scale_factor already set to $CURRENT_AUTOVAC_SETTING" | ||
echo "-----------------------------------------------------------------------" | ||
fi | ||
|
||
# Check and update autovacuum_analyze_scale_factor if needed | ||
echo "--------------------------------------------------------------------" | ||
echo "Checking autovacuum_analyze_scale_factor setting..." | ||
echo "--------------------------------------------------------------------" | ||
|
||
# Extract current setting if it exists (commented or uncommented) | ||
CURRENT_AUTOVAC_ANALYZE_SETTING=$(grep -E "^[#]*autovacuum_analyze_scale_factor" "$PGDATA/postgresql.conf" | grep -oE "[0-9]\.[0-9]+" || echo "") | ||
|
||
if [ -z "$CURRENT_AUTOVAC_ANALYZE_SETTING" ] || [ "$CURRENT_AUTOVAC_ANALYZE_SETTING" != "$OR_AUTOVACUUM_ANALYZE_SCALE_FACTOR" ]; then | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check |
||
echo "------------------------------------------------------------------------" | ||
echo "Setting autovacuum_analyze_scale_factor to $OR_AUTOVACUUM_ANALYZE_SCALE_FACTOR" | ||
echo "------------------------------------------------------------------------" | ||
|
||
# Remove any existing setting (commented or uncommented) | ||
sed -i "/^[#]*autovacuum_analyze_scale_factor/d" "$PGDATA/postgresql.conf" | ||
|
||
# Add the new setting | ||
echo "autovacuum_analyze_scale_factor = $OR_AUTOVACUUM_ANALYZE_SCALE_FACTOR" >> "$PGDATA/postgresql.conf" | ||
else | ||
echo "------------------------------------------------------------------------" | ||
echo "autovacuum_analyze_scale_factor already set to $CURRENT_AUTOVAC_ANALYZE_SETTING" | ||
echo "------------------------------------------------------------------------" | ||
fi | ||
|
||
######################################################################################## | ||
# Do upgrade checks - Adapted from https://github.com/pgautoupgrade/docker-pgautoupgrade | ||
######################################################################################## | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at this now I don't see value in having this init script and the logic in the entrypoint, the entrypoint logic should be sufficient I think