apache / apache/brpc

naming_service_thread still falls into loop when it has found ServerNode

Open
#1,933 0 comments 0 reactions 0 assignees View on GitHub
help wanted module/extensions/naming-service
Dominant language
C++
Stars
17.6k
Forks
4.1k
Avg merge
2d 12h
Merged PRs (30d)
69

Description

**Describe the bug (描述bug)**
I use following `channel Init` API to resolve full dns hostname.
```c++

std::string naming_service_url("http://myhost0.local:8002");
const char *load_balancer_name = "random";
brpc::Channel channel;
if (0 != channel.Init(naming_service_url.c_str(), load_balancer_name, nullptr) )
{
xxxxxx
}

```
Another two hosts called `myhost1.local`, `myhost2.local` , use above API to init brpc channel.
But got following logs,
```
I0923 09:32:26.908915 29 /data/workspace/brpc/src/brpc/details/naming_service_thread.cpp:202] brpc::policy::DomainNamingService("myhost0.local:8002"): added 1
W0923 09:32:30.874791 54 /data/workspace/brpc/src/brpc/details/naming_service_thread.cpp:305] `http://myhost0.local:8002' is empty! RPC over the channel will fail until servers appear
W0923 09:32:35.877102 54 /data/workspace/brpc/src/brpc/details/naming_service_thread.cpp:305] `http://myhost0.local:8002' is empty! RPC over the channel will fail until servers appear
W0923 09:32:40.879414 54 /data/workspace/brpc/src/brpc/details/naming_service_thread.cpp:305] `http://myhost0.local:8002' is empty! RPC over the channel will fail until servers appear
W0923 09:32:45.881746 54 /data/workspace/brpc/src/brpc/details/naming_service_thread.cpp:305] `http://myhost0.local:8002' is empty! RPC over the channel will fail until servers appear
W0923 09:32:50.884365 54 /data/workspace/brpc/src/brpc/details/naming_service_thread.cpp:305] `http://myhost0.local:8002' is empty! RPC over the channel will fail until servers appear
W0923 09:32:55.886679 54 /data/workspace/brpc/src/brpc/details/naming_service_thread.cpp:305] `http://myhost0.local:8002' is empty! RPC over the channel will fail until servers appear
W0923 09:33:00.889066 54 /data/workspace/brpc/src/brpc/details/naming_service_thread.cpp:305] `http://myhost0.local:8002' is empty! RPC over the channel will fail until servers appear
W0923 09:33:05.891879 54 /data/workspace/brpc/src/brpc/details/naming_service_thread.cpp:305] `http://myhost0.local:8002' is empty! RPC over the channel will fail until servers appear
W0923 09:33:10.894347 54 /data/workspace/brpc/src/brpc/details/naming_service_thread.cpp:305] `http://myhost0.local:8002' is empty! RPC over the channel will fail until servers appear
```
It seems that the other two hosts has resolved the host, but still print `empty` cyclically.
There are also other three port served on host`myhost0.local` named `8000, 8001, 8003`, but those are resolved well since there is nothing to print cyclically as above.
By the way, the dns name `myhost0.local:8002` could be resolved by command shell (`nslookup` or `telnet`) in terminal on the other two hosts.

**To Reproduce (复现方法)**

**Expected behavior (期望行为)**

**Versions (各种版本)**
OS: ubuntu 20.04
Compiler: gcc
brpc: master d0b71ffc34b73cbec39cd9773b01137f85b4ffde
protobuf: 3.6.1

**Additional context/screenshots (更多上下文/截图)**

Contributor guide

Open the contributing guide

Research direction

Start in src/brpc/details/naming_service_thread.cpp around the log sites at lines 202 and 305, then reproduce the channel.Init call with myhost0.local:8002 and the random load balancer. Compare the ServerNode discovery with the ports that resolve normally. Done means a successfully resolved ServerNode no longer produces repeated “is empty” warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.