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 lock waiter leak #16193

Merged
merged 2 commits into from
May 16, 2024
Merged

fix lock waiter leak #16193

merged 2 commits into from
May 16, 2024

Conversation

iamlinjunhong
Copy link
Contributor

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #15921 #15815 #15757

What this PR does / why we need it:

fix lock waiter leak

@matrix-meow matrix-meow added the size/XS Denotes a PR that changes [1, 9] lines label May 16, 2024
@mergify mergify bot requested a review from sukki37 May 16, 2024 10:15
@matrix-meow
Copy link
Contributor

@iamlinjunhong Thanks for your contributions!

Pull Request Review:

Title:

The title of the pull request is clear and concise, indicating that it addresses a "lock waiter leak" issue.

Body:

The body of the pull request provides information about the type of PR, the related issues, and the purpose of the changes made. It mentions fixing a lock waiter leak.

Changes:

  1. In the lock_table_local.go file, a change has been made in the doLock function.
  2. Added code to check if c.w is not nil and then call disableNotify() and close() methods on c.w if the deadlock is detected.

Issues Identified:

  1. Resource Leak: The code change in the pull request addresses a lock waiter leak issue. However, there is a potential problem in the added code snippet. If c.w is not nil, disableNotify() and close() are called, but there is no check or handling for the case when c.w is nil. This can lead to a potential nil pointer dereference issue.

Suggestions for Improvement:

  1. Null Pointer Check: Before calling disableNotify() and close() on c.w, ensure that c.w is not nil to avoid a potential nil pointer dereference. Add a null check before accessing methods on c.w.

Optimization:

  1. Code Readability: Consider adding comments to explain the purpose of the added code for better code readability and maintainability.

By addressing the identified issue and implementing the suggested improvement, the code quality and reliability can be enhanced. Additionally, adding comments can help in understanding the code's functionality.

@mergify mergify bot merged commit 32646d7 into matrixorigin:1.2-dev May 16, 2024
18 of 19 checks passed
@aylei aylei mentioned this pull request Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XS Denotes a PR that changes [1, 9] lines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants