Giter VIP home page Giter VIP logo

Comments (2)

shachardevops avatar shachardevops commented on August 23, 2024

Plus 1

from go-nsq.

ploxiln avatar ploxiln commented on August 23, 2024

I'm not too surprised there's a bug in this part of the codebase, it's not heavily used by the original developers. I think the original devs mostly either publish only to localhost on each server that produces messages, in some cases with this library but in other cases just using http from a service written in a different language, or through an http load balancer to a small cluster of nsqd (thus via http). The Consumer code is much more heavily used.

I don't think gotos, goroutines, or races are involved in this. Each Producer starts one goroutine, running Producer.router(), which runs for the life of that Producer. (One more short-lived goroutine is started in Producer.close() when the producer is done.) The two goto you can see in router() are exactly equivalent of a break to label of the outer for (and the Producer exits at that point, and can no longer hit this panic).

Only the single router() goroutine started by a particular Producer will append or pop from the transactions slice, there is no concurrent access.

The bug might simply be that this code assumes that onConnError() can only be called in relation to an in-flight transaction. But if it is called when zero transactions are in flight, you'll get this panic. It actually looks like that shouldn't happen, it should only be called for an error reply message from the server, which should correspond to a sent message ... but of course it should be robust against seeming to get bytes from the server that look like some kind of reply when there are is no transaction in flight (and then close the Producer because message send/recv is out of sync).

I'll open a quick PR. If you can provide a reproducer script, or validate that the PR makes a noticeable difference in your infrastructure (confirming the hypothesis), that would be helpful. Here it is: #346

from go-nsq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.