Skip to content

Possible bug with dogstatsd deadlock #834

@mazad01

Description

@mazad01

Describe the bug
Code is hanging on datadog's post_fork() function. Possibly https://github.com/DataDog/datadogpy/blob/master/datadog/dogstatsd/base.py#L976 ?

Expected behavior
Dogstatsd lib references not deadlocking

Environment and Versions (please complete the following information):
dogstatsd 0.49.1

Additional context
From our developers: the parent code is trying to spawn subprocesses, but it ultimately hangs

i.e snip of the code:

 process = subprocess.Popen(
        cmd,
        stdout=subprocess.PIPE,
        stderr=subprocess.STDOUT,
        shell=True,
        text=True,
        preexec_fn=_set_pdeathsig(
            signal.SIGTERM
        ),  # ensure terminate subproc if this proc dies
    )


def _set_pdeathsig(sig=signal.SIGTERM):
    """Return a callable that terminates the subprocess."""
    libc = ctypes.CDLL("libc.so.6")

    def callable():
        return libc.prctl(1, sig)

    return callable

Output of pyspy:

Thread 1733153 (idle): "Thread-52 (process_items)"
    close_socket (datadog/dogstatsd/base.py:933)
    post_fork (datadog/dogstatsd/base.py:1369)
    post_fork (datadog/dogstatsd/base.py:120)
    _execute_child (subprocess.py:1796)
    __init__ (subprocess.py:971)
...

Output of strace

strace: Process 1733153 attached
futex(0x5644f988f040, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugBug related issuestaleStale - Bot reminder

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions