Skip to content

Commit dd260ab

Browse files
committed
Merge branch '281-adjust-container-params' into 'master'
feat: allow adjusting Docker parameters for any Postgres container (#281) Closes #281 See merge request postgres-ai/database-lab!313
2 parents a2606e1 + afa1c0d commit dd260ab

12 files changed

+393
-252
lines changed

configs/config.example.logical_generic.yml

+44-51
Original file line numberDiff line numberDiff line change
@@ -71,24 +71,46 @@ poolManager:
7171
# Snapshots with this suffix are considered preliminary. They are not supposed to be accessible to end-users.
7272
preSnapshotSuffix: "_pre"
7373

74+
# Configure database containers
75+
databaseContainer: &db_container
76+
# Database Lab provisions thin clones using Docker containers and uses auxiliary containers.
77+
# We need to specify which Postgres Docker image is to be used for that.
78+
# The default is the extended Postgres image built on top of the official Postgres image
79+
# (See https://postgres.ai/docs/database-lab/supported_databases).
80+
# It is possible to choose any custom or official Docker image that runs Postgres. Our Dockerfile
81+
# (See https://gitlab.com/postgres-ai/custom-images/-/tree/master/extended)
82+
# is recommended in case if customization is needed.
83+
dockerImage: "postgresai/extended-postgres:13"
84+
85+
# Container parameters, see
86+
# https://docs.docker.com/engine/reference/run/#runtime-constraints-on-resources
87+
containerConfig:
88+
"shm-size": 1gb # default is 64mb, which is often not enough
89+
90+
# Adjust database configuration
91+
databaseConfigs: &db_configs
92+
configs:
93+
# In order to match production plans with Database Lab plans set parameters related to Query Planning as on production.
94+
shared_buffers: 1GB
95+
# shared_preload_libraries – copy the value from the source
96+
# Adding shared preload libraries, make sure that there are "pg_stat_statements, auto_explain, logerrors" in the list.
97+
# They are needed for query analysis and DB migration testing.
98+
shared_preload_libraries: "pg_stat_statements, auto_explain, logerrors"
99+
# work_mem and all the Query Planning parameters – copy the values from the source.
100+
# Detailed guide: https://postgres.ai/docs/how-to-guides/administration/postgresql-configuration#postgresql-configuration-in-clones
101+
work_mem: "100MB"
102+
# ... put Query Planning parameters here
103+
74104
# Details of provisioning – where data is located,
75105
# thin cloning method, etc.
76106
provision:
107+
<<: *db_container
77108
# Pool of ports for Postgres clones. Ports will be allocated sequentially,
78109
# starting from the lowest value. The "from" value must be less than "to".
79110
portPool:
80111
from: 6000
81112
to: 6100
82113

83-
# Database Lab provisions thin clones using Docker containers, we need
84-
# to specify which Postgres Docker image is to be used when cloning.
85-
# The default is the extended Postgres image built on top of the official Postgres image
86-
# (See https://postgres.ai/docs/database-lab/supported_databases).
87-
# Any custom or official Docker image that runs Postgres. Our Dockerfile
88-
# (See https://gitlab.com/postgres-ai/custom-images/-/tree/master/extended)
89-
# is recommended in case if customization is needed.
90-
dockerImage: "postgresai/extended-postgres:13"
91-
92114
# Use sudo for ZFS/LVM and Docker commands if Database Lab server running
93115
# outside a container. Keep it "false" (default) when running in a container.
94116
useSudo: false
@@ -97,11 +119,6 @@ provision:
97119
# existing users to log in with old passwords.
98120
keepUserPasswords: false
99121

100-
# Custom parameters for clone containers, see
101-
# https://docs.docker.com/engine/reference/run/#runtime-constraints-on-resources
102-
containerConfig:
103-
"shm-size": 1gb
104-
105122
# Data retrieval flow. This section defines both initial retrieval, and rules
106123
# to keep the data directory in a synchronized state with the source. Both are optional:
107124
# you may already have the data directory, so neither initial retrieval nor
@@ -146,13 +163,11 @@ retrieval:
146163
# Dumps PostgreSQL database from provided source.
147164
logicalDump:
148165
options:
166+
<<: *db_container
149167
# The dump file will be automatically created on this location and then used to restore.
150168
# Ensure that there is enough disk space.
151169
dumpLocation: "/var/lib/dblab/dblab_pool/dump"
152170

153-
# The Docker image containing the tools required to get a dump.
154-
dockerImage: "postgresai/extended-postgres:13"
155-
156171
# Source of data.
157172
source:
158173
# Source types: "local", "remote", "rds"
@@ -200,19 +215,16 @@ retrieval:
200215
# forceInit: false
201216
# # Option to adjust PostgreSQL configuration for a logical dump job.
202217
# # It's useful if a dumped database contains non-standard extensions.
203-
# configs:
204-
# shared_preload_libraries: "pg_stat_statements"
218+
# <<: *pg_configs
205219

206220
# Restores PostgreSQL database from the provided dump. If you use this block, do not use
207221
# "restore" option in the "logicalDump" job.
208222
logicalRestore:
209223
options:
224+
<<: *db_container
210225
# The location of the archive files (or directories, for directory-format archives) to be restored.
211226
dumpLocation: "/var/lib/dblab/dblab_pool/dump"
212227

213-
# The Docker image containing the tools required to restore.
214-
dockerImage: "postgresai/extended-postgres:13"
215-
216228
# Use parallel jobs to restore faster.
217229
parallelJobs: 2
218230

@@ -223,8 +235,7 @@ retrieval:
223235

224236
# Option to adjust PostgreSQL configuration for a logical restore job
225237
# It's useful if a restored database contains non-standard extensions.
226-
# configs:
227-
# shared_preload_libraries: "pg_stat_statements"
238+
# <<: *pg_configs
228239

229240
# Option for specifying the database list that must be restored.
230241
# By default, DLE restores all available databases.
@@ -242,42 +253,24 @@ retrieval:
242253

243254
logicalSnapshot:
244255
options:
256+
# Adjust PostgreSQL configuration
257+
<<: *db_configs
258+
259+
# It is possible to define a pre-precessing script. For example, "/tmp/scripts/custom.sh".
260+
# Default: empty string (no pre-processing defined).
261+
# This can be used for scrubbing eliminating PII data, to define data masking, etc.
262+
preprocessingScript: ""
263+
245264
# Define pre-precessing SQL queries for data patching. For example, "/tmp/scripts/sql".
246265
dataPatching:
247-
# The Docker image to run data patching container.
248-
dockerImage: "postgresai/extended-postgres:13"
249-
266+
<<: *db_container
250267
queryPreprocessing:
251268
# Path to SQL pre-processing queries. Default: empty string (no pre-processing defined).
252269
queryPath: ""
253270

254271
# Worker limit for parallel queries.
255272
maxParallelWorkers: 2
256273

257-
# It is possible to define a pre-precessing script. For example, "/tmp/scripts/custom.sh".
258-
# Default: empty string (no pre-processing defined).
259-
# This can be used for scrubbing eliminating PII data, to define data masking, etc.
260-
preprocessingScript: ""
261-
262-
# Adjust PostgreSQL configuration
263-
configs:
264-
# In order to match production plans with Database Lab plans set parameters related to Query Planning as on production.
265-
shared_buffers: 1GB
266-
# shared_preload_libraries – copy the value from the source
267-
# Adding shared preload libraries, make sure that there are "pg_stat_statements, auto_explain, logerrors" in the list.
268-
# It is necessary to perform query and db migration analysis.
269-
shared_preload_libraries: "pg_stat_statements, auto_explain, logerrors"
270-
# work_mem and all the Query Planning parameters – copy the values from the source.
271-
# To do it, use this query:
272-
# select format($$%s = '%s'$$, name, setting)
273-
# from pg_settings
274-
# where
275-
# name ~ '(work_mem$|^enable_|_cost$|scan_size$|effective_cache_size|^jit)'
276-
# or name ~ '(^geqo|default_statistics_target|constraint_exclusion|cursor_tuple_fraction)'
277-
# or name ~ '(collapse_limit$|parallel|plan_cache_mode)';
278-
work_mem: "100MB"
279-
# ... put Query Planning parameters here
280-
281274
cloning:
282275
# Host that will be specified in database connection info for all clones
283276
# Use public IP address if database connections are allowed from outside

configs/config.example.logical_rds_iam.yml

+50-50
Original file line numberDiff line numberDiff line change
@@ -71,24 +71,52 @@ poolManager:
7171
# Snapshots with this suffix are considered preliminary. They are not supposed to be accessible to end-users.
7272
preSnapshotSuffix: "_pre"
7373

74+
# Configure database containers
75+
databaseContainer: &db_container
76+
# Database Lab provisions thin clones using Docker containers and uses auxiliary containers.
77+
# We need to specify which Postgres Docker image is to be used for that.
78+
# The default is the extended Postgres image built on top of the official Postgres image
79+
# (See https://postgres.ai/docs/database-lab/supported_databases).
80+
# It is possible to choose any custom or official Docker image that runs Postgres. Our Dockerfile
81+
# (See https://gitlab.com/postgres-ai/custom-images/-/tree/master/extended)
82+
# is recommended in case if customization is needed.
83+
dockerImage: "postgresai/extended-postgres:13"
84+
85+
# Custom parameters for containers with PostgreSQL, see
86+
# https://docs.docker.com/engine/reference/run/#runtime-constraints-on-resources
87+
containerConfig:
88+
"shm-size": 1gb
89+
90+
# Adjust database configuration
91+
databaseConfigs: &db_configs
92+
configs:
93+
# In order to match production plans with Database Lab plans set parameters related to Query Planning as on production.
94+
shared_buffers: 1GB
95+
# shared_preload_libraries – copy the value from the source
96+
# Adding shared preload libraries, make sure that there are "pg_stat_statements, auto_explain, logerrors" in the list.
97+
# It is necessary to perform query and db migration analysis.
98+
shared_preload_libraries: "pg_stat_statements, auto_explain, logerrors"
99+
# work_mem and all the Query Planning parameters – copy the values from the source.
100+
# To do it, use this query:
101+
# select format($$%s = '%s'$$, name, setting)
102+
# from pg_settings
103+
# where
104+
# name ~ '(work_mem$|^enable_|_cost$|scan_size$|effective_cache_size|^jit)'
105+
# or name ~ '(^geqo|default_statistics_target|constraint_exclusion|cursor_tuple_fraction)'
106+
# or name ~ '(collapse_limit$|parallel|plan_cache_mode)';
107+
work_mem: "100MB"
108+
# ... put Query Planning parameters here
109+
74110
# Details of provisioning – where data is located,
75111
# thin cloning method, etc.
76112
provision:
113+
<<: *db_container
77114
# Pool of ports for Postgres clones. Ports will be allocated sequentially,
78115
# starting from the lowest value. The "from" value must be less than "to".
79116
portPool:
80117
from: 6000
81118
to: 6100
82119

83-
# Database Lab provisions thin clones using Docker containers, we need
84-
# to specify which Postgres Docker image is to be used when cloning.
85-
# The default is the extended Postgres image built on top of the official Postgres image
86-
# (See https://postgres.ai/docs/database-lab/supported_databases).
87-
# Any custom or official Docker image that runs Postgres. Our Dockerfile
88-
# (See https://gitlab.com/postgres-ai/custom-images/-/tree/master/extended)
89-
# is recommended in case if customization is needed.
90-
dockerImage: "postgresai/extended-postgres:13"
91-
92120
# Use sudo for ZFS/LVM and Docker commands if Database Lab server running
93121
# outside a container. Keep it "false" (default) when running in a container.
94122
useSudo: false
@@ -97,10 +125,6 @@ provision:
97125
# existing users to log in with old passwords.
98126
keepUserPasswords: false
99127

100-
# Custom parameters for clone containers (https://docs.docker.com/engine/reference/run/#runtime-constraints-on-resources).
101-
containerConfig:
102-
"shm-size": 1gb
103-
104128
# Data retrieval flow. This section defines both initial retrieval, and rules
105129
# to keep the data directory in a synchronized state with the source. Both are optional:
106130
# you may already have the data directory, so neither initial retrieval nor
@@ -145,13 +169,11 @@ retrieval:
145169
# Dumps PostgreSQL database from provided source.
146170
logicalDump:
147171
options:
172+
<<: *db_container
148173
# The dump file will be automatically created on this location and then used to restore.
149174
# Ensure that there is enough disk space.
150175
dumpLocation: "/var/lib/dblab/dblab_pool/dump"
151176

152-
# The Docker image containing the tools required to get a dump.
153-
dockerImage: "postgresai/extended-postgres:13"
154-
155177
# Source of data.
156178
source:
157179
# Source types: "local", "remote", "rdsIam"
@@ -202,19 +224,16 @@ retrieval:
202224
# forceInit: false
203225
# # Option to adjust PostgreSQL configuration for a logical dump job.
204226
# # It's useful if a dumped database contains non-standard extensions.
205-
# configs:
206-
# shared_preload_libraries: "pg_stat_statements"
227+
# <<: *pg_configs
207228

208229
# Restores PostgreSQL database from the provided dump. If you use this block, do not use
209230
# "restore" option in the "logicalDump" job.
210231
logicalRestore:
211232
options:
233+
<<: *db_container
212234
# The location of the archive file (or directory, for a directory-format archive) to be restored.
213235
dumpLocation: "/var/lib/dblab/dblab_pool/dump"
214236

215-
# The Docker image containing the tools required to restore.
216-
dockerImage: "postgresai/extended-postgres:13"
217-
218237
# Use parallel jobs to restore faster.
219238
parallelJobs: 2
220239

@@ -224,8 +243,7 @@ retrieval:
224243

225244
# Option to adjust PostgreSQL configuration for a logical restore job
226245
# It's useful if a restored database contains non-standard extensions.
227-
# configs:
228-
# shared_preload_libraries: "pg_stat_statements"
246+
# <<: *pg_configs
229247

230248
# Option for specifying the database list that must be restored.
231249
# By default, DLE restores all available databases.
@@ -242,42 +260,24 @@ retrieval:
242260

243261
logicalSnapshot:
244262
options:
263+
# Adjust PostgreSQL configuration
264+
<<: *db_configs
265+
266+
# It is possible to define a pre-precessing script. For example, "/tmp/scripts/custom.sh".
267+
# Default: empty string (no pre-processing defined).
268+
# This can be used for scrubbing eliminating PII data, to define data masking, etc.
269+
preprocessingScript: ""
270+
245271
# Define pre-precessing SQL queries for data patching. For example, "/tmp/scripts/sql".
246272
dataPatching:
247-
# The Docker image to run data patching container.
248-
dockerImage: "postgresai/extended-postgres:13"
249-
273+
<<: *db_container
250274
queryPreprocessing:
251275
# Path to SQL pre-processing queries. Default: empty string (no pre-processing defined).
252276
queryPath: ""
253277

254278
# Worker limit for parallel queries.
255279
maxParallelWorkers: 2
256280

257-
# It is possible to define a pre-precessing script. For example, "/tmp/scripts/custom.sh".
258-
# Default: empty string (no pre-processing defined).
259-
# This can be used for scrubbing eliminating PII data, to define data masking, etc.
260-
preprocessingScript: ""
261-
262-
# Adjust PostgreSQL configuration
263-
configs:
264-
# In order to match production plans with Database Lab plans set parameters related to Query Planning as on production.
265-
shared_buffers: 1GB
266-
# shared_preload_libraries – copy the value from the source
267-
# Adding shared preload libraries, make sure that there are "pg_stat_statements, auto_explain, logerrors" in the list.
268-
# It is necessary to perform query and db migration analysis.
269-
shared_preload_libraries: "pg_stat_statements, auto_explain, logerrors"
270-
# work_mem and all the Query Planning parameters – copy the values from the source.
271-
# To do it, use this query:
272-
# select format($$%s = '%s'$$, name, setting)
273-
# from pg_settings
274-
# where
275-
# name ~ '(work_mem$|^enable_|_cost$|scan_size$|effective_cache_size|^jit)'
276-
# or name ~ '(^geqo|default_statistics_target|constraint_exclusion|cursor_tuple_fraction)'
277-
# or name ~ '(collapse_limit$|parallel|plan_cache_mode)';
278-
work_mem: "100MB"
279-
# ... put Query Planning parameters here
280-
281281
cloning:
282282
# Host that will be specified in database connection info for all clones
283283
# Use public IP address if database connections are allowed from outside

0 commit comments

Comments
 (0)