{"action":"opened","issue":{"url":"https://api.github.com/repos/tgriesser/knex/issues/975","labels_url":"https://api.github.com/repos/tgriesser/knex/issues/975/labels{/name}","comments_url":"https://api.github.com/repos/tgriesser/knex/issues/975/comments","events_url":"https://api.github.com/repos/tgriesser/knex/issues/975/events","html_url":"https://github.com/tgriesser/knex/issues/975","id":106274625,"number":975,"title":"Default pool2 configuration often leads to errors","user":{"login":"acgourley","id":7680,"avatar_url":"https://avatars.githubusercontent.com/u/7680?v=3","gravatar_id":"","url":"https://api.github.com/users/acgourley","html_url":"https://github.com/acgourley","followers_url":"https://api.github.com/users/acgourley/followers","following_url":"https://api.github.com/users/acgourley/following{/other_user}","gists_url":"https://api.github.com/users/acgourley/gists{/gist_id}","starred_url":"https://api.github.com/users/acgourley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acgourley/subscriptions","organizations_url":"https://api.github.com/users/acgourley/orgs","repos_url":"https://api.github.com/users/acgourley/repos","events_url":"https://api.github.com/users/acgourley/events{/privacy}","received_events_url":"https://api.github.com/users/acgourley/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-14T05:41:22Z","updated_at":"2015-09-14T05:41:22Z","closed_at":null,"body":"I recently ran into hair-pulling errors using knex with google cloud SQL. The issue was that GCS was closing idle connections in the pool, however by default pool2 was not testing the connections effectively before trying to use them. \r\n\r\nThere are two possible solutions, and I would suggest the default config does one of the following: \r\n\r\n### Option 1 - don't keep idle connections around. \r\n```\r\n  client: 'mysql',\r\n  pool: {\r\n    min: 0\r\n  }\r\n  ...\r\n}\r\n```\r\n###  Option 2 - effectively test connections (may be database specific)\r\n```\r\n  client: 'mysql',\r\n  pool: {\r\n    min: 2,\r\n    max: 10,\r\n    ping: function (conn, cb) { conn.query('SELECT 1', cb); }  }\r\n  ...\r\n}\r\n```"}}