Closed tsg closed 7 years ago
Stack trace for the moment of error:
runtime/debug.Stack(0x0, 0x0, 0x0)
/usr/local/Cellar/go@1.8/1.8.3/libexec/src/runtime/debug/stack.go:24 +0x79
runtime/debug.PrintStack()
/usr/local/Cellar/go@1.8/1.8.3/libexec/src/runtime/debug/stack.go:16 +0x22
github.com/elastic/beats/filebeat/prospector/log.(*Prospector).loadStates(0xc42024ec00, 0xc42024ea80, 0x3, 0x3, 0x0, 0x0)
/Users/tsg/src/github.com/elastic/beats/filebeat/prospector/log/prospector.go:126 +0x2cc
github.com/elastic/beats/filebeat/prospector/log.NewProspector(0xc4204a2360, 0xc42046d380, 0xc42024ea80, 0x3, 0x3, 0xc4202e6780, 0xc42046ef60, 0x4, 0x3, 0x3, ...)
/Users/tsg/src/github.com/elastic/beats/filebeat/prospector/log/prospector.go:103 +0x494
github.com/elastic/beats/filebeat/prospector.New(0xc4204a2360, 0xc42046d380, 0xc42046ef60, 0xc42024ea80, 0x3, 0x3, 0xc420455f20, 0x0, 0x0)
/Users/tsg/src/github.com/elastic/beats/filebeat/prospector/prospector.go:72 +0x2c0
github.com/elastic/beats/filebeat/fileset.(*Factory).Create(0xc4204a78f0, 0xc4200114a0, 0xc420019680, 0x1, 0x1, 0x1)
/Users/tsg/src/github.com/elastic/beats/filebeat/fileset/factory.go:67 +0x22b
github.com/elastic/beats/libbeat/cfgfile.(*Reloader).Check(0xc420460e60, 0x2176620, 0xc4204a78f0, 0x3, 0x3)
/Users/tsg/src/github.com/elastic/beats/libbeat/cfgfile/reload.go:117 +0x2ba
github.com/elastic/beats/filebeat/crawler.(*Crawler).Start(0xc4203577a0, 0xc42046f2c0, 0x0, 0xc4203d9ef0, 0xc42046d5c0, 0x0, 0x0)
/Users/tsg/src/github.com/elastic/beats/filebeat/crawler/crawler.go:71 +0x3d3
github.com/elastic/beats/filebeat/beater.(*Filebeat).Run(0xc420466e60, 0xc4200d65a0, 0x0, 0x0)
/Users/tsg/src/github.com/elastic/beats/filebeat/beater/filebeat.go:231 +0xa58
github.com/elastic/beats/libbeat/cmd/instance.(*Beat).launch(0xc4200d65a0, 0x1c0ddc0, 0x0, 0x0)
/Users/tsg/src/github.com/elastic/beats/libbeat/cmd/instance/beat.go:272 +0x364
github.com/elastic/beats/libbeat/cmd/instance.Run.func1(0x1bcbeed, 0x8, 0x1bcbeed, 0x8, 0x0, 0x0, 0x1c0ddc0, 0x0, 0xc420219d18)
/Users/tsg/src/github.com/elastic/beats/libbeat/cmd/instance/beat.go:123 +0xa8
github.com/elastic/beats/libbeat/cmd/instance.Run(0x1bcbeed, 0x8, 0x1bcbeed, 0x8, 0x0, 0x0, 0x1c0ddc0, 0x0, 0x0)
/Users/tsg/src/github.com/elastic/beats/libbeat/cmd/instance/beat.go:124 +0x71
github.com/elastic/beats/libbeat/cmd.genRunCmd.func1(0xc420303b80, 0xc4203baa60, 0x0, 0x2)
/Users/tsg/src/github.com/elastic/beats/libbeat/cmd/run.go:19 +0x60
github.com/elastic/beats/vendor/github.com/spf13/cobra.(*Command).execute(0xc420303b80, 0xc420010130, 0x2, 0x2, 0xc420303b80, 0xc420010130)
/Users/tsg/src/github.com/elastic/beats/vendor/github.com/spf13/cobra/command.go:651 +0x23a
github.com/elastic/beats/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc420303b80, 0x1bcbeed, 0x0, 0x0)
/Users/tsg/src/github.com/elastic/beats/vendor/github.com/spf13/cobra/command.go:726 +0x339
github.com/elastic/beats/vendor/github.com/spf13/cobra.(*Command).Execute(0xc420303b80, 0xc4200001a0, 0xc4200001a0)
/Users/tsg/src/github.com/elastic/beats/vendor/github.com/spf13/cobra/command.go:685 +0x2b
main.main()
/Users/tsg/src/github.com/elastic/beats/filebeat/main.go:18 +0x2f
2017/10/11 15:24:59.227265 factory.go:69: ERR Error creating prospector: Can only start a prospector when all related states are finished: {Id: Finished:false Fileinfo:0xc4204a4270 Source:/var/log/system.log Offset:114839 Timestamp:2017-10-11 17:24:59.222944684 +0200 CEST TTL:-1ns Type:log FileStateOS:3165813-16777220}. Prospector: &{0xc4204a2360 {{log} {1000000000 2 10000000000 300000000000 true false false 0} 0 true [{0xc420250c80}] 0 [/var/log/system.log* /var/log/system.log*] 10000000000 true 0 false false false 16384 asc [] [] 10485760 0xc4200eec00 <nil>} 0xc4204a6c30 0xc4200eea80 0xc4204a6bd0 0xc4203e6800 0xc4202e6780}
It's not the exact same run as before, but in similar conditions.
I reproduced this, it looks like prospectors are created several times? It doesn't happen if you enable both modules (nginx & system) and run with filebeat -e
, still looking for the root cause, but may be close to the logic of module overrides
The general problem is that we create a module registry twice and part of the module registry is to read from the command line flags. So the problem is triggered as soon as there is any module loaded through the command line and a module is already enabled in the config file.
The first time a module registry is created can be found here:
The second time the registry is created is in the factory which is triggered when they are enabled config modules:
Unfortunately the module registry in both cases reads the command line flags from the client. So first the system module is loaded and then again loaded with the second registry creation as a file on disk exists.
In general I think there should be only module registry to make sure entries are unique and make sure the modules from the command line are only read once on startup.
I will further investigate a fix.
Version: 6.0.0-rc1 and master
Operating System: darwin
Steps to Reproduce:
./filebeat modules enabled nginx
./filebeat -e -modules=system -d "*"
It doesn't happen everytime, but quite often this breaks with the following error:
Full debug logs:
Registry file contents after the above run: