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

Fix ZooKeeper Topology connection locks not being cleaned up correctly #15757

Merged
merged 5 commits into from
Apr 20, 2024

Conversation

frouioui
Copy link
Member

@frouioui frouioui commented Apr 19, 2024

Description

This PR introduces a new context with timeout to do the clean up phase after we have failed to acquire a new lock in zktopo to prevent the issue described in #15756. Refer to the issue for full context on the issue.

This issue exists on all release branches, but is not visible right now as it is hidden by a bug in the version of golang.org/x/sync that we depend on. While it is not strictly necessary to backport to all release branches right now, it is recommended that we do so in order to avoid surprises should we need to upgrade the dependency on a release branch for other reasons.

Related Issue(s)

Signed-off-by: Florent Poinsard <[email protected]>
Signed-off-by: Florent Poinsard <[email protected]>
Copy link
Contributor

vitess-bot bot commented Apr 19, 2024

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot vitess-bot bot added NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsWebsiteDocsUpdate What it says labels Apr 19, 2024
@frouioui frouioui added Type: Bug Backport to: release-17.0 and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels Apr 19, 2024
@github-actions github-actions bot added this to the v20.0.0 milestone Apr 19, 2024
@frouioui
Copy link
Member Author

This PR will unblock the dependencies upgrade Pull Request where this issue has been found (#15743)

Copy link

codecov bot commented Apr 19, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 2 lines in your changes are missing coverage. Please review.

Project coverage is 68.39%. Comparing base (da1301b) to head (cfce401).
Report is 2 commits behind head on main.

Files Patch % Lines
go/vt/topo/zk2topo/lock.go 75.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15757      +/-   ##
==========================================
- Coverage   68.40%   68.39%   -0.01%     
==========================================
  Files        1556     1556              
  Lines      195418   195422       +4     
==========================================
- Hits       133666   133663       -3     
- Misses      61752    61759       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@mattlord mattlord left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Only a few very minor nits/suggestions. Thanks! ❤️

cleanupCtx, cancel := context.WithTimeout(context.Background(), baseTimeout)
defer cancel()

if err := zs.conn.Delete(cleanupCtx, nodePath, -1); err != nil {
log.Warningf("Failed to close connection :%v", err)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This error should be changed. It would have been more helpful in understanding the problem if it was:

Suggested change
log.Warningf("Failed to close connection :%v", err)
log.Warningf("Failed to cleanup unsuccessful lock path %s: %v", nodePath, err)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think this would be slightly better for line 94:

errToReturn = vterrors.Wrapf(err, "failed to obtain lock: %v", nodePath)

And line 98:

log.Warningf("Failed to obtain lock: %v", err)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed via 2690688

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should be:

log.Warningf("Failed to cleanup unsuccessful lock path %s: %v", nodePath, err)

@deepthi
Copy link
Member

deepthi commented Apr 19, 2024

@frouioui please resolve the feedback and then go ahead and merge this. Nice work!

Signed-off-by: Florent Poinsard <[email protected]>
Signed-off-by: Florent Poinsard <[email protected]>
@frouioui frouioui merged commit 14b36d0 into vitessio:main Apr 20, 2024
104 checks passed
@frouioui frouioui deleted the fix-zk-topo-context branch April 20, 2024 00:56
frouioui added a commit that referenced this pull request Apr 22, 2024
frouioui added a commit that referenced this pull request Apr 22, 2024
frouioui added a commit that referenced this pull request Apr 22, 2024
frouioui added a commit that referenced this pull request Apr 22, 2024
…ned up correctly (#15757) (#15764)

Signed-off-by: Florent Poinsard <[email protected]>
Co-authored-by: Florent Poinsard <[email protected]>
Co-authored-by: Florent Poinsard <[email protected]>
frouioui added a commit that referenced this pull request Apr 22, 2024
…ned up correctly (#15757) (#15762)

Signed-off-by: Florent Poinsard <[email protected]>
Co-authored-by: Florent Poinsard <[email protected]>
frouioui added a commit that referenced this pull request Apr 22, 2024
…ned up correctly (#15757) (#15763)

Signed-off-by: Florent Poinsard <[email protected]>
Co-authored-by: Florent Poinsard <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ZooKeeper Topo locks not being cleaned up properly in case of context timeout
3 participants