Skip to content
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
8 changes: 4 additions & 4 deletions db/active_replicator_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func (a *activeReplicatorCommon) _disconnect() error {
return nil
}

// _stop aborts any replicator processes that run outside of a running replication (e.g: async reconnect handling)
// _stop aborts any replicator processes that run outside of a running replication connection (e.g: async reconnect handling, statsreporter)
func (a *activeReplicatorCommon) _stop() {
if a.ctxCancel != nil {
base.TracefCtx(a.ctx, base.KeyReplicate, "cancelling context on activeReplicatorCommon in _stop()")
Expand Down Expand Up @@ -369,8 +369,8 @@ func (a *activeReplicatorCommon) _publishStatus() {
}
}

func (arc *activeReplicatorCommon) startStatusReporter() error {
go func(ctx context.Context) {
func (arc *activeReplicatorCommon) startStatusReporter(ctx context.Context) error {
go func() {
ticker := time.NewTicker(arc.config.CheckpointInterval)
defer ticker.Stop()
for {
Expand All @@ -386,7 +386,7 @@ func (arc *activeReplicatorCommon) startStatusReporter() error {
return
}
}
}(arc.ctx)
}()
return nil
}

Expand Down
8 changes: 4 additions & 4 deletions db/active_replicator_pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ func (apr *ActivePullReplicator) Start(ctx context.Context) error {
logCtx := base.CorrelationIDLogCtx(ctx, apr.config.ID+"-"+string(ActiveReplicatorTypePull))
apr.ctx, apr.ctxCancel = context.WithCancel(logCtx)

if err := apr.startStatusReporter(apr.ctx); err != nil {
return err
}

err := apr._connect()
if err != nil {
_ = apr.setError(err)
Expand Down Expand Up @@ -91,10 +95,6 @@ func (apr *ActivePullReplicator) _connect() error {
base.ErrorfCtx(apr.ctx, "Pull replicator ID:%s running with revocations enabled but target does not support revocations. Sync Gateway 3.0 required.", apr.config.ID)
}

if err := apr.startStatusReporter(); err != nil {
return err
}

apr.setState(ReplicationStateRunning)

return nil
Expand Down
8 changes: 4 additions & 4 deletions db/active_replicator_push.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ func (apr *ActivePushReplicator) Start(ctx context.Context) error {
apr.config.ID+"-"+string(ActiveReplicatorTypePush))
apr.ctx, apr.ctxCancel = context.WithCancel(logCtx)

if err := apr.startStatusReporter(apr.ctx); err != nil {
return err
}

err := apr._connect()
if err != nil {
_ = apr.setError(err)
Expand Down Expand Up @@ -94,10 +98,6 @@ func (apr *ActivePushReplicator) _connect() error {
}
}

if err := apr.startStatusReporter(); err != nil {
return err
}

apr.setState(ReplicationStateRunning)
return nil
}
Expand Down