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

[CT-352] Catch all Requests Exception on Deps Install and Retry #4849

Closed
emmyoop opened this issue Mar 9, 2022 · 2 comments · Fixed by #4865 or #4982
Closed

[CT-352] Catch all Requests Exception on Deps Install and Retry #4849

emmyoop opened this issue Mar 9, 2022 · 2 comments · Fixed by #4865 or #4982
Assignees
Labels
deps dbt's package manager jira
Milestone

Comments

@emmyoop
Copy link
Member

emmyoop commented Mar 9, 2022

We are not retrying for all exceptions from Requests and it's causing more unexpected/seemingly unexplained failures. We should try to mitigate these failures by retrying (up to 5 times). The logic to retry already exists. We just need to make sure we catch the right/entirety of exceptions.

  1. Catch all exceptions from Requests by catching just requests.exceptions.RequestException since all exceptions that Requests explicitly raises inherit from requests.exceptions.RequestException. Note that the ReadError should remain.

  2. Also fire a new event to track what exception we're retrying so that we can track where the failures are in the future.

dbt-core/core/dbt/utils.py

Lines 609 to 620 in ecfd77f

except (
requests.exceptions.ConnectionError,
requests.exceptions.Timeout,
requests.exceptions.ContentDecodingError,
ReadError,
) as exc:
if attempt <= max_attempts - 1:
fire_event(RetryExternalCall(attempt=attempt, max=max_attempts))
time.sleep(1)
_connection_exception_retry(fn, max_attempts, attempt + 1)
else:
raise ConnectionException("External connection exception occurred: " + str(exc))

Related Issues: #4601, #4178

@jtcohen6 jtcohen6 added this to the v1.0.4 milestone Mar 9, 2022
@jtcohen6 jtcohen6 added the packages Functionality for interacting with installed packages label Mar 9, 2022
@emmyoop emmyoop added the jira label Mar 11, 2022
@github-actions github-actions bot changed the title Catch all Requests Exception on Deps Install and Retry [CT-352] Catch all Requests Exception on Deps Install and Retry Mar 11, 2022
@nave91
Copy link

nave91 commented Mar 15, 2022

@emmyoop I'm just noting this down here in case it gets lost in our process. We saw another surge in dbt deps command failing because of hub returning 503 errors.

If we are catching and retrying on RequestException, we should be able catch the hub's 503 errors along with other HTTP error codes.

@barberscott
Copy link

Saw this on 1.0.5-rc1:

Traceback (most recent call last):
  File "/usr/src/app/sinter/clients/dbt.py", line 1295, in call
    dbt_main.handle(command + extra_args)
  File "/usr/local/lib/python3.8/dist-packages/dbt/main.py", line 152, in handle
    res, success = handle_and_check(args)
  File "/usr/local/lib/python3.8/dist-packages/dbt/main.py", line 192, in handle_and_check
    task, res = run_from_args(parsed)
  File "/usr/local/lib/python3.8/dist-packages/dbt/main.py", line 246, in run_from_args
    results = task.run()
  File "/usr/local/lib/python3.8/dist-packages/dbt/task/deps.py", line 56, in run
    final_deps = resolve_packages(packages, self.config)
  File "/usr/local/lib/python3.8/dist-packages/dbt/deps/resolver.py", line 140, in resolve_packages
    _check_for_duplicate_project_names(resolved, config, renderer)
  File "/usr/local/lib/python3.8/dist-packages/dbt/deps/resolver.py", line 106, in _check_for_duplicate_project_names
    project_name = package.get_project_name(config, renderer)
  File "/usr/local/lib/python3.8/dist-packages/dbt/deps/base.py", line 90, in get_project_name
    metadata = self.fetch_metadata(project, renderer)
  File "/usr/local/lib/python3.8/dist-packages/dbt/deps/base.py", line 86, in fetch_metadata
    self._cached_metadata = self._fetch_metadata(project, renderer)
  File "/usr/local/lib/python3.8/dist-packages/dbt/deps/registry.py", line 61, in _fetch_metadata
    return RegistryPackageMetadata.from_dict(dct)
  File "<string>", line 38, in from_dict
ValueError: Argument for dbt.contracts.project.RegistryPackageMetadata.from_dict method should be a dict instance

@jtcohen6 jtcohen6 added deps dbt's package manager and removed packages Functionality for interacting with installed packages labels Mar 30, 2022
@leahwicz leahwicz reopened this Mar 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deps dbt's package manager jira
Projects
None yet
5 participants