Skip to content

Commit 18df217

Browse files
committed
feat (engine): ignore errors that occurred during logical data dump/restore
1 parent a7c31d2 commit 18df217

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

engine/configs/config.example.logical_generic.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,9 @@ retrieval:
241241
# If your source database has 4 vCPUs or less, and you don't want to saturate them, use 2 or 1.
242242
parallelJobs: 4
243243

244+
# Ignore errors that occurred during logical data dump. Do not ignore by default.
245+
ignoreErrors: false
246+
244247
# Options for direct restore to Database Lab Engine instance.
245248
# Uncomment this if you prefer restoring from the dump on the fly. In this case,
246249
# you do not need to use "logicalRestore" job. Keep in mind that unlike "logicalRestore",
@@ -283,6 +286,9 @@ retrieval:
283286
# Note the existing data will be overwritten.
284287
forceInit: false
285288

289+
# Ignore errors that occurred during logical data restore. Do not ignore by default.
290+
ignoreErrors: false
291+
286292
# Option to adjust PostgreSQL configuration for a logical restore job
287293
# It's useful if a restored database contains non-standard extensions.
288294
<<: *db_configs

engine/configs/config.example.logical_rds_iam.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ retrieval:
238238
# If your source database has 4 vCPUs or less, and you don't want to saturate them, use 2 or 1.
239239
parallelJobs: 4
240240

241+
# Ignore errors that occurred during logical data dump. Do not ignore by default.
242+
ignoreErrors: false
243+
241244
# Options for direct restore to Database Lab Engine instance.
242245
# Uncomment this if you prefer restoring from the dump on the fly. In this case,
243246
# you do not need to use "logicalRestore" job. Keep in mind that unlike "logicalRestore",
@@ -278,6 +281,9 @@ retrieval:
278281
# Note the existing data will be overwritten.
279282
forceInit: false
280283

284+
# Ignore errors that occurred during logical data restore. Do not ignore by default.
285+
ignoreErrors: false
286+
281287
# Option to adjust PostgreSQL configuration for a logical restore job
282288
# It's useful if a restored database contains non-standard extensions.
283289
<<: *db_configs

engine/internal/retrieval/engine/postgres/logical/dump.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ type DumpOptions struct {
8787
Source Source `yaml:"source"`
8888
Databases map[string]DumpDefinition `yaml:"databases"`
8989
ParallelJobs int `yaml:"parallelJobs"`
90+
IgnoreErrors bool `yaml:"ignoreErrors"`
9091
Restore ImmediateRestore `yaml:"immediateRestore"`
9192
CustomOptions []string `yaml:"customOptions"`
9293
}
@@ -513,7 +514,9 @@ func (d *DumpJob) dumpDatabase(ctx context.Context, dumpContID, dbName string, d
513514
}); err != nil {
514515
log.Err("Dump command failed: ", output)
515516

516-
return fmt.Errorf("failed to dump a database: %w. Output: %s", err, output)
517+
if !d.DumpOptions.IgnoreErrors {
518+
return fmt.Errorf("failed to dump a database: %w. Output: %s", err, output)
519+
}
517520
}
518521

519522
log.Msg(fmt.Sprintf("Dumping job for the database %q has been finished", dbName))

engine/internal/retrieval/engine/postgres/logical/restore.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ type RestoreOptions struct {
101101
ContainerConfig map[string]interface{} `yaml:"containerConfig"`
102102
Databases map[string]DumpDefinition `yaml:"databases"`
103103
ForceInit bool `yaml:"forceInit"`
104+
IgnoreErrors bool `yaml:"ignoreErrors"`
104105
ParallelJobs int `yaml:"parallelJobs"`
105106
Configs map[string]string `yaml:"configs"`
106107
QueryPreprocessing query.PreprocessorCfg `yaml:"queryPreprocessing"`
@@ -519,7 +520,7 @@ func (r *RestoreJob) restoreDB(ctx context.Context, contID, dbName string, dbDef
519520
Env: []string{"PGAPPNAME=" + dleRetrieval},
520521
})
521522

522-
if err != nil {
523+
if err != nil && !r.RestoreOptions.IgnoreErrors {
523524
log.Err("Restore command failed: ", output)
524525

525526
return fmt.Errorf("failed to exec restore command: %w. Output: %s", err, output)

0 commit comments

Comments
 (0)