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

Fix retry logic in qai_upload.py #1140

Open
Donaim opened this issue Aug 6, 2024 · 1 comment
Open

Fix retry logic in qai_upload.py #1140

Donaim opened this issue Aug 6, 2024 · 1 comment
Labels

Comments

@Donaim
Copy link
Member

Donaim commented Aug 6, 2024

When micall watcher loses connection to QAI, it should enter a retry loop, where each try is delayed by a bigger and bigger time interval. Example:

- QAI upload succeeds
- QAI upload fails
- Wait 5 seconds
- QAI upload fails
- Wait 10 seconds
- QAI upload fails
- ...
- QAI upload fails
- Wait 24 hours
- QAI upload fails
- Wait 24 hours                  # max interval length reached.
- QAI upload succeeds

This is currently not working.
Instead, micall watcher tries to reconnect much more frequently.

@Donaim Donaim added the bug label Aug 6, 2024
@donkirkby
Copy link
Member

I think it's giving up, instead of retrying. Here's an example from the log, when the watcher was configured to point to an old QAI server that had been shut down:

2024-08-04 13:30:58[INFO]micall.monitor.kive_watcher.collate_folder(): Collating results in /media/RAW_DATA/MiSeq/runs/240802_M04401_0312_000000000-LCB78/Results/version_7.15/denovo
2024-08-04 13:31:02[ERROR]micall.monitor.kive_watcher.wait_for_retry(): Waiting 0:00:05 before retrying.
Traceback (most recent call last):
  File "/usr/local/share/venv-micall/lib/python3.7/site-packages/urllib3/connection.py", line 175, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/usr/local/share/venv-micall/lib/python3.7/site-packages/urllib3/util/connection.py", line 95, in create_connection
    raise err
  File "/usr/local/share/venv-micall/lib/python3.7/site-packages/urllib3/util/connection.py", line 85, in create_connection
    sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/share/venv-micall/lib/python3.7/site-packages/urllib3/connectionpool.py", line 722, in urlopen
    chunked=chunked,
  File "/usr/local/share/venv-micall/lib/python3.7/site-packages/urllib3/connectionpool.py", line 404, in _make_request
    self._validate_conn(conn)
  File "/usr/local/share/venv-micall/lib/python3.7/site-packages/urllib3/connectionpool.py", line 1058, in _validate_conn
    conn.connect()
  File "/usr/local/share/venv-micall/lib/python3.7/site-packages/urllib3/connection.py", line 363, in connect
    self.sock = conn = self._new_conn()
  File "/usr/local/share/venv-micall/lib/python3.7/site-packages/urllib3/connection.py", line 187, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at 0x7f34c5fb7ed0>: 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/share/venv-micall/lib/python3.7/site-packages/requests/adapters.py", line 450, in send
    timeout=timeout
  File "/usr/local/share/venv-micall/lib/python3.7/site-packages/urllib3/connectionpool.py", line 800, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/usr/local/share/venv-micall/lib/python3.7/site-packages/urllib3/util/retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='qai.cfenet.ubc.ca', port=3000): Max retries exceeded with url: /account/login (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection
 object at 0x7f34c5fb7ed0>: 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/share/MiCall/micall/monitor/update_qai.py", line 389, in process_folder
    session.login(qai_server, qai_user, qai_password)
  File "/usr/local/share/MiCall/micall/monitor/qai_helper.py", line 24, in login
    'user_password': password})
  File "/usr/local/share/venv-micall/lib/python3.7/site-packages/requests/sessions.py", line 577, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/usr/local/share/venv-micall/lib/python3.7/site-packages/requests/sessions.py", line 529, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/share/venv-micall/lib/python3.7/site-packages/requests/sessions.py", line 645, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/share/venv-micall/lib/python3.7/site-packages/requests/adapters.py", line 519, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='qai.cfenet.ubc.ca', port=3000): Max retries exceeded with url: /account/login (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f34c5fb7ed0>: 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
Projects
None yet
Development

No branches or pull requests

2 participants