Pulkit Sharma
Pulkit Sharma

Reputation: 262

Postgres not responding with high waiting time

I am using Django with Postgres. My site servers half a million pages without any issue and everything works fine.

However I am using an API system and it works like below:

First party calls my site with API, my site gets data from third website using API. My site extracts some data and pass it to First party. It works perfectly. In this cycle I have to check my Postgres whether data is already present or not.

Everything works fine. But if third party API does not respond or there is any server issue with third party it takes long time to respond with 404 error, my postgres just dies and I have to run service postgresql restart command everytime to site work.

What could be the issue? How do I check why Postgres is dying?

Upvotes: 0

Views: 1401

Answers (1)

mhawke
mhawke

Reputation: 87124

One possibility, although a guess, is that your code is locking the database table while the 3rd party API call is made. This will prevent other updates occurring while waiting.

This wouldn't explain why you would need to restart the Postgres server, the lock should be released after the 3rd party API call times out.

It might help to add to your question the code that deals with checking whether the data is already present in the db, calling the remote API, and finally updating the database with new data.

Upvotes: 1

Related Questions