Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grpc be closed when uninstall service target #807

Closed
qqwx1986 opened this issue Dec 17, 2020 · 1 comment
Closed

grpc be closed when uninstall service target #807

qqwx1986 opened this issue Dec 17, 2020 · 1 comment

Comments

@qqwx1986
Copy link

there two problems

  1. target connect will close while one target uninstall by method grpcConnectionPool::cleanup(),it's 5s interval check
    I uninstall the service of the current target. Although I refused new grpc request right now ,But I need to finish processing the grpc requests currently being processed before disconnecting

  2. grpc_handle.go function hasTarget compare by pointer(target address) to check target whether exist in route.Table, code main.go method watchBackend will NewTable every time while service refresh,so if one service had three target,if just one target uninstall from service ,other two target also will closed by cleanup() ,i think it need reuse old target connect

@qqwx1986
Copy link
Author

qqwx1986 commented Dec 18, 2020

i resovled my problem

func (p *grpcConnectionPool) cleanup() {
	for {
		p.lock.Lock()
		table := route.GetTable()
		for target, cs := range p.connections {
			if cs.GetState() == connectivity.Shutdown {
				delete(p.connections, target)
				continue
			}
			if !hasTarget(target, table) {
				if cs.GetState() != connectivity.Ready {//delete If not ready
					log.Println("[DEBUG] grpc: cleaning up connection to", target.URL.Host,cs.GetState())
					cs.Close()
					delete(p.connections, target)
				}
			}
		}
		p.lock.Unlock()
		time.Sleep(p.cleanupInterval)
	}
}

func hasTarget(target *route.Target, table route.Table) bool {
	for _, routes := range table {
		for _, r := range routes {
			for _, t := range r.Targets {
				if target.URL.Host == t.URL.Host {//compare by HOST
					return true
				}
			}
		}
	}
	return false
}

nathanejohnson added a commit that referenced this issue Jul 12, 2022
fixes #807 - changes map for grpc connections to be a string key
nathanejohnson added a commit that referenced this issue Nov 18, 2022
…ing GRPC connections.

This should address part 1 of #807 and #912
nathanejohnson added a commit that referenced this issue Nov 18, 2022
…ing GRPC connections.

This should address part 1 of #807 and #912

update grpc docs
nathanejohnson added a commit that referenced this issue Nov 18, 2022
This should address part 1 of #807 and #912

update grpc docs
nathanejohnson added a commit that referenced this issue Nov 18, 2022
This should address part 1 of #807 and #912

update grpc docs
nathanejohnson added a commit that referenced this issue Nov 18, 2022
This should address part 1 of #807 and #912

update grpc docs
nathanejohnson added a commit that referenced this issue Nov 18, 2022
This should address part 1 of #807 and #912

update grpc docs
nathanejohnson added a commit that referenced this issue Nov 18, 2022
This should address part 1 of #807 and #912

update grpc docs
nathanejohnson added a commit that referenced this issue Nov 18, 2022
This should address part 1 of #807 and #912

update grpc docs
nathanejohnson added a commit that referenced this issue Dec 10, 2022
This should address part 1 of #807 and #912

update grpc docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant