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

nsqd: io.EOF when client-conn is closed #582

Merged
merged 1 commit into from
Aug 8, 2015
Merged

Conversation

mreiferson
Copy link
Member

NSQd does not distinguish io.EOF.
nsq/nsqd/protocol_v2.go

        line, err = client.Reader.ReadSlice('\n')
        if err != nil {
            if atomic.LoadInt32(&client.State) == stateClosing {
                err = nil 
            } else {
                err = fmt.Errorf("failed to read command - %s", err)
            }   
            break
        }

@mreiferson
Copy link
Member

hmmm, I suppose we could consider io.EOF as a benign error (that the other side had closed the connection cleanly)?

thoughts @jehiah

@jehiah
Copy link
Member

jehiah commented May 6, 2015

Well, we do ignore io.EOF when a client sends a CLS command (if i'm reading this right).

I think that's important because it stops the message flow to allow for a clean close. It's unclear what our expected clean close steps are for producer connections. I'd be happy to begin expecting a CLS msg there as well because it's explicit.

@mreiferson mreiferson changed the title NSQd: io.EOF when client-conn is closed nsqd: io.EOF when client-conn is closed May 26, 2015
@mreiferson
Copy link
Member

Circling back to this...

Agreed about the general value of CLS in the consumer case. I don't think there's anything specific about producer vs. consumer here, though. I think @fjjiaboming was just pointing out that we could conceivably not log io.EOF errors under the assumption that they're TCP-level "clean" closes.

@chaosue
Copy link

chaosue commented Aug 7, 2015

producer won't send a "SUB" command before "CLS", then the error "cannot CLS in current state" will be emitted, while the consumer it to send the "SUB" command before "CLS", so no errors will be emitted when the consumer send the "CLS" and close the tcp connection.

@mreiferson
Copy link
Member

Ahh, good point @chaosue

@Dieterbe
Copy link
Contributor

Dieterbe commented Aug 8, 2015

It's really confusing when nsqd logs errors that are actually not errors at all (if Conn was closed cleanly and all req were processed fine)

@mreiferson
Copy link
Member

It's really confusing when nsqd logs errors that are actually not errors at all (if Conn was closed cleanly and all req were processed fine)

I don't think anyone disagrees with improving this, it's just about being able to deterministically identify expected EOF from unexpected.

@mreiferson
Copy link
Member

according to the golang docs:

EOF is the error returned by Read when no more input is available. Functions should return EOF only to signal a graceful end of input. If the EOF occurs unexpectedly in a structured data stream, the appropriate error is either ErrUnexpectedEOF or some other error giving more detail.

RFR @jehiah

@mreiferson
Copy link
Member

no errors in my testing:

[nsqd] 2015/08/08 16:01:27.656116 PROTOCOL(V2): [127.0.0.1:63472] exiting ioloop
[nsqd] 2015/08/08 16:01:27.656275 TOPIC(test): deleting channel tail433788#ephemeral
[nsqd] 2015/08/08 16:01:27.656290 CHANNEL(tail433788#ephemeral): deleting
[nsqd] 2015/08/08 16:01:27.656392 PROTOCOL(V2): [127.0.0.1:63472] exiting messagePump

jehiah added a commit that referenced this pull request Aug 8, 2015
nsqd: io.EOF when client-conn is closed
@jehiah jehiah merged commit c1ea3b6 into nsqio:master Aug 8, 2015
@mreiferson mreiferson deleted the eof_582 branch August 8, 2015 20:15
@mreiferson mreiferson added bug and removed question labels Aug 8, 2015
@ghost
Copy link
Author

ghost commented Aug 9, 2015

@mreiferson Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants