Skip to content
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

race condition in nsq plugin #1445

Closed
phemmer opened this issue Jul 3, 2016 · 0 comments · Fixed by #1519
Closed

race condition in nsq plugin #1445

phemmer opened this issue Jul 3, 2016 · 0 comments · Fixed by #1519

Comments

@phemmer
Copy link
Contributor

phemmer commented Jul 3, 2016

Bug report

func (n *NSQ) Gather(acc telegraf.Accumulator) error {
var wg sync.WaitGroup
var outerr error
for _, e := range n.Endpoints {
wg.Add(1)
go func(e string) {
defer wg.Done()
outerr = n.gatherEndpoint(e, acc)
}(e)
}

func (n *NSQ) Gather(acc telegraf.Accumulator) error {
    var wg sync.WaitGroup
    var outerr error

    for _, e := range n.Endpoints {
        wg.Add(1)
        go func(e string) {
            defer wg.Done()
            outerr = n.gatherEndpoint(e, acc)
        }(e)
    }

outerr is not protected via a mutex.
Additionally, whichever call to n.gatherEndpoint completes last wins writing to outerr. Meaning if one server fails, stores the error in outerr, but then the second server completes successfully, the first error is lost.

sparrc added a commit that referenced this issue Jul 19, 2016
closes #1439
closes #1440
closes #1441
closes #1442
closes #1443
closes #1444
closes #1445
sparrc added a commit that referenced this issue Jul 19, 2016
closes #1439
closes #1440
closes #1441
closes #1442
closes #1443
closes #1444
closes #1445
sparrc added a commit that referenced this issue Jul 19, 2016
closes #1439
closes #1440
closes #1441
closes #1442
closes #1443
closes #1444
closes #1445
sparrc added a commit that referenced this issue Jul 19, 2016
closes #1439
closes #1440
closes #1441
closes #1442
closes #1443
closes #1444
closes #1445
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant