Tuesday, November 20, 2012

Re: Login failing

> On Feb 22, 11:34 pm, "Aryeh Leib Taurog" <v...@aryehleib.com> wrote:
>> I'm seeing a very strange intermittent problem with logging in.  The login
>> appears to be successful, because the response to the login POST is a 302
>> redirect.  However sometimes the user doesn't seem to be stored in the
>> session.
>>
>> I'm running:
>> django 1.2.4
>> python 2.6.5 (ubuntu 10.4)
>> lighttpd 1.4.26 via fcgi (with flup)
>> postgresql 8.4 via psycopg2 (2.0.13-2ubuntu2)
>>
>> session engine is db (all session-related settings are default)
>> The login view is django.contrib.auth.views.login
>>
>> MIDDLEWARE_CLASSES = (
>>     'django.middleware.common.CommonMiddleware',
>>     'django.contrib.sessions.middleware.SessionMiddleware',
>>     'django.middleware.csrf.CsrfViewMiddleware',
>>     'django.middleware.locale.LocaleMiddleware',
>>     'django.contrib.auth.middleware.AuthenticationMiddleware',
>>     'django.contrib.messages.middleware.MessageMiddleware',
>>     'django.middleware.doc.XViewMiddleware',
>>     'django.middleware.transaction.TransactionMiddleware',
>>      ...
>> )

I'm reviving this monologue because I believe I've resolved the issue, and
perhaps the information will be of use to someone else. I concluded that the
login failures were the result of db connections left with uncommitted
transactions: <https://code.djangoproject.com/ticket/17887>

I was using transaction middleware, so this issue did not affect most normal
activity on the site. But authentication and session middleware were outside
the transaction middleware, so the problem became apparent there. I imagine
one solution would have been to move the transaction middleware outside the
session and authentication middleware.

I opted for postgresql 'autocommit' mode, as Christophe Pettus recommends:
<http://thebuild.com/blog/2009/11/07/>

In order for this to work I had to apply the patch for this bug (I'm running
django 1.3.1 at the moment): <https://code.djangoproject.com/ticket/16047>

It's been a few weeks since the fix was applied. I've seen no issues so far,
login-related or otherwise.

--
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 django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate