Conversation
PR Summary by QodoFix IntentLock rollback leak and add multi-fingerprint lock tests
AI Description
Diagram
High-Level Assessment
Files changed (8)
|
Code Review by Qodo
1. Shard destroyed too early
|
| # 单元测试可执行文件(统一入口,包含所有 *_test.cpp 和 *_perf.cpp) | ||
| add_executable(unit_tests | ||
| db_table_test.cpp | ||
| intent_lock_test.cpp | ||
| ) |
There was a problem hiding this comment.
3. Perf benchmark not built 🐞 Bug ⚙ Maintainability
db_table_perf.cpp was converted into a gtest TEST, but it is not included in the unit_tests target sources, so it won’t compile or run in CI. The CMake comment claiming all *_perf.cpp are included is now misleading.
Agent Prompt
### Issue description
`db_table_perf.cpp` defines a gtest `TEST(...)` but is not compiled into any shown test target.
### Issue Context
`test/CMakeLists.txt` only lists `db_table_test.cpp` and `intent_lock_test.cpp` for `unit_tests`.
### Fix Focus Areas
- test/CMakeLists.txt[3-7]
- test/db_table_perf.cpp[205-214]
### Suggested fix
Choose one:
1) Add `db_table_perf.cpp` to `unit_tests` sources (if it’s acceptable for CI runtime), or
2) Create a separate `db_table_perf`/`benchmarks` target and keep it out of unit tests, and update the comment in `test/CMakeLists.txt` accordingly.
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
/review |
| slice_ = std::make_unique<DbSlice>(0, false, EngineShard::tlocal()); | ||
| } | ||
|
|
||
| void TearDown() override { EngineShard::DestroyThreadLocal(); } |
There was a problem hiding this comment.
1. Shard destroyed too early 🐞 Bug ☼ Reliability
IntentLockTest::TearDown destroys EngineShard thread-local state while the fixture still owns a live DbSlice (slice_), so DbSlice/DbTable destructors may later deallocate via an already-freed EngineShard::memory_resource(). This can cause teardown-time crashes or ASAN/LSAN failures.
Agent Prompt
### Issue description
`IntentLockTest::TearDown()` calls `EngineShard::DestroyThreadLocal()` while `slice_` (a `std::unique_ptr<DbSlice>`) is still alive. Because `DbSlice` creates `DbTable` with `owner_->memory_resource()` (owned by `EngineShard`), destroying the shard first makes the allocator/resource lifetime invalid; when the fixture later destroys `slice_`, it may deallocate via a freed memory resource.
### Issue Context
- `EngineShard::DestroyThreadLocal()` destroys the shard object and deletes its mimalloc heap.
- `DbSlice::CreateDb()` constructs `DbTable` with `owner_->memory_resource()`.
- `DbTable`/`DashTable` store that memory_resource and may use it during destruction.
### Fix Focus Areas
- test/intent_lock_test.cpp[10-16]
### Suggested fix
In `TearDown()`, explicitly destroy/reset `slice_` before destroying the thread-local shard:
```cpp
void TearDown() override {
slice_.reset();
EngineShard::DestroyThreadLocal();
}
```
(Optionally also reset/clean any other objects that might indirectly reference `EngineShard::tlocal()` before calling `DestroyThreadLocal()`.)
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
|
Code review by qodo was updated up to the latest commit 9f4a4bb |
No description provided.