-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Filebeat shuts down early (stdin + once enabled) #3315
Comments
@maddin2016 Thanks for looking into this. It seems like the stdin harvester is somehow not blocking Start and Stop. |
Hi @ruflin, i think this time i know why it's not working. Here you started the harvester without increment the prospector waitgroup. type ProspectorStdin struct {
harvester *harvester.Harvester
Prospector *Prospector
started bool
}
...
...
func NewProspectorStdin(p *Prospector) (*ProspectorStdin, error) {
prospectorer := &ProspectorStdin{}
prospectorer.Prospector = p
...
...
func (p *ProspectorStdin) Run() {
// Make sure stdin harvester is only started once
if !p.started {
reader, err := p.harvester.Setup()
if err != nil {
logp.Err("Error starting stdin harvester: %s", err)
return
}
p.Prospector.wg.Add(1)
// startHarvester is not run concurrently, but atomic operations are need for the decrementing of the counter
// inside the following go routine
atomic.AddUint64(&p.Prospector.harvesterCounter, 1)
go func() {
defer func() {
atomic.AddUint64(&p.Prospector.harvesterCounter, ^uint64(0))
p.Prospector.wg.Done()
}()
// Starts harvester and picks the right type. In case type is not set, set it to defeault (log)
p.harvester.Harvest(reader)
p.started = true
}()
} shutdown is always waiting for the harvester to be finished. |
LGTM. Can you open a PR with that? |
I think we have been bitten by this while trying to write scripts to automate ingestion of old, archived and compressed log files (eg. We tried various configuration options but AFAIK there is currently no workaround, is that correct? |
We're also seeing this in filebeat 5.5.2. Is this going to be fixed? |
I was experiencing similar problem while running https://github.com/willfarrell/docker-filebeat/blob/master/5-stdin/docker-entrypoint.sh One possible workaround is to use |
For the record, the |
Just upgraded filebeats in latest version And still suffering same bug - sometimes the process filebeat just stops immediately after starting.
And when it's working OK, the same command :
Here is the configuration file used :
registry_file: /var/lib/filebeat/registry output:
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Original investigation in this dicussion: https://discuss.elastic.co/t/filebeat-does-not-exit-on-eof-input-type-stdin/69545/13
Testing with file-based prospectors and stdin, the race did only occur for stdin.
The text was updated successfully, but these errors were encountered: