Closed pnovotnak closed 10 years ago
Strange error, do you have the file/line (from the backtrace) raising it ?
I suppose that might indeed help, eh :)
ERROR:django.request:Internal Server Error: /search/******
Traceback (most recent call last):
File "/var/www/************/dev/env/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
File "/var/www/************/dev/****************/views.py", line 225, in **********
File "/var/www/************/dev/env/local/lib/python2.7/site-packages/haystack/query.py", line 157, in _manual_iter
File "/var/www/************/dev/env/local/lib/python2.7/site-packages/haystack/query.py", line 164, in _fill_cache
File "/var/www/************/dev/env/local/lib/python2.7/site-packages/haystack/backends/__init__.py", line 485, in get_results
File "/var/www/************/dev/env/local/lib/python2.7/site-packages/haystack/backends/elasticsearch_backend.py", line 942, in run
File "/var/www/************/dev/env/local/lib/python2.7/site-packages/haystack/backends/__init__.py", line 26, in wrapper
File "/var/www/************/dev/env/local/lib/python2.7/site-packages/haystack/backends/elasticsearch_backend.py", line 510, in search
File "/var/www/************/dev/env/local/lib/python2.7/site-packages/pyelasticsearch/client.py", line 96, in decorate
File "/var/www/************/dev/env/local/lib/python2.7/site-packages/pyelasticsearch/client.py", line 591, in search
File "/var/www/************/dev/env/local/lib/python2.7/site-packages/pyelasticsearch/client.py", line 568, in _search_or_count
File "/var/www/************/dev/env/local/lib/python2.7/site-packages/pyelasticsearch/client.py", line 239, in send_request
File "/var/www/************/dev/env/local/lib/python2.7/site-packages/requests/sessions.py", line 394, in get
File "/var/www/************/dev/env/local/lib/python2.7/site-packages/requests/sessions.py", line 348, in request
File "/var/www/************/dev/env/local/lib/python2.7/site-packages/requests/sessions.py", line 274, in prepare_request
File "/var/www/************/dev/env/local/lib/python2.7/site-packages/requests/utils.py", line 76, in get_netrc_auth
File "/var/www/************/dev/env/local/lib/python2.7/site-packages/requests/utils.py", line 73, in <genexpr>
File "/var/www/************/dev/env/lib/python2.7/posixpath.py", line 260, in expanduser
KeyError: 'getpwuid(): uid not found: 1001'
wow first time i see using .netrc after years :) those uid 1001 suggest you something ? (unless www-data maps to 1001 i do not think it is a uWSGI issue)
Too young, never in my life seen a .netrc
Haha, meant to sensor that UID too. oooops :)
Yeah, that UID is a user created to serve this app- it's the correct UID, there is a www-data group (NGINX). The app is set to run as UID 1001, and GID www-data.
So you think it's a haystack / pyelasticsearch / requests issue?
for some reason it is not able to access /etc/passwd to resolve the mappings between 1001 and its name
Defining the "$HOME" variable via the 'env' setting, actually does fix the problem: https://github.com/toastdriven/django-haystack/issues/924
But, then I run into another issue.. Django throws a "TemplateDoesNotExist" but when I thumb through the places it's looking- the file exists at one of them, and it's rw for user specified in the app's config...
TemplateDoesNotExist at /search/
search/results.html
Request Method: GET
Request URL: http://**********/search
Django Version: 1.4.10
Exception Type: TemplateDoesNotExist
Exception Value:
search/results.html
Python Executable: /usr/local/bin/uwsgi
Python Version: 2.7.3
Python Path:
['.',
'',
'/var/www/************/dev/env/lib/python2.7',
'/var/www/************/dev/env/lib/python2.7/plat-linux2',
'/var/www/************/dev/env/lib/python2.7/lib-tk',
'/var/www/************/dev/env/lib/python2.7/lib-old',
'/var/www/************/dev/env/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/var/www/************/dev/env/local/lib/python2.7/site-packages',
'/var/www/************/dev/env/local/lib/python2.7/site-packages/PIL',
'/var/www/************/dev/env/lib/python2.7/site-packages',
'/var/www/************/dev/env/lib/python2.7/site-packages/PIL',
'/var/www/************/dev/project/django_apps']
Server time: Tue, 7 Jan 2014 10:13:13 -0600
Template-loader postmortem
Using loader django.template.loaders.app_directories.Loader:
/var/www/************/dev/env/local/lib/python2.7/site-packages/grappelli/templates/search/results.html (File does not exist)
...
/var/www/************/dev/project/django_apps/search/templates/search/results.html (File exists)
ls -l /var/www/****/dev/project/django_apps/search/templates/search/results.html # (File exists)
-rw-rw-r-- 1 \ \ /var/www/****/dev/project/django_apps/search/templates/search/results.html
(owned by user/ user's group)
Here's the traceback:
Traceback (most recent call last):
File "/var/www/********/dev/env/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 111, in get_response
File "/var/www/sargento-cpd/dev/project/django_apps/home/views.py", line 31, in home
File "/var/www/sargento-cpd/dev/env/local/lib/python2.7/site-packages/django/shortcuts/__init__.py", line 20, in render_to_response
File "/var/www/sargento-cpd/dev/env/local/lib/python2.7/site-packages/django/template/loader.py", line 169, in render_to_string
File "/var/www/sargento-cpd/dev/env/local/lib/python2.7/site-packages/django/template/loader.py", line 145, in get_template
File "/var/www/sargento-cpd/dev/env/local/lib/python2.7/site-packages/django/template/loader.py", line 138, in find_template
TemplateDoesNotExist: home.html
Here are my uWSGI params:
uwsgi_param QUERY_STRING $query_string;
uwsgi_param REQUEST_METHOD $request_method;
uwsgi_param CONTENT_TYPE $content_type;
uwsgi_param CONTENT_LENGTH $content_length;
uwsgi_param REQUEST_URI $request_uri;
uwsgi_param PATH_INFO $document_uri;
uwsgi_param DOCUMENT_ROOT $document_root;
uwsgi_param SERVER_PROTOCOL $server_protocol;
uwsgi_param UWSGI_SCHEME $scheme;
uwsgi_param REMOTE_ADDR $remote_addr;
uwsgi_param REMOTE_PORT $remote_port;
uwsgi_param SERVER_PORT $server_port;
uwsgi_param SERVER_NAME $server_name;
The site's nginx defines 'root' as /var/www/*****/
The initial request runs OK, other requests run just fine, even other searches, and other repeated searches. It's just when I run that specific query that returns 1000+ results on the same page (and is refreshed before the request completes) that things run amuck. I tried running Apache Bench against another search page, with the concurrency set to the max number of uWSGI workers and everything went just fine.
Again, once it happens, the worker is toast. Every subsequent page returns a template error.
Maybe it's a Django bug...
If I limit the results with [:N] syntax it runs OK.
Sorry for the bother, this is NOT a uwsgi issue. It happens when running with the Django dev server.
I'm about 50% sure this is a Django / Django Haystack bug...
The error happens when running on:
When running several very expensive searches against elasticsearch I get this error:
and the whole worker is toast.
Here's my python requirements file:
Here's my global defaults config:
Here's my app's config: