bundles/postgresql: add metadata keys for some performance related config options

This commit is contained in:
Franzi 2021-04-23 14:02:04 +02:00
parent 616feb54b2
commit 8b14575657
Signed by: kunsi
GPG key ID: 12E3D2136B818350
3 changed files with 34 additions and 5 deletions

View file

@ -2,11 +2,7 @@ data_directory = '/var/lib/postgresql/${version}/main'
hba_file = '/etc/postgresql/${version}/main/pg_hba.conf'
ident_file = '/etc/postgresql/${version}/main/pg_ident.conf'
external_pid_file = '/var/run/postgresql/${version}-main.pid'
% if version == '9.1':
unix_socket_directory = '/var/run/postgresql'
% else:
unix_socket_directories = '/var/run/postgresql'
% endif
port = 5432
listen_addresses = 'localhost'
max_connections = ${max_connections}
@ -28,3 +24,9 @@ log_min_duration_statement = ${slow_query_log_sec*1000}
% else:
log_min_duration_statement = -1
% endif
effective_io_concurrency = ${effective_io_concurrency}
max_worker_processes = ${max_worker_processes}
% if version_list >= [10]:
max_parallel_workers = ${max_parallel_workers}
% endif
max_parallel_workers_per_gather = ${max_parallel_workers_per_gather}

View file

@ -43,7 +43,10 @@ files = {
},
"/etc/postgresql/{}/main/postgresql.conf".format(postgresql_version): {
'content_type': 'mako',
'context': node.metadata['postgresql'],
'context': {
'version_list': [int(i) for i in node.metadata['postgresql']['version'].split('.')],
**node.metadata['postgresql'],
},
'owner': 'postgres',
'group': 'postgres',
'needs': {

View file

@ -77,3 +77,27 @@ def default_postgresql_version_for_debian(metadata):
'version': version_to_be_installed,
},
}
@metadata_reactor.provides(
'postgresql/effective_io_concurrency',
'postgresql/max_worker_processes',
'postgresql/max_parallel_workers',
'postgresql/max_parallel_workers_per_gather',
)
def worker_processes(metadata):
return {
'postgresql': {
# This is the amount of parallel I/O Operations the
# postgresql process is allowed to do on disk. We set
# this to max_connections by default.
'effective_io_concurrency': metadata.get('postgresql/max_connections'),
# Try to request one worker process per 10 configured
# connections. The default is 8 for both of these values.
'max_worker_processes': int(metadata.get('postgresql/max_connections')/10),
'max_parallel_workers': int(metadata.get('postgresql/max_connections')/10),
# default 2
'max_parallel_workers_per_gather': max(int(metadata.get('postgresql/max_connections')/100), 2),
},
}