Skip to content

Commit

Permalink
Merge pull request #752 from sgotti/sync_timeout_disabled_by_default
Browse files Browse the repository at this point in the history
cluster: make DefaultSyncTimeout infinite.
  • Loading branch information
sgotti authored Jan 22, 2020
2 parents 2ae5e0f + 709a3d0 commit d2f4a09
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion internal/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const (
DefaultRequestTimeout = 10 * time.Second
DefaultConvergenceTimeout = 30 * time.Second
DefaultInitTimeout = 5 * time.Minute
DefaultSyncTimeout = 30 * time.Minute
DefaultSyncTimeout = 0
DefaultFailInterval = 20 * time.Second
DefaultDeadKeeperRemovalInterval = 48 * time.Hour
DefaultMaxStandbys uint16 = 20
Expand Down
8 changes: 4 additions & 4 deletions internal/postgresql/postgresql.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ func (p *Manager) start(args ...string) error {
// Wait for the correct pid file to appear or for the process to exit
ok := false
start := time.Now()
for time.Now().Add(-startTimeout).Before(start) {
for time.Since(start) < startTimeout {
fh, err := os.Open(filepath.Join(p.dataDir, "postmaster.pid"))
if err == nil {
scanner := bufio.NewScanner(fh)
Expand Down Expand Up @@ -485,7 +485,7 @@ func (p *Manager) Restart(fast bool) error {

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

start := time.Now()
if maj >= 12 {
for time.Now().Add(-timeout).Before(start) {
for timeout == 0 || time.Since(start) < timeout {
_, err := os.Stat(filepath.Join(p.dataDir, postgresRecoverySignal))
if err != nil && !os.IsNotExist(err) {
return err
Expand All @@ -513,7 +513,7 @@ func (p *Manager) WaitRecoveryDone(timeout time.Duration) error {
time.Sleep(1 * time.Second)
}
} else {
for time.Now().Add(-timeout).Before(start) {
for timeout == 0 || time.Since(start) < timeout {
_, err := os.Stat(filepath.Join(p.dataDir, postgresRecoveryDone))
if err != nil && !os.IsNotExist(err) {
return err
Expand Down

0 comments on commit d2f4a09

Please sign in to comment.