Node-postgres pool.connect becomes unresponsive
up vote
0
down vote
favorite
Hiii,
Recently my elastic beanstalk server have started to become unresponsive and return's 504 gateway timeout. I suspect that my pool.connect is becoming unresponsive and there are no logs reporting error while connecting to pool but it stucks at connecting. My other controllers with no database query works fine.
This goes away when I restart the server but after some time same thing happens.
I making requests this way-
1) database.js
const pg = require("pg")
// setting timestamp for the postgres.
pg.types.setTypeParser(1184, function(stringValue)
console.log(stringValue)
return new Date(Date.parse(Date.parse(stringValue + "+0000")))
)
// configuration for postres for connecting.
const pgConfig =
user: "USER",
database: "DATABASE",
password: "1234",
port: 5432
const pool = new pg.Pool(pgConfig)
module.exports = pool
2) somecontroller.js
const db = require("../database/database")
const constant = require("../utility/constant")
module.exports = function(req, res)
db.connect(function(err, client, done)
if(err)
done()
console.log(constant.error.db.CONNECT_CONSOLE, err)
return res.send(status: constant.status.ERROR, code: constant.error.db.CONNECT)
client.query("QUERY", [UID])
.then(result =>
// Processing this queries and Some other query.....
)
.catch(err =>
console.log(constant.error.db.QUERY_CONSOLE, err)
res.send(status: constant.status.ERROR, code: constant.error.db.QUERY)
)
done()
)
My every controller works in similar fashion.
Thanks,
javascript node.js postgresql rest freeze
add a comment |
up vote
0
down vote
favorite
Hiii,
Recently my elastic beanstalk server have started to become unresponsive and return's 504 gateway timeout. I suspect that my pool.connect is becoming unresponsive and there are no logs reporting error while connecting to pool but it stucks at connecting. My other controllers with no database query works fine.
This goes away when I restart the server but after some time same thing happens.
I making requests this way-
1) database.js
const pg = require("pg")
// setting timestamp for the postgres.
pg.types.setTypeParser(1184, function(stringValue)
console.log(stringValue)
return new Date(Date.parse(Date.parse(stringValue + "+0000")))
)
// configuration for postres for connecting.
const pgConfig =
user: "USER",
database: "DATABASE",
password: "1234",
port: 5432
const pool = new pg.Pool(pgConfig)
module.exports = pool
2) somecontroller.js
const db = require("../database/database")
const constant = require("../utility/constant")
module.exports = function(req, res)
db.connect(function(err, client, done)
if(err)
done()
console.log(constant.error.db.CONNECT_CONSOLE, err)
return res.send(status: constant.status.ERROR, code: constant.error.db.CONNECT)
client.query("QUERY", [UID])
.then(result =>
// Processing this queries and Some other query.....
)
.catch(err =>
console.log(constant.error.db.QUERY_CONSOLE, err)
res.send(status: constant.status.ERROR, code: constant.error.db.QUERY)
)
done()
)
My every controller works in similar fashion.
Thanks,
javascript node.js postgresql rest freeze
When database pools become unresponsive, it's typically caused by connections not being return into the pool or because queries taking a lot of time and the pool size being too small (so at some point, all connections are waiting for a query to finish and new requests are piling up).
– robertklep
Nov 11 at 11:42
@robertklep should i increase pool size??
– Zicsus
Nov 11 at 12:52
I'm just providing some possible reasons why the connections may be timing out. I don't run your app so can't tell specifically which reason (if any) is causing your specific problems. You need to debug your app yourself and rule out things.
– robertklep
Nov 11 at 12:57
@robertklep i found the issue. It was a controller which was not releasing client properly. I still increased the pool size. Thanks for helping though.
– Zicsus
Nov 11 at 16:51
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
Hiii,
Recently my elastic beanstalk server have started to become unresponsive and return's 504 gateway timeout. I suspect that my pool.connect is becoming unresponsive and there are no logs reporting error while connecting to pool but it stucks at connecting. My other controllers with no database query works fine.
This goes away when I restart the server but after some time same thing happens.
I making requests this way-
1) database.js
const pg = require("pg")
// setting timestamp for the postgres.
pg.types.setTypeParser(1184, function(stringValue)
console.log(stringValue)
return new Date(Date.parse(Date.parse(stringValue + "+0000")))
)
// configuration for postres for connecting.
const pgConfig =
user: "USER",
database: "DATABASE",
password: "1234",
port: 5432
const pool = new pg.Pool(pgConfig)
module.exports = pool
2) somecontroller.js
const db = require("../database/database")
const constant = require("../utility/constant")
module.exports = function(req, res)
db.connect(function(err, client, done)
if(err)
done()
console.log(constant.error.db.CONNECT_CONSOLE, err)
return res.send(status: constant.status.ERROR, code: constant.error.db.CONNECT)
client.query("QUERY", [UID])
.then(result =>
// Processing this queries and Some other query.....
)
.catch(err =>
console.log(constant.error.db.QUERY_CONSOLE, err)
res.send(status: constant.status.ERROR, code: constant.error.db.QUERY)
)
done()
)
My every controller works in similar fashion.
Thanks,
javascript node.js postgresql rest freeze
Hiii,
Recently my elastic beanstalk server have started to become unresponsive and return's 504 gateway timeout. I suspect that my pool.connect is becoming unresponsive and there are no logs reporting error while connecting to pool but it stucks at connecting. My other controllers with no database query works fine.
This goes away when I restart the server but after some time same thing happens.
I making requests this way-
1) database.js
const pg = require("pg")
// setting timestamp for the postgres.
pg.types.setTypeParser(1184, function(stringValue)
console.log(stringValue)
return new Date(Date.parse(Date.parse(stringValue + "+0000")))
)
// configuration for postres for connecting.
const pgConfig =
user: "USER",
database: "DATABASE",
password: "1234",
port: 5432
const pool = new pg.Pool(pgConfig)
module.exports = pool
2) somecontroller.js
const db = require("../database/database")
const constant = require("../utility/constant")
module.exports = function(req, res)
db.connect(function(err, client, done)
if(err)
done()
console.log(constant.error.db.CONNECT_CONSOLE, err)
return res.send(status: constant.status.ERROR, code: constant.error.db.CONNECT)
client.query("QUERY", [UID])
.then(result =>
// Processing this queries and Some other query.....
)
.catch(err =>
console.log(constant.error.db.QUERY_CONSOLE, err)
res.send(status: constant.status.ERROR, code: constant.error.db.QUERY)
)
done()
)
My every controller works in similar fashion.
Thanks,
javascript node.js postgresql rest freeze
javascript node.js postgresql rest freeze
edited Nov 11 at 8:11
asked Nov 11 at 7:23
Zicsus
302212
302212
When database pools become unresponsive, it's typically caused by connections not being return into the pool or because queries taking a lot of time and the pool size being too small (so at some point, all connections are waiting for a query to finish and new requests are piling up).
– robertklep
Nov 11 at 11:42
@robertklep should i increase pool size??
– Zicsus
Nov 11 at 12:52
I'm just providing some possible reasons why the connections may be timing out. I don't run your app so can't tell specifically which reason (if any) is causing your specific problems. You need to debug your app yourself and rule out things.
– robertklep
Nov 11 at 12:57
@robertklep i found the issue. It was a controller which was not releasing client properly. I still increased the pool size. Thanks for helping though.
– Zicsus
Nov 11 at 16:51
add a comment |
When database pools become unresponsive, it's typically caused by connections not being return into the pool or because queries taking a lot of time and the pool size being too small (so at some point, all connections are waiting for a query to finish and new requests are piling up).
– robertklep
Nov 11 at 11:42
@robertklep should i increase pool size??
– Zicsus
Nov 11 at 12:52
I'm just providing some possible reasons why the connections may be timing out. I don't run your app so can't tell specifically which reason (if any) is causing your specific problems. You need to debug your app yourself and rule out things.
– robertklep
Nov 11 at 12:57
@robertklep i found the issue. It was a controller which was not releasing client properly. I still increased the pool size. Thanks for helping though.
– Zicsus
Nov 11 at 16:51
When database pools become unresponsive, it's typically caused by connections not being return into the pool or because queries taking a lot of time and the pool size being too small (so at some point, all connections are waiting for a query to finish and new requests are piling up).
– robertklep
Nov 11 at 11:42
When database pools become unresponsive, it's typically caused by connections not being return into the pool or because queries taking a lot of time and the pool size being too small (so at some point, all connections are waiting for a query to finish and new requests are piling up).
– robertklep
Nov 11 at 11:42
@robertklep should i increase pool size??
– Zicsus
Nov 11 at 12:52
@robertklep should i increase pool size??
– Zicsus
Nov 11 at 12:52
I'm just providing some possible reasons why the connections may be timing out. I don't run your app so can't tell specifically which reason (if any) is causing your specific problems. You need to debug your app yourself and rule out things.
– robertklep
Nov 11 at 12:57
I'm just providing some possible reasons why the connections may be timing out. I don't run your app so can't tell specifically which reason (if any) is causing your specific problems. You need to debug your app yourself and rule out things.
– robertklep
Nov 11 at 12:57
@robertklep i found the issue. It was a controller which was not releasing client properly. I still increased the pool size. Thanks for helping though.
– Zicsus
Nov 11 at 16:51
@robertklep i found the issue. It was a controller which was not releasing client properly. I still increased the pool size. Thanks for helping though.
– Zicsus
Nov 11 at 16:51
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53246673%2fnode-postgres-pool-connect-becomes-unresponsive%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
When database pools become unresponsive, it's typically caused by connections not being return into the pool or because queries taking a lot of time and the pool size being too small (so at some point, all connections are waiting for a query to finish and new requests are piling up).
– robertklep
Nov 11 at 11:42
@robertklep should i increase pool size??
– Zicsus
Nov 11 at 12:52
I'm just providing some possible reasons why the connections may be timing out. I don't run your app so can't tell specifically which reason (if any) is causing your specific problems. You need to debug your app yourself and rule out things.
– robertklep
Nov 11 at 12:57
@robertklep i found the issue. It was a controller which was not releasing client properly. I still increased the pool size. Thanks for helping though.
– Zicsus
Nov 11 at 16:51