Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

AF_UNIX path too long #404

Closed
ChihChengLiang opened this issue Mar 15, 2019 · 4 comments
Closed

AF_UNIX path too long #404

ChihChengLiang opened this issue Mar 15, 2019 · 4 comments

Comments

@ChihChengLiang
Copy link
Contributor

  • py-evm Version: py-evm==0.2.0a42
  • OS: osx
  • Python Version (python --version): Python 3.7.0
  • Environment (output of pip freeze):

What is wrong?

To reproduce

pytest -s tests/integration/test_trinity_cli.py::test_web3[command0]

Error message


tests/integration/test_trinity_cli.py b'    INFO  03-15 12:37:40               trinity  \n'
b'      ______     _       _ __       \n'
b'     /_  __/____(_)___  (_) /___  __\n'
b'      / / / ___/ / __ \\/ / __/ / / /\n'
b'     / / / /  / / / / / / /_/ /_/ / \n'
b'    /_/ /_/  /_/_/ /_/_/\\__/\\__, /  \n'
b'                           /____/   \n'
b'    INFO  03-15 12:37:40               trinity  Started main process (pid=49940)\n'
b'    INFO  03-15 12:37:40               trinity  Trinity/0.1.0a23/darwin/cpython3.7.0\n'
b'    INFO  03-15 12:37:40               trinity  Trinity DEBUG log file is created at /private/var/folders/cb/yk2xzls57qg9f5d18hps4q8w0000gn/T/pyt--liangcc/54/test_web3_command0_0/t/mainnet/logs-eth1/trinity.log\n'
b'Traceback (most recent call last):\n'
b'  File "/usr/local/var/pyenv/versions/3.7.0/envs/py-evm/bin/trinity", line 11, in <module>\n'
b"    load_entry_point('trinity', 'console_scripts', 'trinity')()\n"
b'  File "/Users/liangcc/projects/EAPL/eth2.0s/trinity/trinity/main.py", line 85, in main\n'
b'    main_entry(trinity_boot, APP_IDENTIFIER_ETH1, get_all_plugins(), (Eth1AppConfig,))\n'
b'  File "/Users/liangcc/projects/EAPL/eth2.0s/trinity/trinity/bootstrap.py", line 203, in main_entry\n'
b'    main_endpoint.start_serving_nowait(main_connection_config)\n'
b'  File "/usr/local/var/pyenv/versions/3.7.0/envs/py-evm/lib/python3.7/site-packages/lahja/endpoint.py", line 156, in start_serving_nowait\n'
b'    self._create_external_api(self._ipc_path)\n'
b'  File "/usr/local/var/pyenv/versions/3.7.0/envs/py-evm/lib/python3.7/site-packages/lahja/endpoint.py", line 231, in _create_external_api\n'
b'    server = manager.get_server()   # type: ignore\n'
b'  File "/usr/local/var/pyenv/versions/3.7.0/lib/python3.7/multiprocessing/managers.py", line 505, in get_server\n'
b'    self._authkey, self._serializer)\n'
b'  File "/usr/local/var/pyenv/versions/3.7.0/lib/python3.7/multiprocessing/managers.py", line 145, in __init__\n'
b'    self.listener = Listener(address=address, backlog=16)\n'
b'  File "/usr/local/var/pyenv/versions/3.7.0/lib/python3.7/multiprocessing/connection.py", line 438, in __init__\n'
b'    self._listener = SocketListener(address, family, backlog)\n'
b'  File "/usr/local/var/pyenv/versions/3.7.0/lib/python3.7/multiprocessing/connection.py", line 581, in __init__\n'
b'    self._socket.bind(address)\n'
b'OSError: AF_UNIX path too long\n'
b''
F

======================================================================== FAILURES ========================================================================
__________________________________________________________________ test_web3[command0] ___________________________________________________________________

command = ('trinity',), async_process_runner = <trinity.tools.async_process_runner.AsyncProcessRunner object at 0x10e1a7860>

    @pytest.mark.parametrize(
        'command',
        (
            ('trinity', ),
        )
    )
    @pytest.mark.asyncio
    async def test_web3(command, async_process_runner):
        await async_process_runner.run(command, timeout_sec=20)
>       assert await contains_all(async_process_runner.stderr, {
            "Started DB server process",
            "Started networking process",
            "IPC started at",
        })
E       assert False

async_process_runner = <trinity.tools.async_process_runner.AsyncProcessRunner object at 0x10e1a7860>
command    = ('trinity',)

tests/integration/test_trinity_cli.py:121: AssertionError

How can it be fixed

Not investigate hard yet.

@pipermerriam
Copy link
Member

Unix has a maximum path length for sockets. We've encountered this before. Take a look at the line that shows the logfile path

/private/var/folders/cb/yk2xzls57qg9f5d18hps4q8w0000gn/T/pyt--liangcc/54/test_web3_command0_0/t/

This code is supposed to keep that path short:

trinity/tests/conftest.py

Lines 77 to 102 in 40c3ffb

@pytest.fixture(autouse=True)
def xdg_trinity_root(monkeypatch, tmpdir):
"""
Ensure proper test isolation as well as protecting the real directories.
"""
trinity_root_dir = str(tmpdir.mkdir('t'))
# The default path that pytest generates are too long to be allowed as
# IPC Paths (hard UNIX rule). We are shorten them from something like:
# /tmp/pytest-of-<username>/pytest-88/<test-name>_command1_0/trinity
# to /tmp/pyt-<username>/88/<test-name>_command1_0/t
fragment1 = 'pytest-of'
fragment2 = 'pytest-'
expected_fragments = (fragment1, fragment2)
# If pytest ever changes the tmpdir generation layout, this breaks and we adapt
is_expected_path = all(check_str in trinity_root_dir for check_str in expected_fragments)
assert is_expected_path, f"Unexpected pytest tmp dir: {trinity_root_dir}, expected fragments: {expected_fragments}" # noqa: E501
trinity_root_dir = trinity_root_dir.replace(fragment1, 'pyt-').replace(fragment2, '')
monkeypatch.setenv('XDG_TRINITY_ROOT', trinity_root_dir)
assert not is_under_path(os.path.expandvars('$HOME'), get_xdg_trinity_root())
return Path(trinity_root_dir)

But it appears to not be working correctly for whatever your environment is producing.

@ralexstokes
Copy link
Member

ralexstokes commented Mar 16, 2019

i'll just +1 that i also saw this when i was sorting through some strange CI failure.

the obvious difference is that @ChihChengLiang and i are running this on mac os. can't remember if i have seen this on circleci.com or not but i suppose not.

update: same issue reported here:
ethereum/web3.py#929

@pipermerriam
Copy link
Member

We should setup some smoke tests on CircleCI for OSX since I'm pretty sure they offer it as an environment we can test against.

@webknjaz
Copy link

webknjaz commented Jun 9, 2019

FTR: https://github.com/agronholm/anyio/pull/42/files#diff-f0c1c7497545019b8489fa8bc06be6cdR208

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants