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-2393] [Bug] On MacOS, running dbt functional tests fails with errors opening files #7316

Open
2 tasks done
ezraerb opened this issue Apr 11, 2023 · 7 comments · May be fixed by #7343
Open
2 tasks done

[CT-2393] [Bug] On MacOS, running dbt functional tests fails with errors opening files #7316

ezraerb opened this issue Apr 11, 2023 · 7 comments · May be fixed by #7343
Labels
enhancement New feature or request

Comments

@ezraerb
Copy link
Contributor

ezraerb commented Apr 11, 2023

Is this a new bug in dbt-core?

  • I believe this is a new bug in dbt-core
  • I have searched the existing issues, and I could not find an existing issue for this bug

Current Behavior

I downloaded a new clone of the dbt-core repository. It has no edits. Running 'make integration' runs approximately 17% of the tests, and then all tests fail. The error logs contain a mixture of seemingly unrelated errors: warnings can not be written to the log file, the sqllte file used by coverage can not be opened, and others. Lots of trial and error finally revealed that the running the tests is exceeding the open file descriptor (soft) limit. On MacOS, this limit is only 256.

Expected Behavior

Either the integration tests run without error on a newly created clone of the repository, or CONTRIBUTING.md has a note in the testing section about the need for a high open file descriptor limit.

Steps To Reproduce

  1. On MacOS Monterrey, install development tools as specified in CONTRIBUTING.md
  2. Clone the dbt-core repo
  3. 'make integration'. See all the seemingly random file opening errors

Unlike step 3 above, 'pytest tests/functional' produces a clear error message that the file descriptor limit has been hit.

Relevant log output

No response

Environment

- OS: MacOS Monterrey 12.6.5
- Python: 3.9.6
- dbt: 1.5.0-b5

Which database adapter are you using with dbt?

postgres

Additional Context

No response

@ezraerb ezraerb added bug Something isn't working triage labels Apr 11, 2023
@github-actions github-actions bot changed the title [Bug] On MacOS, running dbt functional tests fails with errors opening files [CT-2393] [Bug] On MacOS, running dbt functional tests fails with errors opening files Apr 11, 2023
@dbeatty10 dbeatty10 self-assigned this Apr 11, 2023
@dbeatty10
Copy link
Contributor

Thanks for reporting this @ezraerb !

Trying out these instructions with macOS 12.6 worked fine for me the first time I tried it. Here are the limits my system reported:

$ ulimit -n               
1048575
$ launchctl limit maxfiles
        maxfiles    256            unlimited      

But after adjusting the file descriptor limit down by running ulimit -n 256 per these instructions, I was able to reproduce what you reported.

If we were to add a note in the testing section about the need for a high open file descriptor limit, do you have any suggestions for what that note would say?

I'm going to re-label this as an enhancement, because we reserve bug for when dbt-core itself is not working as expected.

@dbeatty10 dbeatty10 added enhancement New feature or request awaiting_response and removed bug Something isn't working labels Apr 11, 2023
@dbeatty10 dbeatty10 removed their assignment Apr 11, 2023
@dbeatty10 dbeatty10 removed the triage label Apr 11, 2023
@ezraerb
Copy link
Contributor Author

ezraerb commented Apr 12, 2023

I'm a little concerned about why the tests need so many open file descriptors, since they (hopefully) don't actually open that many resources at once. Are descriptors leaking somewhere? Since the issue has such an obvious work-around, I suspect the full fix to be a very low priority.

The method to raise the file descriptor limit varies by OS, so I would go with a generic description of the issue and its workaround: "Running functional tests can fail with repeated errors opening files and other resources. If this occurs, check directory permissions and the limit on open file descriptors. The latter needs to be at least 8000."

If the wording is acceptable, I'm happy to submit a PR with the change.

@dbeatty10
Copy link
Contributor

That language would work for a PR 👍

Our integration testing framework uses pytest to create and run stand-alone dbt projects. There's probably hundreds of these.

One way to see more useful error messages:

ulimit -n 256
python3 -m pytest tests/functional

@ezraerb
Copy link
Contributor Author

ezraerb commented Apr 12, 2023

I'll submit the PR to document the workaround, and leave this ticket open for the fuller investigation.

@ezraerb
Copy link
Contributor Author

ezraerb commented Apr 12, 2023

PR submitted for the workaround note: #7343

@github-actions
Copy link
Contributor

This issue has been marked as Stale because it has been open for 180 days with no activity. If you would like the issue to remain open, please comment on the issue or else it will be closed in 7 days.

@github-actions github-actions bot added the stale Issues that have gone stale label Oct 10, 2023
@dbeatty10
Copy link
Contributor

Here's the workaround within dbt-duckdb within conftest.py:

soft_limit, hard_limit = resource.getrlimit(resource.RLIMIT_NOFILE)
resource.setrlimit(resource.RLIMIT_NOFILE, (hard_limit, hard_limit))

@dbeatty10 dbeatty10 removed the stale Issues that have gone stale label Oct 10, 2023
@dbeatty10 dbeatty10 linked a pull request Mar 22, 2024 that will close this issue
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