Why do some Django ORM requests suddenly end with a "Killed" message?

Sometimes when retrieving data from a database either through the python shell or through a python script, the python process dies and one word is printed on the terminal: Killed

That is literally all he says. This only happens with some scripts, but it always happens for these scripts. This happens sequentially with one single query, which takes time to run, as well as with southern migration, which adds several rows, one at a time, to the database.

My initial guess was that one transaction took too long, so I turned on autocommit for Postgres. Failed to resolve the problem.

I checked the Postgres logs and this is the only thing:

2010-08-19 22:06:34 UTC LOG: could not receive data from client: Connection reset by peer

2010-08-19 22:06:34 UTC LOG: unexpected EOF on client connection

I tried a search on Google, but as you would expect, a one-word error message is difficult for Google.

I am using Django 1.2 with Postgres 8.4 on a single cloud VPS cloud Ubuntu 10.4, a fallback configuration for everything.

+7
python django postgresql
source share
2 answers

Only one thing I could think of would automatically kill the process on Linux - the OOM killer. What does it register in the system?

+6
source share

If psycopg is used, the problem is that the db connection does not close.

According to the psycopg docs example:

 # Connect to an existing database >>> conn = psycopg2.connect("dbname=test user=postgres") # Open a cursor to perform database operations >>> cur = conn.cursor() # Close communication with the database >>> cur.close() >>> conn.close() 

Please note that if you deleted the connection (using dbcon.close() or deleted the connection object, you will probably need to commit or roll back, depending on the type of transaction your connection is working with.

See closing docs for more details.

0
source share

All Articles