Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ac0c10c

Browse filesBrowse files
committed
feat: control Postgres settings of the sync and promotion containers (#210)
1 parent a37c712 commit ac0c10c
Copy full SHA for ac0c10c

File tree

Expand file treeCollapse file tree

4 files changed

+47
-7
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+47
-7
lines changed

‎configs/config.example.physical_generic.yml

Copy file name to clipboardExpand all lines: configs/config.example.physical_generic.yml
+13-1Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ retrieval:
161161
# Maximum number of health check retries.
162162
maxRetries: 200
163163

164+
# Adjust PostgreSQL configuration of the sync container.
165+
configs:
166+
shared_buffers: 1GB
167+
shared_preload_libraries: "pg_stat_statements"
168+
work_mem: "100MB"
169+
164170
# Set environment variables here. See https://www.postgresql.org/docs/current/libpq-envars.html
165171
envs:
166172
PGUSER: "postgres"
@@ -210,12 +216,18 @@ retrieval:
210216
# Worker limit for parallel queries.
211217
maxParallelWorkers: 2
212218

219+
# Adjust PostgreSQL configuration of the promotion container.
220+
configs:
221+
shared_buffers: 1GB
222+
shared_preload_libraries: "pg_stat_statements"
223+
work_mem: "100MB"
224+
213225
# It is possible to define a pre-precessing script. For example, "/tmp/scripts/custom.sh".
214226
# Default: empty string (no pre-processing defined).
215227
# This can be used for scrubbing eliminating PII data, to define data masking, etc.
216228
preprocessingScript: ""
217229

218-
# Adjust PostgreSQL configuration
230+
# Adjust PostgreSQL configuration of the snapshot.
219231
configs:
220232
# In order to match production plans with Database Lab plans set parameters related to Query Planning as on production.
221233
shared_buffers: 1GB

‎configs/config.example.physical_walg.yml

Copy file name to clipboardExpand all lines: configs/config.example.physical_walg.yml
+13-1Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ retrieval:
161161
# Maximum number of health check retries.
162162
maxRetries: 200
163163

164+
# Adjust PostgreSQL configuration of the sync container.
165+
configs:
166+
shared_buffers: 1GB
167+
shared_preload_libraries: "pg_stat_statements"
168+
work_mem: "100MB"
169+
164170
# Passes custom environment variables to the Docker container with the restoring tool.
165171
envs:
166172
WALG_GS_PREFIX: "gs://{BUCKET}/{SCOPE}"
@@ -200,12 +206,18 @@ retrieval:
200206
# Worker limit for parallel queries.
201207
maxParallelWorkers: 2
202208

209+
# Adjust PostgreSQL configuration of the promotion container.
210+
configs:
211+
shared_buffers: 1GB
212+
shared_preload_libraries: "pg_stat_statements"
213+
work_mem: "100MB"
214+
203215
# It is possible to define a pre-precessing script. For example, "/tmp/scripts/custom.sh".
204216
# Default: empty string (no pre-processing defined).
205217
# This can be used for scrubbing eliminating PII data, to define data masking, etc.
206218
preprocessingScript: ""
207219

208-
# Adjust PostgreSQL configuration
220+
# Adjust PostgreSQL configuration of the snapshot.
209221
configs:
210222
# In order to match production plans with Database Lab plans set parameters related to Query Planning as on production.
211223
shared_buffers: 1GB

‎pkg/retrieval/engine/postgres/physical/physical.go

Copy file name to clipboardExpand all lines: pkg/retrieval/engine/postgres/physical/physical.go
+10-2Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ type CopyOptions struct {
7878

7979
// Sync describes sync instance options.
8080
type Sync struct {
81-
Enabled bool `yaml:"enabled"`
82-
HealthCheck HealthCheck `yaml:"healthCheck"`
81+
Enabled bool `yaml:"enabled"`
82+
HealthCheck HealthCheck `yaml:"healthCheck"`
83+
Configs map[string]string `yaml:"configs"`
8384
}
8485

8586
// HealthCheck describes health check options of a sync instance.
@@ -249,6 +250,13 @@ func (r *RestoreJob) Run(ctx context.Context) (err error) {
249250
return errors.Wrap(err, "failed to adjust by init parameters")
250251
}
251252

253+
// Apply sync instance configs.
254+
if syncConfig := r.CopyOptions.Sync.Configs; len(syncConfig) > 0 {
255+
if err := configuration.NewCorrectorWithExtraConfig(syncConfig).ApplyExtraConf(dataDir); err != nil {
256+
return errors.Wrap(err, "cannot update sync instance configs")
257+
}
258+
}
259+
252260
log.Msg("Configuration has been finished")
253261

254262
return nil

‎pkg/retrieval/engine/postgres/snapshot/physical.go

Copy file name to clipboardExpand all lines: pkg/retrieval/engine/postgres/snapshot/physical.go
+11-3Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ type Promotion struct {
9191
DockerImage string `yaml:"dockerImage"`
9292
HealthCheck HealthCheck `yaml:"healthCheck"`
9393
QueryPreprocessing QueryPreprocessing `yaml:"queryPreprocessing"`
94+
Configs map[string]string `yaml:"configs"`
9495
}
9596

9697
// HealthCheck describes health check options of a promotion.
@@ -389,9 +390,11 @@ func (p *PhysicalInitial) promoteInstance(ctx context.Context, clonePath string)
389390
return errors.Wrap(err, "failed to enforce configs")
390391
}
391392

392-
// Apply users configs.
393-
if err := applyUsersConfigs(p.options.Configs, path.Join(clonePath, "postgresql.conf")); err != nil {
394-
return err
393+
// Apply promotion configs.
394+
if syncConfig := p.options.Promotion.Configs; len(syncConfig) > 0 {
395+
if err := configuration.NewCorrectorWithExtraConfig(syncConfig).ApplyExtraConf(clonePath); err != nil {
396+
return errors.Wrap(err, "cannot update promotion configs")
397+
}
395398
}
396399

397400
pgVersion, err := tools.DetectPGVersion(clonePath)
@@ -517,6 +520,11 @@ func (p *PhysicalInitial) promoteInstance(ctx context.Context, clonePath string)
517520
return err
518521
}
519522

523+
// Apply users configs.
524+
if err := applyUsersConfigs(p.options.Configs, path.Join(clonePath, "postgresql.conf")); err != nil {
525+
return err
526+
}
527+
520528
return nil
521529
}
522530

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.