Sitelet https://github.com/Netis/cloud-probe/issues/260
Skip to content

cpworker: control socket listen backlog is 1; concurrent Go clients fail with EAGAIN #260

Description

@vaderyang

Environment

  • CP version: v0.9.4 (f925e5f6)

Description

The cpworker control socket listens with a backlog of 1. ss -xl on a running worker shows LISTEN 0 1 .../cpworker.sock.

Go dials unix sockets non-blocking, and a full backlog makes connect fail immediately with EAGAIN instead of waiting. Both cpctl and cpdaemon connect through cpgolib/cpworker/unix_client.go. So whenever two clients connect at nearly the same time, the second one fails. For example, cpdaemon's periodic stats collection can overlap with an operator's cpctl stats or a reload.

With 32 clients connecting at once, 29 fail with connect: resource temporarily unavailable.

Steps to reproduce

TestControlProtocol/concurrent_clients in cpworker/tests/integration/control_protocol_test.go (branch feat/verification-coverage).

Expected

Concurrent clients are queued and served. For example, use listen(fd, SOMAXCONN).

Actual

Every connection beyond the first pending one fails with EAGAIN.


中文原文

测试环境

  • CP 版本:v0.9.4(f925e5f6)

问题描述

cpworker 控制 socket 的 listen backlog 为 1(运行中 ss -xl 显示 LISTEN 0 1 .../cpworker.sock)。Go 以非阻塞方式 dial unix socket,backlog 满时 connect 立即返回 EAGAIN 而不是等待。cpctl 与 cpdaemon 都通过 cpgolib/cpworker/unix_client.go 连接,因此两个客户端几乎同时连接时(例如 cpdaemon 定期采集统计与运维的 cpctl stats 或 reload 重叠)后者失败。

32 个客户端同时连接,29 个报 connect: resource temporarily unavailable。

复现

feat/verification-coverage 分支 cpworker/tests/integration/control_protocol_test.go 的 TestControlProtocol/concurrent_clients。

期望

并发客户端排队并得到服务(例如 listen(fd, SOMAXCONN))。

实际

第一个等待中的连接之外全部 EAGAIN。

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions