不要怂,就是干,撸起袖子干!

Commit b08b4830 by Daniel Durante

Postgres was having trouble restablishing connections for non-pool clients.

Postgres' connector-manager was only checking to see if this.client was null. We
should have been checking for "readyForQuery" status as well. We now make
this.client null if the connection has an error rather than just maintaining
stale information. This is to ensure that we retry our connection until we can
re-establish a firm connection.

This resolves issue #832 https://github.com/sequelize/sequelize/issues/832
1 parent df2ae8b5
Showing with 3 additions and 2 deletions
......@@ -89,6 +89,7 @@ module.exports = (function() {
if (!!err) {
// release the pool immediately, very important.
done && done(err)
self.client = null
if (err.code) {
switch(err.code) {
......@@ -122,8 +123,8 @@ module.exports = (function() {
this.poolIdentifier = this.pg.pools.getOrCreate(uri)
this.poolIdentifier.connect(connectCallback)
} else {
if (!!this.client) {
connectCallback(null, this.client);
if (!!this.client && this.client.readyForQuery === true) {
connectCallback(null, this.client)
} else {
//create one-off client
this.client = new this.pg.Client(uri)
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!