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

[release-19.0] Fix ZooKeeper Topology connection locks not being cleaned up correctly (#15757) #15764

Merged
merged 2 commits into from
Apr 22, 2024
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
15 changes: 9 additions & 6 deletions go/vt/topo/zk2topo/lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,19 +91,22 @@
case context.Canceled:
errToReturn = topo.NewError(topo.Interrupted, nodePath)
default:
errToReturn = vterrors.Wrapf(err, "failed to obtain action lock: %v", nodePath)
errToReturn = vterrors.Wrapf(err, "failed to obtain lock: %v", nodePath)

Check warning on line 94 in go/vt/topo/zk2topo/lock.go

View check run for this annotation

Codecov / codecov/patch

go/vt/topo/zk2topo/lock.go#L94

Added line #L94 was not covered by tests
}

// Regardless of the reason, try to cleanup.
log.Warningf("Failed to obtain action lock: %v", err)
log.Warningf("Failed to obtain lock: %v", err)

if err := zs.conn.Delete(ctx, nodePath, -1); err != nil {
log.Warningf("Failed to close connection :%v", err)
cleanupCtx, cancel := context.WithTimeout(context.Background(), baseTimeout)
defer cancel()

if err := zs.conn.Delete(cleanupCtx, nodePath, -1); err != nil {
log.Warningf("Failed to cleanup unsuccessful lock path %s: %v", nodePath, err)

Check warning on line 104 in go/vt/topo/zk2topo/lock.go

View check run for this annotation

Codecov / codecov/patch

go/vt/topo/zk2topo/lock.go#L104

Added line #L104 was not covered by tests
}

// Show the other locks in the directory
dir := path.Dir(nodePath)
children, _, err := zs.conn.Children(ctx, dir)
children, _, err := zs.conn.Children(cleanupCtx, dir)
if err != nil {
log.Warningf("Failed to get children of %v: %v", dir, err)
return nil, errToReturn
Expand All @@ -115,7 +118,7 @@
}

childPath := path.Join(dir, children[0])
data, _, err := zs.conn.Get(ctx, childPath)
data, _, err := zs.conn.Get(cleanupCtx, childPath)
if err != nil {
log.Warningf("Failed to get first locks node %v (may have just ended): %v", childPath, err)
return nil, errToReturn
Expand Down
Loading