Skip to content

单进程持续写管道超出缓冲区导致进程无限阻塞 #132

@hsbyhub

Description

@hsbyhub

感谢阿里团队开源精神,目前我们在生产环境中大规模部署了tsar, 发现了这个bug,希望对大家有帮助。
在src/output_tcp.c中的output_multi_tcp方法将标准输出重定向到pipe,接下来调用running_check将输出内容到管道,管道默认阻塞模式, 缓冲区一般是8-64k, 缓冲区不足写时,将阻塞进程,造成资源泄漏。
目前我的解决方法为申请pipe后,使用fcntl(out_pipe[1], F_SETPIPE_SZ, LEN_10M) 调整pipe缓冲区大小为足够大,值得注意的是,F_SETPIPE_SZ需要引入/usr/include/linux/fcntl.h才有这个标志。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions