2016-09-22 2 views
0

이 내 전체 추적입니다 :redis.exceptions.ConnectionError 후 약 하루 셀러리 실행

Traceback (most recent call last): 
    File "/home/server/backend/venv/lib/python3.4/site-packages/celery/app/trace.py", line 283, in trace_task 
    uuid, retval, SUCCESS, request=task_request, 
    File "/home/server/backend/venv/lib/python3.4/site-packages/celery/backends/base.py", line 256, in store_result 
    request=request, **kwargs) 
    File "/home/server/backend/venv/lib/python3.4/site-packages/celery/backends/base.py", line 490, in _store_result 
    self.set(self.get_key_for_task(task_id), self.encode(meta)) 
    File "/home/server/backend/venv/lib/python3.4/site-packages/celery/backends/redis.py", line 160, in set 
    return self.ensure(self._set, (key, value), **retry_policy) 
    File "/home/server/backend/venv/lib/python3.4/site-packages/celery/backends/redis.py", line 149, in ensure 
    **retry_policy 
    File "/home/server/backend/venv/lib/python3.4/site-packages/kombu/utils/__init__.py", line 243, in retry_over_time 
    return fun(*args, **kwargs) 
    File "/home/server/backend/venv/lib/python3.4/site-packages/celery/backends/redis.py", line 169, in _set 
    pipe.execute() 
    File "/home/server/backend/venv/lib/python3.4/site-packages/redis/client.py", line 2593, in execute 
    return execute(conn, stack, raise_on_error) 
    File "/home/server/backend/venv/lib/python3.4/site-packages/redis/client.py", line 2447, in _execute_transaction 
    connection.send_packed_command(all_cmds) 
    File "/home/server/backend/venv/lib/python3.4/site-packages/redis/connection.py", line 532, in send_packed_command 
    self.connect() 
    File "/home/pserver/backend/venv/lib/python3.4/site-packages/redis/connection.py", line 436, in connect 
    raise ConnectionError(self._error_message(e)) 
redis.exceptions.ConnectionError: Error 0 connecting to localhost:6379. Error. 
[2016-09-21 10:47:18,814: WARNING/Worker-747] Data collector is not contactable. This can be because of a network issue or because of the data collector being restarted. In the event that contact cannot be made after a period of time then please report this problem to New Relic support for further investigation. The error raised was ConnectionError(ProtocolError('Connection aborted.', BlockingIOError(11, 'Resource temporarily unavailable')),). 

난 정말 ConnectionError를 검색하지만 내와 일치 문제가 없었다가.

내 플랫폼은 우분투 14.04입니다. 이것은 나의 redis 설정의 일부입니다. 이 내 미니 레디 스 래퍼입니다

# By default Redis listens for connections from all the network interfaces 
# available on the server. It is possible to listen to just one or multiple 
# interfaces using the "bind" configuration directive, followed by one or 
# more IP addresses. 
# 
# Examples: 
# 
# bind 192.168.1.100 10.0.0.1 
bind 127.0.0.1 

# Specify the path for the unix socket that will be used to listen for 
# incoming connections. There is no default, so Redis will not listen 
# on a unix socket when not specified. 
# 
# unixsocket /var/run/redis/redis.sock 
# unixsocketperm 755 

# Close the connection after a client is idle for N seconds (0 to disable) 
timeout 0 

# TCP keepalive. 
# 
# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence 
# of communication. This is useful for two reasons: 
# 
# 1) Detect dead peers. 
# 2) Take the connection alive from the point of view of network 
# equipment in the middle. 
# 
# On Linux, the specified value (in seconds) is the period used to send ACKs. 
# Note that to close the connection the double of the time is needed. 
# On other kernels the period depends on the kernel configuration. 
# 
# A reasonable value for this option is 60 seconds. 
tcp-keepalive 60 

을 (.. 당신이 전체 redis.conf 파일이 필요하다면 나는 모든 매개 변수 제한 섹션에 폐쇄하는 방법으로 공유 할 수 있습니다) :

import redis 

from django.conf import settings 


REDIS_POOL = redis.ConnectionPool(host=settings.REDIS_HOST, port=settings.REDIS_PORT) 


def get_redis_server(): 
    return redis.Redis(connection_pool=REDIS_POOL) 

그리고 이것은이다 나는 그것을 사용하는 방법 :

from redis_wrapper import get_redis_server 

# view and task are working in different, indipendent processes 

def sample_view(request): 
    rs = get_redis_server() 
    # some get-set stuff with redis 



@shared_task 
def sample_celery_task(): 
    rs = get_redis_server() 
    # some get-set stuff with redis 

패키지 버전 :

celery==3.1.18 
django-celery==3.1.16 
kombu==3.0.26 
redis==2.10.3 

그래서 문제가 있습니다. 이 연결 오류는 셀러리 작업자를 얼마간 만료 한 후에 발생합니다. 그리고 첫 번째 오류가 보인 후 모든 셀러 리 작업자를 다시 시작할 때까지 모든 작업이이 오류로 끝납니다. (흥미롭게도, 문제가있는 기간 동안 셀러리 꽃도 실패합니다.)

redis 연결 풀 사용 방법이나 redis 구성 또는 네트워크 문제가 의심됩니다. 이유에 대한 아이디어가 있습니까? 내가 도대체 ​​뭘 잘못하고있는 겁니까?

(PS : 오늘이 오류를 볼 때 내가 레디 스-CLI 정보 결과를 추가합니다) :

내가 일시적으로 내 작업자 스타터 명령에 --maxtasksperchild 매개 변수를 추가하여이 문제를 해결

UPDATE. 나는 그것을 200으로 설정했다. 당연히이 문제를 해결하는 적절한 방법은 아니며 단지 증상이 완치되는 것이다. 기본적으로 작업자 인스턴스를 주기적으로 새로 고칩니다 (이전 프로세스를 닫고 이전 작업이 200 개 작업에 도달하면 새 프로세스를 만들고 새로 글로벌 redis 풀과 연결을 새로 고칩니다). 그래서 나는 글로벌 redis 연결 풀 사용법에 초점을 맞추어야한다고 생각하며 새로운 아이디어와 의견을 기다리고 있습니다.

영어로 감사드립니다. 미리 감사드립니다.

답변

0

redd 백그라운드에서 rdb 백그라운드 저장 방법을 활성화 했습니까 ??
dump.rdb 파일의 크기가 /var/lib/redis인지 확인하십시오.
가끔씩 파일의 크기가 커지고 root 디렉토리가 채워지고 redis 인스턴스는 더 이상 해당 파일에 저장할 수 없습니다.

당신은 redis-cli

+0

덕분에
config set stop-writes-on-bgsave-error no
명령을 실행하여 프로세스를 저장 배경을 중지 할 수 있습니다. 방금 확인한 결과 589MB였습니다. 하지만 redis가 지속성 목적으로 사용하는 파일이 맞습니까? 내 컴퓨터를 재부팅 한 후에 대기열을 사용할 수 없게 만들지 않습니까? 또한 디스크 크기를 하루에 몇 번 확인하고 있습니다. 마지막으로 작업자를 다시 시작하면 덤프 파일 크기를 줄일 수 있습니까? 제 말은, 증상이 맞지 않는다는 것입니다. –

+0

제공되는 명령은 백그라운드 저장을 중지하는 것이 아니라 백그라운드 저장 방법과 관련된 오류가 발생할 경우 다시 시작을 막는 것입니다. –

+0

나는 그것을 얻었다. 그러나 우리는 그 오류 시간에 redis-cli를 통해 redis 데이터에 도달 할 수 있다고 생각해야합니다. redis가 완전히 멈추지 않고 셀러리 클라이언트 만 차단합니다. –