Skip to content

Commit 4698e5d

Browse files
[9.3](backport #51864) managerEarlyStop before runReady close (#51870)
* managerEarlyStop before runReady close (#51864) (cherry picked from commit 00068f7) # Conflicts: # filebeat/beater/filebeat.go * fix merge conflicts --------- Co-authored-by: Lee E Hinman <57081003+leehinman@users.noreply.github.com> Co-authored-by: Lee E. Hinman <lee.e.hinman@elastic.co>
1 parent 8dc0849 commit 4698e5d

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

filebeat/beater/filebeat.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,14 @@ func (fb *Filebeat) Run(b *beat.Beat) error {
306306
}
307307
}()
308308

309+
// Close runReady so that Stop does not block waiting for Run to reach its
310+
// ready state, regardless of how Run exits. This must be deferred after
311+
// the managerEarlyStop defer above so that it runs first in LIFO order:
312+
// managerEarlyStop calls Stop, which waits on runReady.ch, so runReady
313+
// must be closed before Stop is called to avoid a 5-second timeout on
314+
// every early-exit error path.
315+
defer fb.runReady.Close()
316+
309317
registryMigrator := registrar.NewMigrator(config.Registry, fb.logger, b.Info.Paths)
310318
if err := registryMigrator.Run(); err != nil {
311319
fb.logger.Errorf("Failed to migrate registry file: %+v", err)

0 commit comments

Comments
 (0)