Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do some Django ORM queries end abruptly with the message "Killed"?

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

That's literally all it says. It only happens with certain scripts, but it always happens for those scripts. It consistently happens with this one single query that takes a while to run, and also with a south migration that adds a bunch of rows one-by-one to the database.

My initial hunch was that a single transaction was taking too long, so I turned on autocommit for Postgres. Didn't solve the problem.

I checked the Postgres logs, and this is the only thing in there:

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've tried googling, but as you might expect, a one-word error message is tough to google for.

I'm using Django 1.2 with Postgres 8.4 on a single Ubuntu 10.4 rackspace cloud VPS, stock config for everything.

like image 648
Zain Avatar asked Aug 19 '10 22:08

Zain


People also ask

Is Django QuerySet lazy?

This is because a Django QuerySet is a lazy object. It contains all of the information it needs to populate itself from the database, but will not actually do so until the information is needed.

Is Django ORM slow?

Django's ORM is fantastic. It's slow because it chooses to be convenient but if it needs to be fast it's just a few slight API calls away. If you're curious, check out the code on Github.

What is Django's ORM?

One of the most powerful features of Django is its Object-Relational Mapper (ORM), which enables you to interact with your database, like you would with SQL. In fact, Django's ORM is just a pythonical way to create SQL to query and manipulate your database and get results in a pythonic fashion.


1 Answers

Only one thing I could think of that will kill automatically a process on Linux - the OOM killer. What's in the system logs?

like image 178
Milen A. Radev Avatar answered Sep 28 '22 15:09

Milen A. Radev