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

backend: fix the bug that the redirection signal may be discarded #75

Merged
merged 2 commits into from
Sep 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions pkg/proxy/backend/backend_conn_mgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func NewBackendConnManager(connectionID uint64) *BackendConnManager {
connectionID: connectionID,
cmdProcessor: NewCmdProcessor(),
authenticator: &Authenticator{},
signalReceived: make(chan struct{}),
signalReceived: make(chan struct{}, 1),
redirectResCh: make(chan *redirectResult, 1),
}
}
Expand Down Expand Up @@ -292,10 +292,8 @@ func (mgr *BackendConnManager) Redirect(newAddr string) {
atomic.StorePointer(&mgr.signal, unsafe.Pointer(&signalRedirect{
newAddr: newAddr,
}))
select {
case mgr.signalReceived <- struct{}{}:
default:
}
// Generally, it won't wait because the caller won't send another signal because the last one finishes.
mgr.signalReceived <- struct{}{}
}

// GetRedirectingAddr implements RedirectableConn.GetRedirectingAddr interface.
Expand Down