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

Problem: memiavl has resource leaks #1075

Merged
merged 6 commits into from
Jun 21, 2023
Merged

Conversation

yihuang
Copy link
Collaborator

@yihuang yihuang commented Jun 21, 2023

Solution:

  • add defers and close functions

👮🏻👮🏻👮🏻 !!!! REFERENCE THE PROBLEM YOUR ARE SOLVING IN THE PR TITLE AND DESCRIBE YOUR SOLUTION HERE !!!! DO NOT FORGET !!!! 👮🏻👮🏻👮🏻

PR Checklist:

  • Have you read the CONTRIBUTING.md?
  • Does your PR follow the C4 patch requirements?
  • Have you rebased your work on top of the latest master?
  • Have you checked your code compiles? (make)
  • Have you included tests for any non-trivial functionality?
  • Have you checked your code passes the unit tests? (make test)
  • Have you checked your code formatting is correct? (go fmt)
  • Have you checked your basic code style is fine? (golangci-lint run)
  • If you added any dependencies, have you checked they do not contain any known vulnerabilities? (go list -json -m all | nancy sleuth)
  • If your changes affect the client infrastructure, have you run the integration test?
  • If your changes affect public APIs, does your PR follow the C4 evolution of public contracts?
  • If your code changes public APIs, have you incremented the crate version numbers and documented your changes in the CHANGELOG.md?
  • If you are contributing for the first time, please read the agreement in CONTRIBUTING.md now and add a comment to this pull request stating that your PR is in accordance with the Developer's Certificate of Origin.

Thank you for your code, it's appreciated! :)

Solution:
- add defers and close functions
@yihuang yihuang requested a review from a team as a code owner June 21, 2023 01:30
@yihuang yihuang requested review from mmsqe and thomas-nguy and removed request for a team June 21, 2023 01:30
CHANGELOG.md Outdated Show resolved Hide resolved
@yihuang yihuang enabled auto-merge June 21, 2023 01:32
CHANGELOG.md Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Jun 21, 2023

Codecov Report

Merging #1075 (80df52d) into main (368524d) will increase coverage by 24.40%.
The diff coverage is 71.42%.

Impacted file tree graph

@@             Coverage Diff             @@
##             main    #1075       +/-   ##
===========================================
+ Coverage   21.67%   46.08%   +24.40%     
===========================================
  Files          50       82       +32     
  Lines        3031     7139     +4108     
===========================================
+ Hits          657     3290     +2633     
- Misses       2310     3498     +1188     
- Partials       64      351      +287     
Impacted Files Coverage Δ
memiavl/export.go 57.95% <55.55%> (ø)
memiavl/import.go 65.28% <100.00%> (ø)

... and 45 files with indirect coverage changes

Comment on lines +241 to +245
defer func() {
if err := snapshot.Close(); returnErr == nil {
returnErr = err
}
}()

Check warning

Code scanning / CodeQL

Defer in loop

This defer statement is in a [loop](1).
Copy link
Collaborator

@mmsqe mmsqe left a comment

Choose a reason for hiding this comment

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

should we add close this one as well

@yihuang
Copy link
Collaborator Author

yihuang commented Jun 21, 2023

should we add close this one as well

no, the snapshot is passed to the Trees, which will close them when the trees are closed.

Co-authored-by: mmsqe <[email protected]>
Signed-off-by: yihuang <[email protected]>
@yihuang yihuang added this pull request to the merge queue Jun 21, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 21, 2023
@mmsqe mmsqe added this pull request to the merge queue Jun 21, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 21, 2023
@yihuang yihuang added this pull request to the merge queue Jun 21, 2023
Merged via the queue into crypto-org-chain:main with commit ed5ce30 Jun 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants