Skip to content

Commit ed0879d

Browse files
committed
Add commonly changed postgresql settings as parameters
Prior to this commit, we only managed autovacuum settings. After this commit, we manage many more commonly changed postgresql settings. We also set autovacuum_cost_delay=0 on the fact_values table of pe-puppetdb because it prevents bloat of the table and its indexes if customers have a lot of facts that change every run.
1 parent 7c2bad5 commit ed0879d

File tree

1 file changed

+56
-4
lines changed

1 file changed

+56
-4
lines changed

manifests/postgresql_settings.pp

Lines changed: 56 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,17 @@
11
class pe_databases::postgresql_settings (
2-
Float[0,1] $autovacuum_vacuum_scale_factor = 0.08,
3-
Float[0,1] $autovacuum_analyze_scale_factor = 0.04,
4-
Boolean $manage_postgresql_service = true,
5-
Boolean $all_in_one_pe_install = true,
2+
Float[0,1] $autovacuum_vacuum_scale_factor = 0.08,
3+
Float[0,1] $autovacuum_analyze_scale_factor = 0.04,
4+
Integer $autovacuum_max_workers = min(8, $::processors['count'] / 2),
5+
Integer $log_autovacuum_min_duration = 0,
6+
Integer $log_temp_files = 0,
7+
String $maintenance_work_mem = "${::memory['system']['total_bytes'] / 1024 / 1024 / 16}MB",
8+
String $work_mem = '8MB',
9+
Integer $max_connections = 1000,
10+
Float[0,1] $checkpoint_completion_target = 0.9,
11+
Float[0,1] $checkpoint_segments = 128,
12+
Boolean $manage_postgresql_service = true,
13+
Boolean $all_in_one_pe_install = true,
14+
Boolean $manage_fact_values_autovacuum_cost_delay = true,
615
) {
716

817
$postgresql_service_resource_name = 'postgresqld'
@@ -41,4 +50,47 @@
4150
postgresql_conf { 'autovacuum_analyze_scale_factor' :
4251
value => "${autovacuum_analyze_scale_factor}",
4352
}
53+
54+
postgresql_conf { 'autovacuum_max_workers' :
55+
value => "${autovacuum_max_workers}",
56+
}
57+
58+
postgresql_conf { 'log_autovacuum_min_duration' :
59+
value => "${log_autovacuum_min_duration}",
60+
}
61+
62+
postgresql_conf { 'log_temp_files' :
63+
value => "${log_temp_files}",
64+
}
65+
66+
postgresql_conf { 'maintenance_work_mem' :
67+
value => "${maintenance_work_mem}",
68+
}
69+
70+
postgresql_conf { 'work_mem' :
71+
value => "${work_mem}",
72+
}
73+
74+
postgresql_conf { 'max_connections' :
75+
value => "${max_connections}",
76+
}
77+
78+
postgresql_conf { 'checkpoint_completion_target' :
79+
value => "${checkpoint_completion_target}",
80+
}
81+
82+
postgresql_conf { 'checkpoint_segments' :
83+
value => "${checkpoint_segments}",
84+
}
85+
86+
if $manage_fact_values_autovacuum_cost_delay {
87+
postgresql_psql { 'Set autovacuum_cost_delay=0 for fact_values' :
88+
command => 'ALTER TABLE fact_values SET ( autovacuum_vacuum_cost_delay = 0 )',
89+
unless => 'SELECT reloptions FROM pg_class WHERE relname = \'fact_values\' AND CAST(reloptions as text) LIKE \'%autovacuum_vacuum_cost_delay=0%\'',
90+
db => 'pe-puppetdb',
91+
psql_user => 'pe-postgres',
92+
psql_group => 'pe-postgres',
93+
psql_path => '/opt/puppetlabs/server/bin/psql',
94+
}
95+
}
4496
}

0 commit comments

Comments
 (0)