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

Connection doesn't automatically close #368

Open
Sven65 opened this issue Jan 10, 2018 · 4 comments
Open

Connection doesn't automatically close #368

Sven65 opened this issue Jan 10, 2018 · 4 comments

Comments

@Sven65
Copy link

Sven65 commented Jan 10, 2018

Using the connection pool in an app that pulls data from a RDB server based on user activity doesn't work as intented.

The library inflates the connection pool to the extremes making the application crash due to a TCP Read error by never closing the connection after the query has been ran.

@mxstbr
Copy link

mxstbr commented Dec 5, 2018

This is biting us in the butt really hard right now in production, has anybody found a workaround?

@mxstbr
Copy link

mxstbr commented Dec 5, 2018

This code is very suspicious:

rethinkdbdash/lib/pool.js

Lines 159 to 169 in 7421553

/*
// We let the pool garbage collect these connections
else if (self.getAvailableLength()+1 > self.options.buffer) { // +1 for the connection we may put back
// Note that because we have available connections here, the pool master has no pending
// queries.
connection.close().error(function(error) {
self._log('Fail to properly close a connection. Error:'+JSON.stringify(error));
});
clearTimeout(connection.timeout);
}
*/

Maybe that's the culprit?

@benfletcher
Copy link

benfletcher commented Feb 8, 2019

FWIW, Spectrum.chat forked rethinkdbdash for the apparent sole purpose of uncommenting that code:

withspectrum/spectrum@245aeae

The source for the fork is not on Github and only on npm. Doing a diff, the only other difference I saw was the addition of an .npmignore file and resulting absence of node_modules in the package.

The forked package is rethinkhaberdashery.

@mxstbr
Copy link

mxstbr commented Feb 8, 2019

That is correct, that was us! 👍 Feel free to use the package, but it is unlikely we will do any more maintenance on it.

The real fix in our case was to limit the number of connections much lower than the defaults and making the buffer and max connections the same amount to avoid constantly opening and closing connections. We also talked with our DB hosting provider (compose.io) to make sure we were not exceeding the max amount of connections their proxy could handle (2000).

https://github.com/withspectrum/spectrum/blob/alpha/shared/db/db.js#L12-L19

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

No branches or pull requests

3 participants