stream模式,为啥receiver卡死的情况下,导致sender也卡死了? 一直卡在BRPC_HANDLE_EOVERCROWDED这个宏里

Open
#3,336 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Quiet
Tech stack
cpp
Domain
networking

Research direction

Start with brpc::Stream::WriteToHostSocket, Stream::CutMessageIntoFileDescriptor, and the BRPC_HANDLE_EOVERCROWDED and BRPC_HANDLE_EOVERCROWDED_N definitions and call sites. Reproduce the stream write with a blocked receiver, compare the two macro behaviors, and determine whether the sender's prolonged sleep is expected or indicates a bug; document the conclusion with a focused regression case if needed.

Written by the indexing model from the issue text.

Description

堆栈(Stack)

Stack:
#0 0x00007f7410dc6a41 clock_nanosleep@@GLIBC_2.17
#1 0x00007f7410dcbf67 __nanosleep
#2 0x00007f7410df7a49 usleep
#3 0x000000000121c897 bthread_usleep
#4 0x00000000013412e1 brpc::Stream::WriteToHostSocket(butil::IOBuf*)
#5 0x0000000001343b3a brpc::Stream::CutMessageIntoFileDescriptor(int, butil::IOBuf**, unsigned long)
#6 0x0000000001331712 brpc::Socket::StartWrite(brpc::Socket::WriteRequest*, brpc::Socket::WriteOptions const&)
#7 0x0000000001331b92 brpc::Socket::Write(butil::IOBuf*, brpc::Socket::WriteOptions const*)
#8 0x0000000001341464 brpc::Stream::AppendIfNotFull(butil::IOBuf const&)
#9 0x0000000001342ce4 brpc::StreamWrite(unsigned long, butil::IOBuf const&)
#10 0x0000000000bc87aa proxima::centaur::kafka_proxy::KafkaProxyService::send_task_job()
#11 0x00007f74110e8b74 execute_native_thread_routine
#12 0x00007f74123b73f9 start_thread
#13 0x00007f7410dffb13 __clone

宏定义代码
// Sleep a while when `write_expr' returns negative with errno=EOVERCROWDED
// Implemented as a macro rather than a field of Socket.WriteOptions because
// the macro works for other functions besides Socket.Write as well.
#define BRPC_HANDLE_EOVERCROWDED(write_expr)                       \
    ({                                                                  \
        int64_t __ret_code__;                                           \
        int sleep_time = 250;                                           \
        while (true) {                                                  \
            __ret_code__ = (write_expr);                                \
            if (__ret_code__ >= 0 || errno != ::brpc::EOVERCROWDED) { \
                break;                                                  \
            }                                                           \
            sleep_time *= 2;                                            \
            if (sleep_time > 2000) { sleep_time = 2000; }               \
            ::bthread_usleep(sleep_time);                               \
        }                                                               \
        __ret_code__;                                                   \
    })

我看还有个BRPC_HANDLE_EOVERCROWDED_N, 想请教下当时没有用_N,是基于什么考虑呢?

Dominant language
C++
Stars
17.6k
Forks
4.2k
Avg merge
3d 17h
Merged PRs (30d)
72

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/brpc

All issues in apache/brpc

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.