Skip to content

PROTOCOL_CONNECTION_LOST during streaming query #566

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

Closed
cheyner opened this issue Aug 7, 2013 · 1 comment
Closed

PROTOCOL_CONNECTION_LOST during streaming query #566

cheyner opened this issue Aug 7, 2013 · 1 comment
Assignees
Labels

Comments

@cheyner
Copy link

cheyner commented Aug 7, 2013

I'm using version 2.0.0-alpha8 and node v0.10.11 and am experiencing an issue where I'm getting a lost connection error while streaming the results of a query.

I realize there are a number of issues relating to lost connections. And I've seen solutions like connection.ping() to avoid an idle connection timeout, or connection.on('error') handlers to re-establish a severed connection. Because my problem happens while a query is running, this seems like a different scenario than others have reported.

I am creating a fileWriteStream and piping the results of the SQL query into that writestream. I also have a CsvPrepStream in the pipeline which transforms the data object into a string of text suitable for a CSV.

This process runs just fine with ~200k or fewer results in the sql query. Bigger query results, however, cause the PROTOCOL_CONNECTION_LOST error after a minute or so.

I realize this doesn't give the full context of what's going on, but should give an idea:

var query = me.connection.query({
    sql: me.query,
    nestTables: true
})
    .stream({
        highWaterMark: 20
    })
    .pipe(new CsvPrepStream(
        {objectMode: true},
        me.fields
    ))
    .pipe(me.fileStream);
@Jimbly
Copy link

Jimbly commented Aug 10, 2015

I have been getting this error in a similar situation - in my case that gets this error, the time to process a row far exceeds the time for MySQL to send it to me (the network-level buffers are almost always full and the stream is almost always paused), and I usually get this error after 3-5 minutes (even though all MySQL timeouts are set to hours and, as far as I can tell, OS-level network/TCP timeouts are set to hours, and I even set .setKeepAlive on the TCP stream to MySQL, though I still suspect some OS-level timeout must be happening). In my case I just worked around it by catching the error and issuing a new query that starts where the old one left off (though that's not guaranteed to get the same results, since new things may have been written), but this would be good to investigate at some point.

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

No branches or pull requests

3 participants