django admin + apache + mod_python => breakage

2007-07-28 Thread Bram - Smartelectronix

hello everyone,


I have a rather "well connected" model like this ( used here: 
http://www.splicemusic.com/contests/ ):

class Contest(models.Model):
 [ snip of regular fields ]

 # the sounds people HAVE to use to enter the contest
 required_sounds = models.ManyToManyField(Sound, null=True,
   blank=True)

 # the soungs people HAVE to use to enter the contest
 required_songs = models.ManyToManyField(Song, null=True, blank=True)

 # how they should tag theior sounds to enter the competition
 sound_tag = models.ForeignKey('Tag',
 related_name=u'contest_sound_set')

 # how they should tag their song to enter the competition
 song_tag = models.ForeignKey('Tag',
related_name=u'contest_song_set')

 # the winners of the contes if it's already finished
 winners = models.ManyToManyField(Profile, null=True, blank=True)

 # a forum thread w/ more explanations
 forum_thread = models.ForeignKey(Thread, null=True, blank=True)


As you can see, quite a lot of many-to-many and foreign keys in there 
(and they all point to tables with over 30K entries, so the admin page 
takes about 10 minutes to load). Now, when we try to edit this model in 
the admin the apache instance goes nuts and starts eating ALL the memory 
on the machine: it almost immediately jumps to 1.5GB of RAM and then 
just keeps consuming until the kernell kills the process.

Does anyone have an idea why this could be?? No other models in our 
application show this behaviour (then again, no other model has this 
many connections to the rest of the models)

Editing the model via manage.py shell works just fine.


  - bram

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: admin apache solved? / now mysql problem

2006-03-29 Thread abe


Andy Dustman wrote:
> On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
> > Andy Dustman wrote:
> > > On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
> > > > Andy Dustman wrote:
> > > > > On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
> > > > >
> > > > > > OperationalError: (2002, "Can't connect to local MySQL server 
> > > > > > through
> > > > > > socket '/var/lib/mysql/mysql.sock' (13)")
> > > > >
> > > > > This indicates your MySQL server isn't running,
> > > > I think it is, since the admin site works fine if I use
> > > > manage.py runserver , doesn't it also use the server?
> > > >
> > > > %myproject]# ps -eadf|grep sql
> > > > root 18240 18044  0 12:32 pts/200:00:00 /bin/sh
> > > > /usr/bin/mysqld_safe
> > > > mysql18268 18240  0 12:32 pts/200:00:00 /usr/libexec/mysqld
> > > > --basedir=/usr --datadir=/var/lib/mysql --user=mysql
> > > > --pid-file=/var/run/mysqld/mysqld.pid --skip-locking
> > > > --socket=/var/lib/mysql/mysql.sock
> > > >
> > > > unless 'MYSQL server' means somthing different from mysqld ??
> > > >
> > > >
> > > > > and you are using DATABASE_HOST="localhost".
> > > > well I use ='', but that should be the same
> > > >
> > > > but isn't that correct, since mysqld runs on the same host as django?
> > >
> > > Make sure apache can read /var/ilbmysql/mysql.sock. I'm a little
> > how do I do that? I can't 'become' apache
> > from the permissions it looks readable
> >
> > myproject$ ls -lst /var/lib/mysql/mysql.sock
> > 4 srwxrwxrwx  1 mysql mysql 0 Mar 28 12:32 /var/lib/mysql/mysql.sock
> > myproject$ ls -lst /tmp/mysql.sock
>
> But is the parent directory world-readable? i.e. ls -ld /var/lib/mysql

looks so:
ls -ld /var/lib/mysql
drwxr-xr-x  5 mysql mysql 4096 Mar 29 10:30 /var/lib/mysql


> > there a link to it in /tmp :
> > 4 lrwxrwxrwx  1 mysql mysql 25 Mar 23 16:58 /tmp/mysql.sock ->
> > /var/lib/mysql/mysql.sock
> > [EMAIL PROTECTED] myproject]$
> >
> > > surprised to see it put the socket there, since (on Gentoo)
> > > /var/lib/mysql is only accessible by the user the mysql server runs
> > > as, so it puts the socket (which needs to be world-readable and
> > > writable) in /var/run.
> >
> > >
> > > When you run manage.py runserver, are you running as root?
> > yes (should I?), but I can also run as myself, doesn't matter
>
> You probably shoudn't run it as root on general principle. Make sure
> you can access it as a non-root user. The error indicates it did not
> get as far as the authentication phase so I am still leaning towards
> filesystem permissions.

> You're not running a chroot apache by any chance, are you?
not that I know, but I didn't setup the system myself.
how do I to find out?

> SELinux? Some sort of virtualization?
idem. it's a scientific linux installlation (RHEL-like), I saw the
selinux libraries are installed.

> I guess you could try 127.0.0.1 for the database host which will make it use 
> TCP
> and see if that makes a difference.

Ah, that helped!
but I also had to change the mysqld that I'm running
from  /usr/bin/mysqld_safe (mysql 4) to
/usr/local/mysql/bin/mysqld_safe (mysql 5)

although the sockets they use are the same, and I still use mysqldb
that is
compiled with the mysql.h from mysql4

I can login to the admin site now, great!
but it seems that the css files are not accessible  because there is no
layout .
I copied the dir
/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/contrib/admin/media/css

to /var/www// (where my project is, wasn't able to use it under my
own dir) but that didn't help

according to the admin page it expects the css in //css :



my settings.py has:
ADMIN_MEDIA_PREFIX = 'zbdb/'



thanks for the help and patience, 

-E


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: admin apache solved? / now mysql problem

2006-03-29 Thread abe


Todd O'Bryan wrote:
> On Mar 28, 2006, at 8:20 AM, Andy Dustman wrote:
> > On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
> >
> >> OperationalError: (2002, "Can't connect to local MySQL server through
> >> socket '/var/lib/mysql/mysql.sock' (13)")
> >
> > This indicates your MySQL server isn't running, and you are using
> > DATABASE_HOST="localhost".
>
> We saw this problem because the mysql.sock file was in /tmp/ instead
> of /var/lib/mysql. A symbolic link from /var/lib/mysql/mysql.sock to /
> tmp/mysql.sock solved the problem.

this is already the case, see my previous post. 

-E


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: admin apache solved? / now mysql problem

2006-03-28 Thread Todd O'Bryan

On Mar 28, 2006, at 8:20 AM, Andy Dustman wrote:

>
> On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
>
>> OperationalError: (2002, "Can't connect to local MySQL server through
>> socket '/var/lib/mysql/mysql.sock' (13)")
>
> This indicates your MySQL server isn't running, and you are using
> DATABASE_HOST="localhost".

We saw this problem because the mysql.sock file was in /tmp/ instead  
of /var/lib/mysql. A symbolic link from /var/lib/mysql/mysql.sock to / 
tmp/mysql.sock solved the problem.

Todd

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: admin apache solved? / now mysql problem

2006-03-28 Thread Andy Dustman

On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
>
>
> Andy Dustman wrote:
> > On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
> > >
> > >
> > > Andy Dustman wrote:
> > > > On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
> > > >
> > > > > OperationalError: (2002, "Can't connect to local MySQL server through
> > > > > socket '/var/lib/mysql/mysql.sock' (13)")
> > > >
> > > > This indicates your MySQL server isn't running,
> > > I think it is, since the admin site works fine if I use
> > > manage.py runserver , doesn't it also use the server?
> > >
> > > %myproject]# ps -eadf|grep sql
> > > root 18240 18044  0 12:32 pts/200:00:00 /bin/sh
> > > /usr/bin/mysqld_safe
> > > mysql18268 18240  0 12:32 pts/200:00:00 /usr/libexec/mysqld
> > > --basedir=/usr --datadir=/var/lib/mysql --user=mysql
> > > --pid-file=/var/run/mysqld/mysqld.pid --skip-locking
> > > --socket=/var/lib/mysql/mysql.sock
> > >
> > > unless 'MYSQL server' means somthing different from mysqld ??
> > >
> > >
> > > > and you are using DATABASE_HOST="localhost".
> > > well I use ='', but that should be the same
> > >
> > > but isn't that correct, since mysqld runs on the same host as django?
> >
> > Make sure apache can read /var/ilbmysql/mysql.sock. I'm a little
> how do I do that? I can't 'become' apache
> from the permissions it looks readable
>
> myproject$ ls -lst /var/lib/mysql/mysql.sock
> 4 srwxrwxrwx  1 mysql mysql 0 Mar 28 12:32 /var/lib/mysql/mysql.sock
> myproject$ ls -lst /tmp/mysql.sock

But is the parent directory world-readable? i.e. ls -ld /var/lib/mysql

> there a link to it in /tmp :
> 4 lrwxrwxrwx  1 mysql mysql 25 Mar 23 16:58 /tmp/mysql.sock ->
> /var/lib/mysql/mysql.sock
> [EMAIL PROTECTED] myproject]$
>
> > surprised to see it put the socket there, since (on Gentoo)
> > /var/lib/mysql is only accessible by the user the mysql server runs
> > as, so it puts the socket (which needs to be world-readable and
> > writable) in /var/run.
>
> >
> > When you run manage.py runserver, are you running as root?
> yes (should I?), but I can also run as myself, doesn't matter

You probably shoudn't run it as root on general principle. Make sure
you can access it as a non-root user. The error indicates it did not
get as far as the authentication phase so I am still leaning towards
filesystem permissions. You're not running a chroot apache by any
chance, are you? SELinux? Some sort of virtualization? I guess you
could try 127.0.0.1 for the database host which will make it use TCP
and see if that makes a difference.
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: admin apache solved? / now mysql problem

2006-03-28 Thread abe


Andy Dustman wrote:
> On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
> >
> >
> > Andy Dustman wrote:
> > > On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
> > >
> > > > OperationalError: (2002, "Can't connect to local MySQL server through
> > > > socket '/var/lib/mysql/mysql.sock' (13)")
> > >
> > > This indicates your MySQL server isn't running,
> > I think it is, since the admin site works fine if I use
> > manage.py runserver , doesn't it also use the server?
> >
> > %myproject]# ps -eadf|grep sql
> > root 18240 18044  0 12:32 pts/200:00:00 /bin/sh
> > /usr/bin/mysqld_safe
> > mysql18268 18240  0 12:32 pts/200:00:00 /usr/libexec/mysqld
> > --basedir=/usr --datadir=/var/lib/mysql --user=mysql
> > --pid-file=/var/run/mysqld/mysqld.pid --skip-locking
> > --socket=/var/lib/mysql/mysql.sock
> >
> > unless 'MYSQL server' means somthing different from mysqld ??
> >
> >
> > > and you are using DATABASE_HOST="localhost".
> > well I use ='', but that should be the same
> >
> > but isn't that correct, since mysqld runs on the same host as django?
>
> Make sure apache can read /var/ilbmysql/mysql.sock. I'm a little
how do I do that? I can't 'become' apache
from the permissions it looks readable

myproject$ ls -lst /var/lib/mysql/mysql.sock
4 srwxrwxrwx  1 mysql mysql 0 Mar 28 12:32 /var/lib/mysql/mysql.sock
myproject$ ls -lst /tmp/mysql.sock

there a link to it in /tmp :
4 lrwxrwxrwx  1 mysql mysql 25 Mar 23 16:58 /tmp/mysql.sock ->
/var/lib/mysql/mysql.sock
[EMAIL PROTECTED] myproject]$

> surprised to see it put the socket there, since (on Gentoo)
> /var/lib/mysql is only accessible by the user the mysql server runs
> as, so it puts the socket (which needs to be world-readable and
> writable) in /var/run.

>
> When you run manage.py runserver, are you running as root?
yes (should I?), but I can also run as myself, doesn't matter

thanks, -E


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: admin apache solved? / now mysql problem

2006-03-28 Thread Andy Dustman

On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
>
>
> Andy Dustman wrote:
> > On 3/28/06, abe <[EMAIL PROTECTED]> wrote:
> >
> > > OperationalError: (2002, "Can't connect to local MySQL server through
> > > socket '/var/lib/mysql/mysql.sock' (13)")
> >
> > This indicates your MySQL server isn't running,
> I think it is, since the admin site works fine if I use
> manage.py runserver , doesn't it also use the server?
>
> %myproject]# ps -eadf|grep sql
> root 18240 18044  0 12:32 pts/200:00:00 /bin/sh
> /usr/bin/mysqld_safe
> mysql18268 18240  0 12:32 pts/200:00:00 /usr/libexec/mysqld
> --basedir=/usr --datadir=/var/lib/mysql --user=mysql
> --pid-file=/var/run/mysqld/mysqld.pid --skip-locking
> --socket=/var/lib/mysql/mysql.sock
>
> unless 'MYSQL server' means somthing different from mysqld ??
>
>
> > and you are using DATABASE_HOST="localhost".
> well I use ='', but that should be the same
>
> but isn't that correct, since mysqld runs on the same host as django?

Make sure apache can read /var/ilbmysql/mysql.sock. I'm a little
surprised to see it put the socket there, since (on Gentoo)
/var/lib/mysql is only accessible by the user the mysql server runs
as, so it puts the socket (which needs to be world-readable and
writable) in /var/run.

When you run manage.py runserver, are you running as root?
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: admin apache solved? / now mysql problem

2006-03-28 Thread Andy Dustman

On 3/28/06, abe <[EMAIL PROTECTED]> wrote:

> OperationalError: (2002, "Can't connect to local MySQL server through
> socket '/var/lib/mysql/mysql.sock' (13)")

This indicates your MySQL server isn't running, and you are using
DATABASE_HOST="localhost".
--
The Pythonic Principle: Python works the way it does
because if it didn't, it wouldn't be Python.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: admin apache solved? / now mysql problem

2006-03-28 Thread abe


Adrian Holovaty wrote:
> On 3/24/06, abe <[EMAIL PROTECTED]> wrote:
> > I get a blank screen (in the browser) and the
> > httpd error logs say :
> >
> > [Fri Mar 24 18:36:09 2006] [notice] mod_python: (Re)importing module
> > 'django.core.handlers.modpython'
> > [Fri Mar 24 18:36:17 2006] [notice] child pid 13817 exit signal
> > Segmentation fault (11)
> >
> > does anybody have an idea what goes wrong?
>
> Hey there,
>
> Check out the Django/mod_python docs for some possible explanations/solutions.
>
> http://www.djangoproject.com/documentation/modpython/#if-you-get-a-segmentation-fault
>
> Adrian

slowly making progress...

I removed mod_php from the httpd.conf
and installed a newer version of MySQLdb (1.0 -> 1.2.0)

It seems to get a bit further (not completely sure about that)
but now mysql gives problems.
If I try to reach te admin site I get the following error message
in the browser window (just plain text, not the django error page
type):

Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

  File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line
299, in HandlerDispatch
result = object(req)

  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/core/handlers/modpython.py",
line 165, in handler
return ModPythonHandler()(req)

  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/core/handlers/modpython.py",
line 145, in __call__
response = middleware_method(request, response)

  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/middleware/sessions.py",
line 74, in process_response
session_key = request.session.session_key or
sessions.get_new_session_key()

  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/models/core.py",
line 110, in _module_get_new_session_key
get_object(session_key__exact=session_key)

  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/utils/functional.py",
line 3, in _curried
return args[0](*(args[1:]+moreargs), **dict(kwargs.items() +
morekwargs.items()))

  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/core/meta/__init__.py",
line 1355, in function_get_object
obj_list = function_get_list(opts, klass, **kwargs)

  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/core/meta/__init__.py",
line 1395, in function_get_list
return list(function_get_iterator(opts, klass, **kwargs))

  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/core/meta/__init__.py",
line 1376, in function_get_iterator
cursor = db.db.cursor()

  File
"/usr/lib/python2.3/site-packages/Django-0.91-py2.3.egg/django/core/db/backends/mysql.py",
line 67, in cursor
self.connection = Database.connect(**kwargs)

  File "/usr/lib/python2.3/site-packages/MySQLdb/__init__.py", line 66,
in Connect
return Connection(*args, **kwargs)

  File "/usr/lib/python2.3/site-packages/MySQLdb/connections.py", line
134, in __init__
super(Connection, self).__init__(*args, **kwargs2)

OperationalError: (2002, "Can't connect to local MySQL server through
socket '/var/lib/mysql/mysql.sock' (13)")


if I use manage.py runserver on the localhost, I get the normal admin
login page.


any idea's how to solve this? I googled for the error message but I
don't find much 
django specific

thanks


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: admin apache

2006-03-24 Thread Adrian Holovaty

On 3/24/06, abe <[EMAIL PROTECTED]> wrote:
> I get a blank screen (in the browser) and the
> httpd error logs say :
>
> [Fri Mar 24 18:36:09 2006] [notice] mod_python: (Re)importing module
> 'django.core.handlers.modpython'
> [Fri Mar 24 18:36:17 2006] [notice] child pid 13817 exit signal
> Segmentation fault (11)
>
> does anybody have an idea what goes wrong?

Hey there,

Check out the Django/mod_python docs for some possible explanations/solutions.

http://www.djangoproject.com/documentation/modpython/#if-you-get-a-segmentation-fault

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



admin apache

2006-03-24 Thread abe

hi,

trying to use the admin site vi apache/mod_python/mysql

I get a blank screen (in the browser) and the
httpd error logs say :

[Fri Mar 24 18:36:09 2006] [notice] mod_python: (Re)importing module
'django.core.handlers.modpython'
[Fri Mar 24 18:36:17 2006] [notice] child pid 13817 exit signal
Segmentation fault (11)

does anybody have an idea what goes wrong? 

-E


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---