Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commitfc1817c

Browse files
committed
Merge branch '230-dle-configuration' into 'master'
fix: DLE restore configuration (#230)# Description- add recovery_target_timeline (PG < 12) to handle a failover properly in Postgres 11 and older(see the related issue)- skip an error due to absent `postgresql.conf` while init DLE configs. The absence of the `postgresql.conf` file is normal at the first start because it will be initialized a little later- correct the path of the recovery fileCloses#230See merge request postgres-ai/database-lab!247
2 parents5fb36f0 +4dda095 commitfc1817c

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func (c *custom) GetRecoveryConfig(pgVersion float64) map[string]string {
4141

4242
ifpgVersion<defaults.PGVersion12 {
4343
recoveryCfg["standby_mode"]="on"
44+
recoveryCfg["recovery_target_timeline"]="latest"
4445
}
4546
}
4647

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ func TestCustomRecoveryConfig(t *testing.T) {
1313

1414
recoveryConfig:=customTool.GetRecoveryConfig(11.7)
1515
expectedResponse11:=map[string]string{
16-
"restore_command":"pg_basebackup -X stream -D dataDirectory",
17-
"standby_mode":"on",
16+
"restore_command":"pg_basebackup -X stream -D dataDirectory",
17+
"standby_mode":"on",
18+
"recovery_target_timeline":"latest",
1819
}
1920
assert.Equal(t,expectedResponse11,recoveryConfig)
2021

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ func (w *walg) GetRecoveryConfig(pgVersion float64) map[string]string {
4444

4545
ifpgVersion<defaults.PGVersion12 {
4646
recoveryCfg["standby_mode"]="on"
47+
recoveryCfg["recovery_target_timeline"]="latest"
4748
}
4849

4950
returnrecoveryCfg

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ func TestWALGRecoveryConfig(t *testing.T) {
1111

1212
recoveryConfig:=walg.GetRecoveryConfig(11.7)
1313
expectedResponse11:=map[string]string{
14-
"restore_command":"wal-g wal-fetch %f %p",
15-
"standby_mode":"on",
14+
"restore_command":"wal-g wal-fetch %f %p",
15+
"standby_mode":"on",
16+
"recovery_target_timeline":"latest",
1617
}
1718
assert.Equal(t,expectedResponse11,recoveryConfig)
1819

‎pkg/services/provision/databases/postgres/pgconfig/configuration.go‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ func (m *Manager) isInitialized() (bool, error) {
146146

147147
postgresFile,err:=os.Open(pgConfDst)
148148
iferr!=nil {
149+
if_,ok:=err.(*os.PathError);ok {
150+
returnfalse,nil
151+
}
152+
149153
returnfalse,err
150154
}
151155

@@ -303,6 +307,10 @@ func (m *Manager) AdjustRecoveryFiles() error {
303307

304308
// ApplyRecovery applies recovery configuration parameters.
305309
func (m*Manager)ApplyRecovery(cfgmap[string]string)error {
310+
iferr:=tools.TouchFile(path.Join(m.dataDir,m.recoveryFilename()));err!=nil {
311+
returnerr
312+
}
313+
306314
iferr:=appendExtraConf(path.Join(m.dataDir,m.recoveryFilename()),cfg);err!=nil {
307315
returnerr
308316
}
@@ -373,11 +381,11 @@ func (m *Manager) getConfigPath(configName string) string {
373381

374382
// recoveryFilename returns the name of a recovery configuration file.
375383
func (mManager)recoveryFilename()string {
376-
ifm.pgVersion>defaults.PGVersion12 {
384+
ifm.pgVersion>=defaults.PGVersion12 {
377385
returnconfigPrefix+pgConfName
378386
}
379387

380-
returnconfigPrefix+recoveryConfName
388+
returnrecoveryConfName
381389
}
382390

383391
// rewriteConfig completely rewrite a configuration file with provided parameters.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp