Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[bug 701011] fix excerpt problems

The old search view code caught socket.timeout and socket.error exceptions
and handled them.  The new code in oedipus didn't.  Turns out these errors
happen a lot in production.

This adds handling for those errors and also counts them with
statsd so we can see how big the problem is without getting a ton of
error email.
  • Loading branch information...
commit 66ba9bdf67942f834bca216c377c7eecbb2a755e 1 parent 26302fe
@willkg willkg authored
View
2  apps/search/__init__.py
@@ -86,4 +86,6 @@ def port(self):
else settings.SPHINX_PORT)
+ExcerptTimeoutError = oedipus.ExcerptTimeoutError
+ExcerptSocketErrorError = oedipus.ExcerptSocketErrorError
SearchError = oedipus.SearchError
View
27 apps/search/views.py
@@ -14,9 +14,10 @@
import jingo
import jinja2
from mobility.decorators import mobile_template
+from statsd import statsd
from tower import ugettext as _
-from search import SearchError
+from search import SearchError, ExcerptTimeoutError, ExcerptSocketErrorError
from search.utils import locale_or_default, clean_excerpt
from forums.models import Thread, discussion_search
from questions.models import question_search
@@ -311,8 +312,16 @@ def search(request, template=None):
results.append(result)
elif type_ == 'question':
- summary = jinja2.Markup(
- clean_excerpt(question_s.excerpt(doc)[0]))
+ try:
+ excerpt = question_s.excerpt(doc)[0]
+ except ExcerptTimeoutError:
+ statsd.incr('search.excerpt.timeout')
+ excerpt = u''
+ except ExcerptSocketErrorError:
+ statsd.incr('search.excerpt.socketerror')
+ excerpt = u''
+
+ summary = jinja2.Markup(clean_excerpt(excerpt))
result = {
'search_summary': summary,
@@ -329,8 +338,16 @@ def search(request, template=None):
# to get this manually.
thread = Thread.objects.get(pk=doc.thread_id)
- summary = jinja2.Markup(
- clean_excerpt(discussion_s.excerpt(doc)[0]))
+ try:
+ excerpt = discussion_s.excerpt(doc)[0]
+ except ExcerptTimeoutError:
+ statsd.incr('search.excerpt.timeout')
+ excerpt = u''
+ except ExcerptSocketErrorError:
+ statsd.incr('search.excerpt.socketerror')
+ excerpt = u''
+
+ summary = jinja2.Markup(clean_excerpt(excerpt))
result = {
'search_summary': summary,
2  vendor/src/oedipus
@@ -1 +1 @@
-Subproject commit 9a3ec4b4f75d99b329e766e8e30e50ca9f569b0f
+Subproject commit 428fb5c430a0d6ff99a81c06bcef8b7bbbe6f238
Please sign in to comment.
Something went wrong with that request. Please try again.