Skip to content

Possible bug with dogstatsd deadlock #834

Open

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

Activity

  1. added
    kind/bug
    on Jun 14, 2024
  2. vickenty commented on Jun 21, 2024

    @vickenty
    Contributor

    Thank you for reporting the issue.

    While we are working on a fix. In the meantime, you can work around the issue by disabling fork support by setting the DD_DOGSTATSD_DISABLE_FORK_SUPPORT environment variable before importing the datadog package.

  3. github-actions commented on Jul 22, 2024

    @github-actions

    Thanks for your contribution!

    This issue has been automatically marked as stale because it has not had activity in the last 30 days. Note that the issue will not be automatically closed, but this notification will remind us to investigate why there's been inactivity. Thank you for participating in the Datadog open source community.

    If you would like this issue to remain open:

    1. Verify that you can still reproduce the issue in the latest version of this project.

    2. Comment that the issue is still reproducible and include updated details requested in the issue template.

  4. added
    stale
    on Jul 22, 2024
  5. mazad01 commented on Jul 22, 2024

    @mazad01
    Author

    Not stale, still waiting for resolution. Thanks

  6. anupamdialpad commented on Jul 25, 2024

    @anupamdialpad

    What are the side effects of setting DD_DOGSTATSD_DISABLE_FORK_SUPPORT?

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugstale

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions