From ff7563536b0d280c45e76906feecf9ed057fa318 Mon Sep 17 00:00:00 2001 From: yux0 Date: Mon, 6 Feb 2023 23:02:39 -0800 Subject: [PATCH 1/4] Use max join time as start timeout --- temporal/server_impl.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/temporal/server_impl.go b/temporal/server_impl.go index 5568f3a08ec..b516b4f6e7b 100644 --- a/temporal/server_impl.go +++ b/temporal/server_impl.go @@ -146,7 +146,12 @@ func (s *ServerImpl) Stop() error { } func (s *ServerImpl) startServices() error { - ctx, cancel := context.WithTimeout(context.Background(), serviceStartTimeout) + serviceStartMaxTimeout := 3 * s.so.config.Global.Membership.MaxJoinDuration + + if serviceStartMaxTimeout < serviceStartTimeout { + serviceStartMaxTimeout = serviceStartTimeout + } + ctx, cancel := context.WithTimeout(context.Background(), serviceStartMaxTimeout) defer cancel() results := make(chan startServiceResult, len(s.servicesMetadata)) for _, svcMeta := range s.servicesMetadata { From dc37d3ca6404843869ff100f69ffad441ce3a10a Mon Sep 17 00:00:00 2001 From: yux0 Date: Tue, 7 Feb 2023 10:14:13 -0800 Subject: [PATCH 2/4] Add comments --- temporal/server_impl.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/temporal/server_impl.go b/temporal/server_impl.go index b516b4f6e7b..46b660212ca 100644 --- a/temporal/server_impl.go +++ b/temporal/server_impl.go @@ -146,8 +146,9 @@ func (s *ServerImpl) Stop() error { } func (s *ServerImpl) startServices() error { - serviceStartMaxTimeout := 3 * s.so.config.Global.Membership.MaxJoinDuration - + // The membership join time may exceed the configured max join duration. + // Double the service start timeout to make sure there is enough time for start logic. + serviceStartMaxTimeout := 2 * s.so.config.Global.Membership.MaxJoinDuration if serviceStartMaxTimeout < serviceStartTimeout { serviceStartMaxTimeout = serviceStartTimeout } From 3df23155eae8ddaf24507ac79ec37833bf0111f2 Mon Sep 17 00:00:00 2001 From: Yu Xia Date: Tue, 7 Feb 2023 12:05:20 -0800 Subject: [PATCH 3/4] Update temporal/server_impl.go Co-authored-by: David Reiss --- temporal/server_impl.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/temporal/server_impl.go b/temporal/server_impl.go index 46b660212ca..8c1c9bd5a29 100644 --- a/temporal/server_impl.go +++ b/temporal/server_impl.go @@ -148,11 +148,8 @@ func (s *ServerImpl) Stop() error { func (s *ServerImpl) startServices() error { // The membership join time may exceed the configured max join duration. // Double the service start timeout to make sure there is enough time for start logic. - serviceStartMaxTimeout := 2 * s.so.config.Global.Membership.MaxJoinDuration - if serviceStartMaxTimeout < serviceStartTimeout { - serviceStartMaxTimeout = serviceStartTimeout - } - ctx, cancel := context.WithTimeout(context.Background(), serviceStartMaxTimeout) + timeout := util.Max(serviceStartTimeout, 2 * s.so.config.Global.Membership.MaxJoinDuration) + ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() results := make(chan startServiceResult, len(s.servicesMetadata)) for _, svcMeta := range s.servicesMetadata { From 5bf71c66147b50961c559d68d03e325a05668d7b Mon Sep 17 00:00:00 2001 From: yux0 Date: Tue, 7 Feb 2023 12:10:03 -0800 Subject: [PATCH 4/4] Added import --- temporal/server_impl.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/temporal/server_impl.go b/temporal/server_impl.go index 8c1c9bd5a29..f91efb801b4 100644 --- a/temporal/server_impl.go +++ b/temporal/server_impl.go @@ -40,6 +40,7 @@ import ( persistenceClient "go.temporal.io/server/common/persistence/client" "go.temporal.io/server/common/resolver" "go.temporal.io/server/common/resource" + "go.temporal.io/server/common/util" ) type ( @@ -148,7 +149,7 @@ func (s *ServerImpl) Stop() error { func (s *ServerImpl) startServices() error { // The membership join time may exceed the configured max join duration. // Double the service start timeout to make sure there is enough time for start logic. - timeout := util.Max(serviceStartTimeout, 2 * s.so.config.Global.Membership.MaxJoinDuration) + timeout := util.Max(serviceStartTimeout, 2*s.so.config.Global.Membership.MaxJoinDuration) ctx, cancel := context.WithTimeout(context.Background(), timeout) defer cancel() results := make(chan startServiceResult, len(s.servicesMetadata))