telegraf icon indicating copy to clipboard operation
telegraf copied to clipboard

(Bug Report) Shared WaitGroup in Exec plugin

Open allen13 opened this issue 10 years ago • 5 comments

Bug report

The exec plugin gather function is relying on an instance shared WaitGroup which causes the gather function to hang indefinitely when run concurrently. This does not affect the current code base since the agent waits for gather to finish before kicking off a new one. I stumbled upon this while addressing an in-house requirement for gathers to kick off regardless of whether or not the previous one has finished.

allen13 avatar Jul 07 '16 14:07 allen13

Submitted pull request 1464 to address the issue.

allen13 avatar Jul 07 '16 14:07 allen13

This does not affect the current code base since the agent waits for gather to finish before kicking off a new one

Then why is this an issue? Seems like a bug report for a bug that can't happen :-)

phemmer avatar Jul 08 '16 22:07 phemmer

Just addressing unsafe code. The waitGroup belongs in the gather function not in the struct instance.

allen13 avatar Jul 08 '16 22:07 allen13

@allen13 why is the code unsafe?

sparrc avatar Jul 14 '16 21:07 sparrc

@sparrc The wait group is unnecessarily sharing its state between Gather executions. Should a previous gather fail to close it's waitgroup, future Gathers will hang indefinitely. Creating a new waitGroup instance for each Gather guarantees isolation.

allen13 avatar Jul 14 '16 22:07 allen13