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

Memory leak caused by watch #7807

Closed
rleungx opened this issue Feb 5, 2024 · 0 comments · Fixed by #7806
Closed

Memory leak caused by watch #7807

rleungx opened this issue Feb 5, 2024 · 0 comments · Fixed by #7806
Labels

Comments

@rleungx
Copy link
Member

rleungx commented Feb 5, 2024

Bug Report

Screenshot 2024-02-05 at 15 42 26

for {
select {
case <-ctx.Done():
return nil
case res := <-watchChan:
if res.Err() != nil {
var resp meta_storagepb.WatchResponse
if startRevision < res.CompactRevision {
resp.Header = s.wrapErrorAndRevision(res.Header.GetRevision(), meta_storagepb.ErrorType_DATA_COMPACTED,
fmt.Sprintf("required watch revision: %d is smaller than current compact/min revision %d.", startRevision, res.CompactRevision))
resp.CompactRevision = res.CompactRevision
} else {
resp.Header = s.wrapErrorAndRevision(res.Header.GetRevision(), meta_storagepb.ErrorType_UNKNOWN,
fmt.Sprintf("watch channel meet other error %s.", res.Err().Error()))
}
if err := server.Send(&resp); err != nil {
return err
}
// Err() indicates that this WatchResponse holds a channel-closing error.
return res.Err()
}
events := make([]*meta_storagepb.Event, 0, len(res.Events))
for _, e := range res.Events {
event := &meta_storagepb.Event{Kv: &meta_storagepb.KeyValue{
Key: e.Kv.Key,
Value: e.Kv.Value,
ModRevision: e.Kv.ModRevision,
CreateRevision: e.Kv.CreateRevision,
Version: e.Kv.Version,
Lease: e.Kv.Lease,
}, Type: meta_storagepb.Event_EventType(e.Type)}
if e.PrevKv != nil {
event.PrevKv = &meta_storagepb.KeyValue{Key: e.PrevKv.Key, Value: e.PrevKv.Value}
}
events = append(events, event)
}
if len(events) > 0 {
if err := server.Send(&meta_storagepb.WatchResponse{
Header: &meta_storagepb.ResponseHeader{ClusterId: s.manager.ClusterID(), Revision: res.Header.GetRevision()},
Events: events, CompactRevision: res.CompactRevision}); err != nil {
return err
}
}
}
}
}

It won't exit even if the client is gone. watch global config also has this problem.

@rleungx rleungx added the type/bug The issue is confirmed as a bug. label Feb 5, 2024
@ti-chi-bot ti-chi-bot bot closed this as completed in #7806 Feb 5, 2024
ti-chi-bot bot added a commit that referenced this issue Feb 5, 2024
close #7807

Signed-off-by: Ryan Leung <rleungx@gmail.com>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this issue Feb 6, 2024
close tikv#7807

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ti-chi-bot pushed a commit to ti-chi-bot/pd that referenced this issue Feb 6, 2024
close tikv#7807

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
ti-chi-bot bot pushed a commit that referenced this issue Feb 7, 2024
close #7807

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Signed-off-by: Ryan Leung <rleungx@gmail.com>

Co-authored-by: Ryan Leung <rleungx@gmail.com>
ti-chi-bot bot added a commit that referenced this issue Feb 21, 2024
close #7807

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
Signed-off-by: Ryan Leung <rleungx@gmail.com>

Co-authored-by: Ryan Leung <rleungx@gmail.com>
Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging a pull request may close this issue.

2 participants