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

producer: fix write error deadlock #65

Merged
merged 1 commit into from
Jul 20, 2014

Conversation

mreiferson
Copy link
Member

see commit message, fixes nsqio/nsq#408

@mreiferson mreiferson added the bug label Jul 18, 2014
@mreiferson
Copy link
Member Author

this fix is ghetto, but IOErrors are relatively infrequent so it's not a big deal methinks.

alternatively we can split the transaction consumption/WriteCommand work into a separate goroutine and we wouldn't have this issue (but would then need to synchronize access to the outstanding transaction slice)

RFR @jehiah

@jehiah
Copy link
Member

jehiah commented Jul 19, 2014

would making ioErrorChan a buffered channel be a better option?

@jehiah
Copy link
Member

jehiah commented Jul 19, 2014

Got it i see the deadlock with router which could trigger that IOError.

Should the producer router() also goto exit when reading from that channel?

        case <-w.ioErrorChan:
            w.close()

if `WriteCommand` fails, since it only occurs inside the same goroutine
that receives `Delegate` events, the call to `WriteCommand` deadlocks
trying to delegate the `IOError` (which sends to `Producer.ioErrorChan`)

fix it by just closing inline
@mreiferson
Copy link
Member Author

alright, even better... RFR

jehiah added a commit that referenced this pull request Jul 20, 2014
@jehiah jehiah merged commit 1504543 into nsqio:master Jul 20, 2014
@mreiferson mreiferson deleted the producer_deadlock_65 branch July 20, 2014 16:44
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.

2 participants