Comments (2)
Plus 1
from go-nsq.
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)
- feat: NSQ cluster or public network message synchronization
- v1.2.1 use DeferredPublish publish delay message,delay invalidation HOT 4
- SIngleton Producer HOT 2
- Can you tag v1.0.9 HOT 1
- How to use Command? HOT 1
- Support NSQ in ArgoLabs Dataflow HOT 1
- the tag of v1.0.8, and the file of doc.go line 65, the value name p is error, in fact, it is producer. HOT 2
- Disconnects seem to be quite ungraceful HOT 2
- "go test" fails with "connection refused" HOT 2
- Client doesn't know it's disconnected HOT 2
- Conn cannot execute multiple subscribe commands HOT 1
- error connecting to nsqd - dial tcp 127.0.0.1:4150: connect: connection refused? HOT 1
- An Example of multit-hreaded nsq consuming messages HOT 1
- producer: HTTP response to IDENTIFY causes memory allocation of over 1GB HOT 2
- how to clear data in nsq HOT 1
- MaxAttempts Callback HOT 1
- *: context.Context and timeouts
- How can I limit the queue size?
- NSQ 延时消息最大延迟是多少 一天能能支持吗
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-nsq.