Skip to content
This repository has been archived by the owner on Dec 30, 2019. It is now read-only.

pool not timing out/idling #99

Open
InsidiousForce opened this issue Apr 11, 2018 · 1 comment
Open

pool not timing out/idling #99

InsidiousForce opened this issue Apr 11, 2018 · 1 comment

Comments

@InsidiousForce
Copy link

InsidiousForce commented Apr 11, 2018

                            user: db_username,
                            password: db_password,
                            host: db_host,
                            port: db_port',
                            database: db_schema,
                            max: 10, // set pool max size to 10
                            min: 0, // set min pool size to 0
                            idleTimeoutMillis: 10000, // close idle clients after 10 seconds
                            softIdleTimeoutMillis: 10000,
                            evictionRunIntervalMillis: 10000

No matter what we change the values of the last 5 items to (I added the last 2 after no love on the idleTimeoutMills by itself) there is always 1 idle connection to the database left open. Days and days go by and there is still one idle connection left open to the database server. Is there a way to have the pool clean up idle connections down to 0?

Here's the code we're using, Database.connections[host].connection is as above.

Pool init:

    Database.pool = new Pool( Database.connections[host].connection );

    Database.pool.on( 'error', (error, client) => {
        console.log( 'Pool connection error', error );
    });

    Database.pool.connect()
        .then( () => {
            console.log( `Connected to host ${host}.`);
            console.log( JSON.stringify( Database.connections[host] ) );
        })
        .catch( error => {
            console.log( `Error Connecting to host ${host}, retrying in 5 seconds...` );
            console.log( JSON.stringify(error) );
            setTimeout( setConnection, 5000 );
        });
}

Queries:

Database.pool.query( SqlQueries.SetUserSetting, params )
            .then( result => {
                Database.GetUserSetting(userid, key, nodes, callback.bind(this));
            })
            .catch( error => {
                callback({success: false, data: error});
            });
@charmander
Copy link
Collaborator

No matter what we change the values of the last 5 items to (I added the last 2 after no love on the idleTimeoutMills by itself) there is always 1 idle connection to the database left open. Days and days go by and there is still one idle connection left open to the database server.

How are you checking? Are you sure it doesn’t come from somewhere else?

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

No branches or pull requests

2 participants