Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support delay before history joins membership #4582

Merged
merged 1 commit into from
Jul 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions common/dynamicconfig/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@ const (
HistoryCacheMaxSize = "history.cacheMaxSize"
// HistoryCacheTTL is TTL of history cache
HistoryCacheTTL = "history.cacheTTL"
// HistoryStartupMembershipJoinDelay is the duration a history instance waits
// before joining membership after starting.
HistoryStartupMembershipJoinDelay = "history.startupMembershipJoinDelay"
// HistoryShutdownDrainDuration is the duration of traffic drain during shutdown
HistoryShutdownDrainDuration = "history.shutdownDrainDuration"
// EventsCacheInitialSize is initial size of events cache
Expand Down
12 changes: 7 additions & 5 deletions service/history/configs/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,12 @@ type Config struct {
VisibilityDisableOrderByClause dynamicconfig.BoolPropertyFnWithNamespaceFilter
VisibilityEnableManualPagination dynamicconfig.BoolPropertyFnWithNamespaceFilter

EmitShardLagLog dynamicconfig.BoolPropertyFn
MaxAutoResetPoints dynamicconfig.IntPropertyFnWithNamespaceFilter
ThrottledLogRPS dynamicconfig.IntPropertyFn
EnableStickyQuery dynamicconfig.BoolPropertyFnWithNamespaceFilter
ShutdownDrainDuration dynamicconfig.DurationPropertyFn
EmitShardLagLog dynamicconfig.BoolPropertyFn
MaxAutoResetPoints dynamicconfig.IntPropertyFnWithNamespaceFilter
ThrottledLogRPS dynamicconfig.IntPropertyFn
EnableStickyQuery dynamicconfig.BoolPropertyFnWithNamespaceFilter
ShutdownDrainDuration dynamicconfig.DurationPropertyFn
StartupMembershipJoinDelay dynamicconfig.DurationPropertyFn

// HistoryCache settings
// Change of these configs require shard restart
Expand Down Expand Up @@ -334,6 +335,7 @@ func NewConfig(
EnablePersistencePriorityRateLimiting: dc.GetBoolProperty(dynamicconfig.HistoryEnablePersistencePriorityRateLimiting, true),
PersistenceDynamicRateLimitingParams: dc.GetMapProperty(dynamicconfig.HistoryPersistenceDynamicRateLimitingParams, dynamicconfig.DefaultDynamicRateLimitingParams),
ShutdownDrainDuration: dc.GetDurationProperty(dynamicconfig.HistoryShutdownDrainDuration, 0*time.Second),
StartupMembershipJoinDelay: dc.GetDurationProperty(dynamicconfig.HistoryStartupMembershipJoinDelay, 0*time.Second),
MaxAutoResetPoints: dc.GetIntPropertyFilteredByNamespace(dynamicconfig.HistoryMaxAutoResetPoints, DefaultHistoryMaxAutoResetPoints),
DefaultWorkflowTaskTimeout: dc.GetDurationPropertyFilteredByNamespace(dynamicconfig.DefaultWorkflowTaskTimeout, common.DefaultWorkflowTaskTimeout),
ContinueAsNewMinInterval: dc.GetDurationPropertyFilteredByNamespace(dynamicconfig.ContinueAsNewMinInterval, time.Second),
Expand Down
12 changes: 11 additions & 1 deletion service/history/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,17 @@ func (s *Service) Start() {
// that we own. Ideally, then, we would start the GRPC server, and only then
// join membership. That's not possible with the GRPC interface, though, hence
// we start membership in a goroutine.
go s.membershipMonitor.Start()
go func() {
if delay := s.config.StartupMembershipJoinDelay(); delay > 0 {
// In some situations, like rolling upgrades of the history service,
// pausing before joining membership can help separate the shard movement
// caused by another history instance terminating with this instance starting.
logger.Info("history start: delaying before membership start",
tag.NewDurationTag("startupMembershipJoinDelay", delay))
time.Sleep(delay)
}
s.membershipMonitor.Start()
}()

logger.Info("Starting to serve on history listener")
if err := s.server.Serve(s.grpcListener); err != nil {
Expand Down