Skip to content

DialContext will be blocked if no address exists when use a name target #976

@ruinanchen

Description

@ruinanchen

hi, my question as below:

  1. I use grpc balance, so I init a grpcclient use function grpc.Dial with parameter service name:
    conn, err = grpc.Dial(servicename,...,grpc.WithBalancer(balancer))

  2. the function grpc.Dial use DialContext, and my master routine will block here:
    ch := cc.dopts.balancer.Notify()
    if ch == nil {
    // There is no name resolver installed.
    addrs = append(addrs, Address{Addr: target})
    } else {
    addrs, ok = <-ch
    if !ok || len(addrs) == 0 {
    waitC <- errNoAddr
    return
    }
    }

Because of no address available, there is not element([]Address) input into the channel.So, the dial will return "grpc: timed out when dialing".

  1. I can change it, input a empty []Address when actually no address in initialization phase, but it satisfys:
    if !ok || len(addrs) == 0 {

so dial will also return an error,and it is "grpc: there is no address available to dial" .

In our system, we have much processes implement different serivce. Unfortunately, these processes is a situation of mutual dependence. So I can't init any first process because i make it exit when dial fail, saddly this will lead to i can't start our system.

Actually I just hope dial return a grpc.ClientConn even if there is no address available.I think this can solve my problem.

Metadata

Metadata

Assignees

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