Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request focuses on enhancing the stability and resource management of the system by addressing two critical memory leaks. The changes ensure that allocated resources, specifically LRU caches and BSE components, are correctly deallocated during error conditions or object closure, preventing gradual memory consumption and improving overall system robustness. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Pull request overview
This PR addresses memory/resource leaks during vnode/TSDB initialization failure paths, ensuring allocated cache and blob-store engine resources are properly released when open steps fail.
Changes:
- Close and nullify
pVnode->pBseinvnodeOpen()error cleanup to avoid leaking the blob store engine handle. - Ensure
tsdbOpenCache()cleans up the newly created LRU cache (taosLRUCacheCleanup) when a subsequent open step fails.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| source/dnode/vnode/src/vnd/vnodeOpen.c | Adds pBse cleanup in vnodeOpen()’s _err path to prevent BSE handle leaks. |
| source/dnode/vnode/src/tsdb/tsdbCache.c | Fixes LRU cache leak on tsdbOpenCache() failure by cleaning up pCache before returning an error. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request addresses memory leaks in tsdbCache and bse. The changes involve adding proper resource cleanup in error paths. In tsdbCache.c, a memory leak is fixed by cleaning up pCache if tsdbOpenCache fails. In vnodeOpen.c, a potential leak is addressed by ensuring pVnode->pBse is closed and set to NULL in the error handling block of vnodeOpen. While the changes are correct, there's an opportunity to improve code clarity in tsdbCache.c by removing a redundant assignment.
Note: Security Review did not run due to the size of the PR.
| } | ||
| } | ||
|
|
||
| pTsdb->lruCache = pCache; |
There was a problem hiding this comment.
The assignment pTsdb->lruCache = pCache; is redundant here. In the error path, pCache is set to NULL within the if (code) block on line 2886. This assignment correctly sets pTsdb->lruCache to NULL. However, for better readability and to avoid confusion, it would be cleaner to set pTsdb->lruCache to NULL directly within the error handling block and remove this line.
| if (pVnode->pBse) { | ||
| bseClose(pVnode->pBse); | ||
| pVnode->pBse = NULL; | ||
| } |
There was a problem hiding this comment.
Description
Issue(s)
https://project.feishu.cn/taosdata_td/defect/detail/6854367892
Checklist
Please check the items in the checklist if applicable.