Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notify RPC exceptions on out of sync #1692

Closed
Uxio0 opened this issue Oct 3, 2023 · 1 comment · Fixed by #1696
Closed

Notify RPC exceptions on out of sync #1692

Uxio0 opened this issue Oct 3, 2023 · 1 comment · Fixed by #1696
Assignees
Labels
enhancement New feature or request

Comments

@Uxio0
Copy link
Member

Uxio0 commented Oct 3, 2023

What is needed?

Currently if there's a RPC error service will not report out of sync and it should be reported, as we should assume that if we cannot access the RPC there's a problem.

@Uxio0 Uxio0 added the enhancement New feature or request label Oct 3, 2023
@Uxio0 Uxio0 self-assigned this Oct 3, 2023
@luarx
Copy link
Contributor

luarx commented Oct 5, 2023

Possible solution:

  • Catch the exception. Add a try-catch to check_sync_status_task to catch when the exception is raised and log the same error message as when it is out-of-sync or something similar to know that it is a special case logger.error("Service is out of sync - Maybe as it is not possible to calculate because of exception {exception}")
  • Exception. ConnectionError or just all the Exception types so that we can guarantee that always the logging message can be generated.

The purpose of this issue was this exception last time:

2023-10-03 04:10:17,555 [ERROR] [3406eeba/check_sync_status_task] Task safe_transaction_service.history.tasks.check_sync_status_task[3406eeba-d3fc-45c6-998e-a6f24f02037e] raised unexpected: ConnectionError(MaxRetryError("HTTPConnectionPool(host='ethereum-node.local', port=8545): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff713ab490>: Failed to establish a new connection: [Errno 111] Connection refused'))"))
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 174, in _new_conn
    conn = connection.create_connection(
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 95, in create_connection
    raise err
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/connection.py", line 85, in create_connection
    sock.connect(sa)
  File "/usr/local/lib/python3.10/site-packages/gevent/_socketcommon.py", line 590, in connect
    self._internal_connect(address)
  File "/usr/local/lib/python3.10/site-packages/gevent/_socketcommon.py", line 634, in _internal_connect
    raise _SocketError(err, strerror(err))
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 714, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 415, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 244, in request
    super(HTTPConnection, self).request(method, url, body=body, headers=headers)
  File "/usr/local/lib/python3.10/http/client.py", line 1283, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/local/lib/python3.10/http/client.py", line 1329, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.10/http/client.py", line 1278, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/local/lib/python3.10/http/client.py", line 1038, in _send_output
    self.send(msg)
  File "/usr/local/lib/python3.10/http/client.py", line 976, in send
    self.connect()
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 205, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.10/site-packages/urllib3/connection.py", line 186, in _new_conn
    raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPConnection object at 0xffff713ab490>: Failed to establish a new connection: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
  File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 798, in urlopen
    retries = retries.increment(
  File "/usr/local/lib/python3.10/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='ethereum-node.local', port=8545): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff713ab490>: Failed to establish a new connection: [Errno 111] Connection refused'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/celery/app/trace.py", line 477, in trace_task
    R = retval = fun(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/celery/app/trace.py", line 760, in __protected_call__
    return self.run(*args, **kwargs)
  File "/app/safe_transaction_service/history/tasks.py", line 80, in check_sync_status_task
    if not (is_service_synced := IndexServiceProvider().is_service_synced()):
  File "/app/safe_transaction_service/history/services/index_service.py", line 156, in is_service_synced
    self.ethereum_client.current_block_number - self.eth_reorg_blocks
  File "/usr/local/lib/python3.10/site-packages/gnosis/eth/ethereum_client.py", line 1280, in current_block_number
    return self.w3.eth.block_number
  File "/usr/local/lib/python3.10/site-packages/web3/eth/eth.py", line 134, in block_number
    return self.get_block_number()
  File "/usr/local/lib/python3.10/site-packages/web3/module.py", line 73, in caller
    result = w3.manager.request_blocking(
  File "/usr/local/lib/python3.10/site-packages/web3/manager.py", line 249, in request_blocking
    response = self._make_request(method, params)
  File "/usr/local/lib/python3.10/site-packages/web3/manager.py", line 188, in _make_request
    return request_func(method, params)
  File "/usr/local/lib/python3.10/site-packages/web3/middleware/cache.py", line 115, in middleware
    return make_request(method, params)
  File "/usr/local/lib/python3.10/site-packages/web3/middleware/gas_price_strategy.py", line 101, in middleware
    return make_request(method, params)
  File "/usr/local/lib/python3.10/site-packages/web3/middleware/formatting.py", line 106, in middleware
    response = make_request(method, params)
  File "/usr/local/lib/python3.10/site-packages/web3/middleware/attrdict.py", line 43, in middleware
    response = make_request(method, params)
  File "/usr/local/lib/python3.10/site-packages/web3/middleware/formatting.py", line 106, in middleware
    response = make_request(method, params)
  File "/usr/local/lib/python3.10/site-packages/web3/middleware/formatting.py", line 106, in middleware
    response = make_request(method, params)
  File "/usr/local/lib/python3.10/site-packages/web3/middleware/buffered_gas_estimate.py", line 43, in middleware
    return make_request(method, params)
  File "/usr/local/lib/python3.10/site-packages/web3/middleware/formatting.py", line 106, in middleware
    response = make_request(method, params)
  File "/usr/local/lib/python3.10/site-packages/web3/middleware/exception_retry_request.py", line 114, in middleware
    return make_request(method, params)
  File "/usr/local/lib/python3.10/site-packages/web3/providers/rpc.py", line 90, in make_request
    raw_response = make_post_request(
  File "/usr/local/lib/python3.10/site-packages/web3/_utils/request.py", line 114, in make_post_request
    response = get_response_from_post_request(endpoint_uri, data=data, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/web3/_utils/request.py", line 107, in get_response_from_post_request
    response = session.post(endpoint_uri, *args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 637, in post
    return self.request("POST", url, data=data, json=json, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 519, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='ethereum-node.local', port=8545): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0xffff713ab490>: Failed to establish a new connection: [Errno 111] Connection refused'))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants