fix(tmq): optimize poll logic & vtable meta error & dead lock in sometimes#35086
fix(tmq): optimize poll logic & vtable meta error & dead lock in sometimes#35086guanshengliang merged 7 commits intomainfrom
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces lock wrapper functions in clientTmq.c to incorporate trace logging and replaces direct latch calls. It also adds a getElapsedTime helper and refactors tmq_consumer_poll. In catalog.c, it updates ctgGetTbMeta to correctly manage schemaExt and tagRef during metadata reallocation. Feedback suggests renaming the new lock functions to snake_case to maintain consistency with the existing codebase.
There was a problem hiding this comment.
Pull request overview
This PR targets TMQ stability and metadata correctness by tightening virtual table meta reconstruction in the catalog layer and adjusting TMQ client poll/response handling to reduce intermittent deadlocks.
Changes:
- Fix virtual-table meta rebuild to correctly account for
schemaExtand tag references when reallocating/copying meta buffers. - Add TMQ lock wrapper helpers with TRACE logging and use them across multiple TMQ code paths.
- Simplify
processMqRspcontrol flow by returning early for EP responses / decode errors to avoid incorrect unlock paths.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| source/libs/catalog/src/catalog.c | Rebuilds vtable meta with schemaExt + colRef + tagRef layout and sets pointers consistently. |
| source/client/src/clientTmq.c | Introduces lock wrappers + TRACE macro, replaces direct latch calls, and tweaks poll/response flow to avoid deadlock-prone paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Code Review本次审查覆盖 ✅ 确认正确的修复1. processMqRsp 死锁修复 2. catalog.c vtable meta 内存布局修复
PR 对这三点均已正确修复,并在 realloc 移动地址后补充了 schemaExt 指针更新。
|
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
source/libs/catalog/src/catalog.c:251
- Potential use-after-free/out-of-bounds read:
output->vctbMetais produced viactgCloneMetaOutputinctgRefreshTbMeta, but that clone routine only allocates/copiescolRefand does not deep-copy thetagRefarray. As a result,output->vctbMeta->tagRefmay point outside the cloned allocation or to memory owned by the enqueued original output, and dereferencing it here can race with cache-update/free. Fix by updating the clone logic to allocate/copytagRef(and settagRef=NULL+numOfTagRefs=0when absent) sooutput->vctbMetais self-contained before this memcpy.
TAOS_MEMCPY(output->tbMeta->colRef, output->vctbMeta->colRef, colRefSize);
if (output->vctbMeta->tagRef && tagRefSize > 0) {
output->tbMeta->tagRef = (SColRef *)((char *)output->tbMeta + metaSize + schemaExtSize + colRefSize);
TAOS_MEMCPY(output->tbMeta->tagRef, output->vctbMeta->tagRef, tagRefSize);
} else {
output->tbMeta->tagRef = NULL;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description
Issue(s)
Checklist
Please check the items in the checklist if applicable.