Skip to content

Dead lock in context init #3381

@matejsp

Description

@matejsp

Describe your environment
We are using python 3.8 on Amazon Linux 2 and opentelemetry version 1.18. We have django application and are using it inside docker.

When calling

docker-compose run --rm app bash -c "echo \"show tables; exit \" | ./manage.py dbshell -- -A | grep auth_user_groups"

with tracing enabled the app is frozen and stuck in opentelemetry code when obtaining runtime context lock and it is not released. This code runs external process (mysql) based on the django configuration and does not create multiple threads (except jaeger exporter that we use):

Traceback (most recent call last):
  File "/app/common/gc/metrics.py", line 65, in callback
    self.trace = tracing.trace_op(OPERATION_NAME)
  File "/opt/virtualenvs/py38/lib64/python3.8/site-packages/btspython/tracing/tracer.py", line 296, in trace_op
    self.ensure_request_trace_id()
  File "/opt/virtualenvs/py38/lib64/python3.8/site-packages/btspython/tracing/tracer.py", line 366, in ensure_request_trace_id
    request_trace_id = baggage_api.get_baggage("request-trace-id")  # type: ignore
  File "/opt/virtualenvs/py38/lib64/python3.8/site-packages/opentelemetry/baggage/__init__.py", line 67, in get_baggage
    return get_all(context=context).get(name)
  File "/opt/virtualenvs/py38/lib64/python3.8/site-packages/opentelemetry/baggage/__init__.py", line 47, in get_all
    baggage = get_value(_BAGGAGE_KEY, context=context)
  File "/opt/virtualenvs/py38/lib64/python3.8/site-packages/opentelemetry/context/__init__.py", line 102, in get_value
    return context.get(key) if context is not None else get_current().get(key)
  File "/opt/virtualenvs/py38/lib64/python3.8/site-packages/opentelemetry/context/__init__.py", line 48, in wrapper
    with _RUNTIME_CONTEXT_LOCK:
KeyboardInterrupt:
opentelemetry-api==1.18.0
opentelemetry-exporter-jaeger-thrift==1.18.0
opentelemetry-sdk==1.18.0
opentelemetry-semantic-conventions==0.39b0

Any idea how to track down this issue?
Maybe some context is unable to initialize? where do i get a list?

Steps to reproduce
It is not realiably reproducible (it works on local machine).

What is the expected behavior?
Not to lock.

What is the actual behavior?
It deadlocks and never completes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions