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

planemo tests timing out and ASGI error #13136

Closed
bernt-matthias opened this issue Jan 8, 2022 · 10 comments
Closed

planemo tests timing out and ASGI error #13136

bernt-matthias opened this issue Jan 8, 2022 · 10 comments

Comments

@bernt-matthias
Copy link
Contributor

Describe the bug

When running planemo test on a few (two) tools of the IUC repo I see the following error after Galaxy started and the tool test execution stalls reproducibly.

ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/uvicorn/protocols/http/h11_impl.py", line 373, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
    return await self.app(scope, receive, send)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/fastapi/applications.py", line 208, in __call__
    await super().__call__(scope, receive, send)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/middleware/errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette_context/middleware/raw_middleware.py", line 96, in __call__
    await self.app(scope, receive, send_wrapper)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/middleware/base.py", line 65, in __call__
    task_group.cancel_scope.cancel()
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 574, in __aexit__
    raise exceptions[0]
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/middleware/base.py", line 34, in coro
    await self.app(scope, request.receive, send_stream.send)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/routing.py", line 656, in __call__
    await route.handle(scope, receive, send)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/routing.py", line 408, in handle
    await self.app(scope, receive, send)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/middleware/wsgi.py", line 64, in __call__
    await responder(receive, send)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/middleware/wsgi.py", line 91, in __call__
    await anyio.to_thread.run_sync(self.wsgi, environ, self.start_response)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 572, in __aexit__
    raise ExceptionGroup(exceptions)
anyio._backends._asyncio.ExceptionGroup: 2 exceptions were raised in the task group:
----------------------------
Traceback (most recent call last):
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/middleware/wsgi.py", line 98, in sender
    await send(message)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/exceptions.py", line 68, in sender
    await send(message)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/streams/memory.py", line 193, in send
    self.send_nowait(item)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/streams/memory.py", line 177, in send_nowait
    raise BrokenResourceError
anyio.BrokenResourceError
----------------------------
Traceback (most recent call last):
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/middleware/wsgi.py", line 91, in __call__
    await anyio.to_thread.run_sync(self.wsgi, environ, self.start_response)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/to_thread.py", line 28, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(func, *args, cancellable=cancellable,
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 818, in run_sync_in_worker_thread
    return await future
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 754, in run
    result = context.run(func, *args)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/middleware/wsgi.py", line 131, in wsgi
    anyio.from_thread.run(
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/from_thread.py", line 35, in run
    return asynclib.run_async_from_thread(func, *args)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 847, in run_async_from_thread
    return f.result()
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 444, in result
    return self.__get_result()
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 389, in __get_result
    raise self._exception
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/streams/memory.py", line 193, in send
    self.send_nowait(item)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/streams/memory.py", line 177, in send_nowait
    raise BrokenResourceError
anyio.BrokenResourceError

2022-01-08 18:19:39,334 ERROR [uvicorn.error] Exception in ASGI application
Traceback (most recent call last):
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/uvicorn/protocols/http/h11_impl.py", line 373, in run_asgi
    result = await app(self.scope, self.receive, self.send)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
    return await self.app(scope, receive, send)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/fastapi/applications.py", line 208, in __call__
    await super().__call__(scope, receive, send)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/applications.py", line 112, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/middleware/errors.py", line 159, in __call__
    await self.app(scope, receive, _send)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette_context/middleware/raw_middleware.py", line 96, in __call__
    await self.app(scope, receive, send_wrapper)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/middleware/base.py", line 65, in __call__
    task_group.cancel_scope.cancel()
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 574, in __aexit__
    raise exceptions[0]
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/middleware/base.py", line 34, in coro
    await self.app(scope, request.receive, send_stream.send)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/exceptions.py", line 71, in __call__
    await self.app(scope, receive, sender)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/routing.py", line 656, in __call__
    await route.handle(scope, receive, send)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/routing.py", line 408, in handle
    await self.app(scope, receive, send)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/middleware/wsgi.py", line 64, in __call__
    await responder(receive, send)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/middleware/wsgi.py", line 91, in __call__
    await anyio.to_thread.run_sync(self.wsgi, environ, self.start_response)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 572, in __aexit__
    raise ExceptionGroup(exceptions)
anyio._backends._asyncio.ExceptionGroup: 2 exceptions were raised in the task group:
----------------------------
Traceback (most recent call last):
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/middleware/wsgi.py", line 98, in sender
    await send(message)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/exceptions.py", line 68, in sender
    await send(message)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/streams/memory.py", line 193, in send
    self.send_nowait(item)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/streams/memory.py", line 177, in send_nowait
    raise BrokenResourceError
anyio.BrokenResourceError
----------------------------
Traceback (most recent call last):
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/middleware/wsgi.py", line 91, in __call__
    await anyio.to_thread.run_sync(self.wsgi, environ, self.start_response)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/to_thread.py", line 28, in run_sync
    return await get_asynclib().run_sync_in_worker_thread(func, *args, cancellable=cancellable,
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 818, in run_sync_in_worker_thread
    return await future
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 754, in run
    result = context.run(func, *args)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/starlette/middleware/wsgi.py", line 131, in wsgi
    anyio.from_thread.run(
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/from_thread.py", line 35, in run
    return asynclib.run_async_from_thread(func, *args)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/_backends/_asyncio.py", line 847, in run_async_from_thread
    return f.result()
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 444, in result
    return self.__get_result()
  File "/usr/lib/python3.8/concurrent/futures/_base.py", line 389, in __get_result
    raise self._exception
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/streams/memory.py", line 193, in send
    self.send_nowait(item)
  File "/home/berntm/.planemo/gx_venv_3.7/lib/python3.8/site-packages/anyio/streams/memory.py", line 177, in send_nowait
    raise BrokenResourceError
anyio.BrokenResourceError

Tool tests stall at a line similar to (only ids differ):

Setup for job Job[unflushed,tool_id=macs2_callpeak] complete, ready to be enqueued (22.027 ms)
2022-01-08 18:40:41,618 INFO  [galaxy.web_stack.handlers] (Job[id=3,tool_id=macs2_callpeak]) Handler '_default_' assigned using 'HANDLER_ASSIGNMENT_METHODS.DB_SKIP_LOCKED' assignment method

Galaxy Version and/or server at which you observed the bug
Galaxy Version: dev
Commit: 060ab1a

To Reproduce
Steps to reproduce the behavior:

Run either

  • planemo test --biocontainers --no_dependency_resolution --no_conda_auto_init --galaxy_python_version 3.7 --galaxy_source https://github.com/galaxyproject/galaxy --galaxy_branch dev tools/macs2/macs2_callpeak.xml or
  • planemo test --biocontainers --no_dependency_resolution --no_conda_auto_init --galaxy_python_version 3.7 --galaxy_source https://github.com/galaxyproject/galaxy --galaxy_branch dev tools/pygenometracks/pyGenomeTracks.xml

macs2 stalls at the first test and pygenoetracs at test 17

Expected behavior

Screenshots

Additional context

Might be the cause of the tests timing out in the tests of #13039 here galaxyproject/tools-iuc#4318

@nsoranzo
Copy link
Member

nsoranzo commented Jan 8, 2022

Can you please check if galaxy at the commit before that also exhibit the same issue? #13135 updated starlette and fastapi, and could be the cause for BrokenResourceError.

@bernt-matthias
Copy link
Contributor Author

bernt-matthias commented Jan 8, 2022

Did a git bisect between 21.09 and dev. It appears that the stalling and the traceback are unrelated

@bernt-matthias
Copy link
Contributor Author

For a5b1452 the changes in lib/galaxy/util/__init__.py look fishy on first glance ... try without except?

@mvdbeek
Copy link
Member

mvdbeek commented Jan 9, 2022

Can you check if #13137 fixes it for you ? I could see the test hang if the metadata is in error ... . If that is true we need to find a way to error out quickly.

bernt-matthias added a commit to bernt-matthias/galaxy that referenced this issue Jan 10, 2022
If no check or skip is given, self.check and self.skip
need to be initialised to None. Otherwise validation with
`value.missing_meta(check=self.check, skip=self.skip)`
is called with `value.missing_meta(check=[""], skip=[""])`.

This led to the stalling observed in
galaxyproject#13136

Explanation: each data input parameter automatically gets
a MetadataValidator. Since this validator was dysfunctional
the job was scheduled anyway, but did not execute.
@mvdbeek mvdbeek added this to the 22.01 milestone Jan 17, 2022
@mvdbeek
Copy link
Member

mvdbeek commented Jan 21, 2022

@davelopez do we still need to downgrade fastAPI ? I see a lot of anyio.BrokenResourceError exceptions. I thought they were supposed to be fixed, but seems it's still an issue

@davelopez
Copy link
Contributor

Yeah, I also thought it was fixed but I guess it is still an issue tiangolo/fastapi#4041 so probably we should downgrade again.

@nsoranzo
Copy link
Member

Is it a real issue of just polluting the logs?

@davelopez
Copy link
Contributor

That's a good question, some people claim it is fixed and some are silencing it but I'm afraid I don't know if that's a good idea or what are the consequences.

@mvdbeek
Copy link
Member

mvdbeek commented Jan 21, 2022

Yeah, all of these are kind of "logging issues". It happens when the client goes away and we write to a closed socket. You can see that the fix in https://github.com/encode/starlette/pull/1262/files is to pick up the right exception from the coroutine, I suppose that something similar should be done for the WSGI middleware we're using (which doesn't seem to be based on BaseHTTPMiddleware that got fixed). A good start might be to write a small client test

@mvdbeek
Copy link
Member

mvdbeek commented Jan 21, 2022

It might not be the closed socket issue ....

import time
import uvicorn
from fastapi import FastAPI
from fastapi.middleware.wsgi import WSGIMiddleware


def wsgi_application(env, start_response):
    print('start')
    time.sleep(0.3)
    start_response("200 OK", {})
    print('done')
    return [b'bla']

app = FastAPI()
app.mount('/', WSGIMiddleware(wsgi_application))


if __name__ == "__main__":
    uvicorn.run(app="timeoutapp:app", port=8001)

And then curl http://127.0.0.1:8001/ --max-time 0.1 doesn't lead to the exception. Explicitly raising an exception is also fine and doesn't print the whole anyio stacktrace ... odd. I could have sworn i've seen it in the tests recently. But I guess we can close that for now until we see it again in Galaxy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants