Skip to content

Commit 709a3d0

Browse files
committed
cluster: make DefaultSyncTimeout infinite.
SyncTimeout is currently undocumented and is set to 30 minutes causing unexpected behaviors to users. So make its default set to 0 (infinite). Another PR will document it.
1 parent 2ae5e0f commit 709a3d0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

internal/cluster/cluster.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const (
5555
DefaultRequestTimeout = 10 * time.Second
5656
DefaultConvergenceTimeout = 30 * time.Second
5757
DefaultInitTimeout = 5 * time.Minute
58-
DefaultSyncTimeout = 30 * time.Minute
58+
DefaultSyncTimeout = 0
5959
DefaultFailInterval = 20 * time.Second
6060
DefaultDeadKeeperRemovalInterval = 48 * time.Hour
6161
DefaultMaxStandbys uint16 = 20

internal/postgresql/postgresql.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ func (p *Manager) start(args ...string) error {
342342
// Wait for the correct pid file to appear or for the process to exit
343343
ok := false
344344
start := time.Now()
345-
for time.Now().Add(-startTimeout).Before(start) {
345+
for time.Since(start) < startTimeout {
346346
fh, err := os.Open(filepath.Join(p.dataDir, "postmaster.pid"))
347347
if err == nil {
348348
scanner := bufio.NewScanner(fh)
@@ -485,7 +485,7 @@ func (p *Manager) Restart(fast bool) error {
485485

486486
func (p *Manager) WaitReady(timeout time.Duration) error {
487487
start := time.Now()
488-
for time.Now().Add(-timeout).Before(start) {
488+
for timeout == 0 || time.Since(start) < timeout {
489489
if err := p.Ping(); err == nil {
490490
return nil
491491
}
@@ -502,7 +502,7 @@ func (p *Manager) WaitRecoveryDone(timeout time.Duration) error {
502502

503503
start := time.Now()
504504
if maj >= 12 {
505-
for time.Now().Add(-timeout).Before(start) {
505+
for timeout == 0 || time.Since(start) < timeout {
506506
_, err := os.Stat(filepath.Join(p.dataDir, postgresRecoverySignal))
507507
if err != nil && !os.IsNotExist(err) {
508508
return err
@@ -513,7 +513,7 @@ func (p *Manager) WaitRecoveryDone(timeout time.Duration) error {
513513
time.Sleep(1 * time.Second)
514514
}
515515
} else {
516-
for time.Now().Add(-timeout).Before(start) {
516+
for timeout == 0 || time.Since(start) < timeout {
517517
_, err := os.Stat(filepath.Join(p.dataDir, postgresRecoveryDone))
518518
if err != nil && !os.IsNotExist(err) {
519519
return err

0 commit comments

Comments
 (0)