webapp workers are being killed off
Categories
(Socorro :: Webapp, defect, P2)
Tracking
(Not tracked)
People
(Reporter: willkg, Assigned: willkg)
Details
Attachments
(1 external file)
https://sentry.prod.mozaws.net/operations/socorro-new-prod/issues/9466810/
timeout: The read operation timed out
File "urllib3/connectionpool.py", line 426, in _make_request
six.raise_from(e, None)
File "<string>", line 3, in raise_from
# Permission is hereby granted, free of charge, to any person obtaining a copy
File "urllib3/connectionpool.py", line 421, in _make_request
httplib_response = conn.getresponse()
File "http/client.py", line 1347, in getresponse
response.begin()
File "http/client.py", line 307, in begin
version, status, reason = self._read_status()
File "http/client.py", line 268, in _read_status
line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
File "socket.py", line 704, in readinto
return self._sock.recv_into(b)
File "ssl.py", line 1241, in recv_into
return self.read(nbytes, buffer)
File "ssl.py", line 1099, in read
return self._sslobj.read(len, buffer)
ReadTimeoutError: HTTPSConnectionPool(host='bugzilla.mozilla.org', port=443): Read timed out. (read timeout=5)
File "urllib3/connectionpool.py", line 670, in urlopen
httplib_response = self._make_request(
File "urllib3/connectionpool.py", line 428, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
File "urllib3/connectionpool.py", line 335, in _raise_timeout
raise ReadTimeoutError(
SystemExit: 1
File "django/core/handlers/wsgi.py", line 141, in __call__
response = self.get_response(request)
File "django/core/handlers/base.py", line 75, in get_response
response = self._middleware_chain(request)
File "django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "whitenoise/middleware.py", line 59, in __call__
response = self.get_response(request)
File "django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "django/utils/deprecation.py", line 94, in __call__
response = response or self.get_response(request)
File "django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "django/utils/deprecation.py", line 94, in __call__
response = response or self.get_response(request)
File "django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "django/utils/deprecation.py", line 94, in __call__
response = response or self.get_response(request)
File "django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "django/utils/deprecation.py", line 94, in __call__
response = response or self.get_response(request)
File "django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "django/utils/deprecation.py", line 94, in __call__
response = response or self.get_response(request)
File "django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "django/utils/deprecation.py", line 94, in __call__
response = response or self.get_response(request)
File "django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "django/utils/deprecation.py", line 94, in __call__
response = response or self.get_response(request)
File "django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "crashstats/crashstats/middleware.py", line 29, in __call__
return self.get_response(request)
File "django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "django/utils/deprecation.py", line 94, in __call__
response = response or self.get_response(request)
File "django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "django/utils/deprecation.py", line 94, in __call__
response = response or self.get_response(request)
File "django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "ratelimit/middleware.py", line 12, in __call__
return self.get_response(request)
File "django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "crashstats/tokens/middleware.py", line 34, in __call__
response = self.get_response(request)
File "django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "crashstats/crashstats/middleware.py", line 42, in __call__
response = self.get_response(request)
File "django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "crashstats/crashstats/utils.py", line 235, in wrapper
response = f(request, *args, **kw)
File "crashstats/crashstats/views.py", line 282, in buginfo
result = bzapi.get(bug_ids)
File "crashstats/crashstats/models.py", line 988, in get
response = session.get(
File "requests/sessions.py", line 543, in get
return self.request('GET', url, **kwargs)
File "requests/sessions.py", line 530, in request
resp = self.send(prep, **send_kwargs)
File "requests/sessions.py", line 643, in send
r = adapter.send(request, **kwargs)
File "socorro/lib/requestslib.py", line 33, in send
return super().send(*args, **kwargs)
File "requests/adapters.py", line 439, in send
resp = conn.urlopen(
File "urllib3/connectionpool.py", line 754, in urlopen
return self.urlopen(
File "urllib3/connectionpool.py", line 754, in urlopen
return self.urlopen(
File "urllib3/connectionpool.py", line 754, in urlopen
return self.urlopen(
File "urllib3/connectionpool.py", line 754, in urlopen
return self.urlopen(
File "urllib3/connectionpool.py", line 729, in urlopen
retries.sleep()
File "urllib3/util/retry.py", line 311, in sleep
self._sleep_backoff()
File "urllib3/util/retry.py", line 295, in _sleep_backoff
time.sleep(backoff)
File "gunicorn/workers/base.py", line 201, in handle_abort
sys.exit(1)
That's a long stack trace. What seems to be going on is that someone is hitting /buginfo/bug with a single bug, Bugzilla is having serious problems, and thus the webapp retries the event with connection timeouts. While waiting for one of the retries, the webapp process is killed off by gunicorn with signal 6.
It'd be better if things weren't killed off while they're working on things.
| Assignee | ||
Comment 1•5 years ago
|
||
I'm pretty sure what's going on is that the cumulative timeouts and sleeps between retrying exceeds gunicorn's 30-second "yo, homie--you still alive?" check (set by timeout) and then gunicorn kills the process.
We set up requests like this:
def session_with_retries(
total_retries=5,
backoff_factor=0.2,
status_forcelist=(429, 500),
default_timeout=5.0,
):
It gets called here:
session = session_with_retries(
# BZAPI isn't super reliable, so be extra patient
total_retries=5,
# 502 = Bad Gateway
# 504 = Gateway Time-out
status_forcelist=(500, 502, 504),
)
response = session.get(
url, headers=headers, timeout=self.BUGZILLA_REST_TIMEOUT
)
It retries 5 times with timeout set to 5 (BUGZILLA_REST_TIMEOUT) and backoff_factor set to 0.2. So we get:
- 5 (conn timeout)
-
- 0.2 (1st backoff) = 5.2
-
- 5 (conn timeout) = 10.2
-
- 0.4 (2nd backoff) = 10.6
-
- 5 (conn timeout) = 15.6
-
- 0.8 (3rd backoff) = 16.4
-
- 5 (conn timeout) = 21.4
-
- 1.6 (4th backoff) = 23.0
-
- 5 (conn timeout) = 28.0
-
- 3.2 (5th and final backoff) = 33.0 which exceeds the gunicorn "yo, homie--you ok?" amount.
Thus when Bugzilla isn't functional, it can kill off webapp processes. BAM!
So two things:
- I misunderstood
backoff_factorwhen I created defaults for things. It shouldn't be 0.2--it should be 0.1. I should fix that. Plus we should improve the docs because they read like it's linear progression and it's an exponential progression. - The comments in urllib3 code suggest that our default connection timeout should be more like 3.
I'll work on that now.
| Assignee | ||
Comment 2•5 years ago
|
||
| Assignee | ||
Comment 3•5 years ago
|
||
| Assignee | ||
Comment 4•5 years ago
|
||
Pushed this out just now in bug #1692041. Marking as FIXED.
Description
•