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 merges recent changes from the 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 merges recent changes from main into the 3.0 branch, bringing in updates across privileges/RBAC behavior, catalog caching, Windows/libcurl integration, stream notifications, tests, and documentation.
Changes:
- Removes deprecated RESTful CLI option for
taosdumpand updates corresponding docs. - Extends privilege/column-visibility handling (parser + privilege tables) and adjusts/expands privilege test coverage (including TMQ topic privilege checks).
- Adds/extends Windows support for libcurl (build + headers), and includes several stability/cleanup fixes (e.g., paged buffer truncation, consumer user release, batch response free).
Reviewed changes
Copilot reviewed 43 out of 55 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/taos-tools/src/taosdump.c | Removes -R/--restful option handling. |
| test/cases/25-Privileges/test_priv_rbac.py | Adds column/topic privilege checks; uses TMQ Consumer. |
| test/cases/25-Privileges/test_priv_control.py | Updates expected behavior for row/column combined privilege case. |
| test/cases/24-Users/test_user_privilege_sysinfo.py | Adjusts sysinfo privilege expectations (vgroups/columns). |
| test/README.md | Improves formatting and adds prerequisites notes. |
| source/util/src/tpagedbuf.c | Adds debug/cleanup logging and truncates paged buffer file on clear. |
| source/util/src/tcurl.c | Removes Windows no-op path; uses curl implementation universally. |
| source/libs/sync/src/syncMain.c | Improves logs and stop-timer warning behavior. |
| source/libs/parser/src/parTranslater.c | Updates invisible-column handling and privilege column checks. |
| source/libs/parser/src/parInsertSql.c | Clears previously stored privilege/tag condition nodes to avoid leaks. |
| source/libs/parser/src/parAuthenticator.c | Marks columns appended by privilege conditions. |
| source/libs/parser/inc/sql.y | Adds LOCK ROLE / UNLOCK ROLE privilege types. |
| source/libs/nodes/src/nodesUtilFuncs.c | Fixes column collection/cloning bookkeeping for later flag updates. |
| source/libs/nodes/src/nodesCloneFuncs.c | Ensures column flags are copied during clone. |
| source/libs/new-stream/src/streamUtil.c | Removes Windows stub for stream notify; enables notify code path. |
| source/libs/new-stream/src/dataSinkMgr.c | Fixes function terminator and translates comments to English. |
| source/libs/new-stream/src/dataSinkFile.c | Translates comments to English. |
| source/libs/new-stream/src/dataSinkCache.c | Translates comments to English. |
| source/libs/catalog/src/ctgCache.c | Changes queue enqueue API and adjusts user-auth enqueue ownership handling. |
| source/libs/catalog/src/catalog.c | Clarifies shallow-copy caveat in catalogGetUserAuth doc. |
| source/dnode/vnode/src/vnd/vnodeSync.c | Improves sync close log messages. |
| source/dnode/mnode/impl/src/mndDb.c | Adds keepTimeOffset field output in db info dump. |
| source/dnode/mnode/impl/src/mndConsumer.c | Releases operator user on show consumer path. |
| source/common/src/tpriv.c | Adds role lock/unlock privs; adjusts required roles for lock/unlock user. |
| source/common/CMakeLists.txt | Adds curl dependency for Windows build of common. |
| source/client/src/clientHb.c | Uses structured free for user-auth batch response. |
| include/util/tpriv.h | Bumps privilege table version to 4. |
| include/util/tcurl.h | Enables CURL_STATICLIB on Windows; includes curl headers unconditionally. |
| include/libs/nodes/querynodes.h | Adds appendByPrivCond bit flag on column nodes. |
| include/libs/new-stream/dataSink.h | Replaces large CN comment block with concise English notes; adds <stdbool.h>. |
| docs/zh/27-train-faq/01-faq.md | Adds Docker Hub pull failure FAQ entry with anchor. |
| docs/zh/14-reference/05-connector/_windows_install.mdx | Updates referenced version to 3.4.0.9. |
| docs/zh/14-reference/05-connector/_macos_install.mdx | Updates referenced version to 3.4.0.9. |
| docs/zh/14-reference/05-connector/_linux_install.mdx | Updates referenced version and tarball name to 3.4.0.9. |
| docs/zh/14-reference/02-tools/09-taosdump.md | Removes RESTful option from taosdump docs. |
| docs/zh/14-reference/02-tools/07-taos-cli.md | Removes RESTful option mention; formatting cleanup. |
| docs/zh/08-operation/03-install.md | Updates referenced versions to 3.4.0.9. |
| docs/zh/06-advanced/05-data-in/pic/pspace-07.png | Adds pSpace documentation asset. |
| docs/zh/06-advanced/05-data-in/pic/pspace-06.png | Adds pSpace documentation asset. |
| docs/zh/06-advanced/05-data-in/22-pspace.mdx | Adds new Chinese pSpace guide page. |
| docs/zh/04-get-started/_03-docker.md | Adds troubleshooting link to Docker Hub pull failure FAQ. |
| docs/en/assets/pspace-06.png | Adds English pSpace documentation asset. |
| docs/en/assets/pspace-02.png | Adds English pSpace documentation asset. |
| docs/en/14-reference/02-tools/09-taosdump.md | Removes RESTful option from taosdump docs. |
| docs/en/14-reference/02-tools/07-taos-cli.md | Removes RESTful option mention; formatting cleanup. |
| docs/en/06-advanced/05-data-in/22-pspace.md | Adds new English pSpace guide page. |
| cmake/external.cmake | Enables building/ext-linking libcurl on Windows (static, websockets, schannel). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| code = ctgEnqueue(pCtg, op, &enqueued); | ||
| // Clear source pointers to transfer ownership after successful enqueue | ||
| if (enqueued) { | ||
| pAuth->objPrivs = NULL; | ||
| pAuth->selectTbs = NULL; | ||
| pAuth->insertTbs = NULL; | ||
| pAuth->deleteTbs = NULL; | ||
| pAuth->tokens = NULL; | ||
| pAuth->ownedDbs = NULL; | ||
| } |
There was a problem hiding this comment.
ctgUpdateUserEnqueue mutates pAuth by NULLing pointer fields when the operation is enqueued. This breaks callers that still need pAuth after the call (e.g., ctgGetUserAuth enqueues pRsp and then returns it to catalogGetUserAuth, but the pointer fields will be cleared). Consider enqueuing a deep-copy/moved clone instead (so the queue owns its copy), or only transferring ownership when the caller explicitly indicates it, but avoid modifying output structs that are returned to callers.
| def subscribe_topic(self, user, password, group_id, topic_name): | ||
| attr = { | ||
| 'group.id': group_id, | ||
| 'td.connect.user': user, | ||
| 'td.connect.pass': password, | ||
| 'auto.offset.reset': 'earliest' | ||
| } | ||
| consumer = Consumer(attr) | ||
| consumer.subscribe([topic_name]) | ||
|
|
There was a problem hiding this comment.
subscribe_topic creates a TMQ Consumer but never closes it. In the test suite this can leak sockets/threads and cause subsequent cases to hang or flake. Please ensure the consumer is closed (e.g., try/finally around subscribe + an explicit consumer.close()/unsubscribe() as appropriate).
| # URL_HASH MD5=b25588a43556068be05e1624e0e74d41 | ||
| get_from_local_if_exists("https://github.com/curl/curl/releases/download/curl-8_2_1/curl-8.2.1.tar.gz") | ||
| ExternalProject_Add(ext_curl | ||
| URL ${_url} | ||
| URL_HASH MD5=b25588a43556068be05e1624e0e74d41 | ||
| PREFIX "${_base}" | ||
| CMAKE_ARGS -DCMAKE_BUILD_TYPE:STRING=${TD_CONFIG_NAME} | ||
| CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:STRING=${_ins} | ||
| CMAKE_ARGS -DCMAKE_INSTALL_LIBDIR:PATH=lib | ||
| CMAKE_ARGS -DBUILD_SHARED_LIBS:BOOL=OFF | ||
| CMAKE_ARGS -DBUILD_TESTING:BOOL=OFF | ||
| CMAKE_ARGS -DBUILD_CURL_EXE:BOOL=OFF | ||
| CMAKE_ARGS -DENABLE_WEBSOCKETS:BOOL=ON | ||
| CMAKE_ARGS -DCURL_USE_SCHANNEL:BOOL=ON | ||
| CMAKE_ARGS -DCURL_USE_OPENSSL:BOOL=OFF | ||
| CMAKE_ARGS -DCURL_ZLIB:BOOL=OFF | ||
| CMAKE_ARGS -DCURL_DISABLE_LDAP:BOOL=ON | ||
| CMAKE_ARGS -DCURL_DISABLE_LDAPS:BOOL=ON | ||
| BUILD_COMMAND | ||
| COMMAND "${CMAKE_COMMAND}" --build . --config "${TD_CONFIG_NAME}" | ||
| INSTALL_COMMAND | ||
| COMMAND "${CMAKE_COMMAND}" --install . --config "${TD_CONFIG_NAME}" --prefix "${_ins}" | ||
| EXCLUDE_FROM_ALL TRUE | ||
| VERBATIM | ||
| ) | ||
| else() | ||
| string(JOIN " " _c_flags ${_c_flags_list}) | ||
| # URL https://github.com/curl/curl/releases/download/curl-8_2_1/curl-8.2.1.tar.gz | ||
| # URL_HASH MD5=b25588a43556068be05e1624e0e74d41 |
There was a problem hiding this comment.
The ext_curl external dependency is verified using URL_HASH MD5=..., which relies on MD5, a cryptographically broken hash function, for integrity checking of third‑party code. An attacker who can intercept or influence the download channel could craft a curl tarball with a colliding MD5 and have malicious code accepted into your build, potentially leading to execution of attacker‑controlled code in the build environment. Replace MD5 with a modern, collision‑resistant hash (for example a SHA‑256 checksum or stronger signature‑based verification supported by CMake) for the URL_HASH used when fetching ext_curl on all platforms.
There was a problem hiding this comment.
Code Review
This pull request merges significant changes, including enabling libcurl support on Windows, improving code maintainability by translating comments, and enhancing the privilege system with new features like LOCK/UNLOCK ROLE and more refined column-level access control. It also incorporates important memory safety fixes, including addressing several resource leaks. However, a memory leak was identified in the catalog cache enqueue logic where allocated operation objects are not freed upon failure, which needs to be addressed to prevent potential memory exhaustion. Additionally, there are suggestions to further enhance security and documentation quality.
| code = ctgEnqueue(pCtg, op, &enqueued); | ||
| // Clear source pointers to transfer ownership after successful enqueue | ||
| if (enqueued) { | ||
| pAuth->objPrivs = NULL; | ||
| pAuth->selectTbs = NULL; | ||
| pAuth->insertTbs = NULL; | ||
| pAuth->deleteTbs = NULL; | ||
| pAuth->tokens = NULL; | ||
| pAuth->ownedDbs = NULL; | ||
| } | ||
|
|
||
| _return: | ||
|
|
||
| tFreeSGetUserAuthRsp(pAuth); | ||
| if (!enqueued) { | ||
| tFreeSGetUserAuthRsp(pAuth); | ||
| } |
There was a problem hiding this comment.
A memory leak occurs in ctgUpdateUserEnqueue and other enqueue functions when ctgEnqueue fails. The SCtgCacheOperation object op is allocated using taosMemoryCalloc, but it is not freed if ctgEnqueue returns an error (i.e., when enqueued is false). Additionally, the msg object assigned to op->data is also leaked in this scenario. Repeated failures could lead to memory exhaustion and a potential Denial of Service (DoS).
| get_from_local_if_exists("https://github.com/curl/curl/releases/download/curl-8_2_1/curl-8.2.1.tar.gz") | ||
| ExternalProject_Add(ext_curl | ||
| URL ${_url} | ||
| URL_HASH MD5=b25588a43556068be05e1624e0e74d41 |
There was a problem hiding this comment.
For security reasons, it is recommended to use a stronger hashing algorithm than MD5 for verifying the downloaded file. ExternalProject_Add supports SHA256, which should be preferred.
The SHA256 hash for curl-8.2.1.tar.gz is 431175130424587834751581b8333535f0535350b6b44b5665805213038a685b.
URL_HASH SHA256=431175130424587834751581b8333535f0535350b6b44b5665805213038a685b
|
|
||
| 如果启动 TDengine 服务时出现异常,请查看数据库日志以获取更多信息。你也可以参考 TDengine 的官方文档中的故障排除部分,或者在 TDengine 开源社区中寻求帮助。 | ||
| 1. 如果无法正常从 Docker Hub 拉取镜像,请参考常见问题列表中的相关问题:[如果从 Docker Hub 拉取 TDengine 镜像失败,应该如何解决?](https://docs.taosdata.com/train-faq/faq/#docker-hub-failure) | ||
| 1. 如果启动 TDengine 服务时出现异常,请查看数据库日志以获取更多信息。你也可以参考 TDengine 的官方文档中的故障排除部分,或者在 TDengine 开源社区中寻求帮助。 |
There was a problem hiding this comment.
The numbered list in the "故障排查" (Troubleshooting) section is not correctly formatted. To ensure both items appear in a single ordered list, the second item should be numbered 2. instead of 1..
| 1. 如果启动 TDengine 服务时出现异常,请查看数据库日志以获取更多信息。你也可以参考 TDengine 的官方文档中的故障排除部分,或者在 TDengine 开源社区中寻求帮助。 | |
| 2. 如果启动 TDengine 服务时出现异常,请查看数据库日志以获取更多信息。你也可以参考 TDengine 的官方文档中的故障排除部分,或者在 TDengine 开源社区中寻求帮助。 |
Closes: https://project.feishu.cn/taosdata_td/defect/detail/6779768893 * fix: SAST Check invalid rules * fix: shellArguments.c format indent * fix: shellArguments.c format indent 2 * fix: shellEngine.c format indent
* fix(taos-tools): fix sast warnings * fix(taos-tools): add error handling * fix(taos-tools): fix typo * fix(taos-tools): optimize judgment condition * fix(taosdump): fix wrong if condition
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 96 out of 98 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| QUERY_CHECK_NULL(taosArrayPush(pVirtualScanInfo->pSortCtxList, &pCtx), code, lino, _return, terrno) | ||
| pCtx = NULL; | ||
| VTS_ERR_JRET(tsortAddSource(pVirtualScanInfo->pSortHandle, ps)); | ||
| ps = NULL; |
There was a problem hiding this comment.
In the loop, pCtx is set to NULL before tsortAddSource() succeeds. If tsortAddSource() fails, the allocated SLoadNextCtx has already been pushed into pSortCtxList but won't be freed in the _return cleanup (since the local pCtx is NULL), leading to a leak and leaving pSortCtxList out of sync with the sort handle sources. Consider only nulling pCtx after tsortAddSource() succeeds (and/or cleaning up the last pushed ctx on failure, or calling cleanUpVirtualScanInfo() in the error path).
| int pos = 0; | ||
| BArray* fields = NULL; | ||
| int16_t field_count = 0; | ||
| char* binanry_prefix = stb->binaryPrefex ? stb->binaryPrefex : ""; | ||
| char* nchar_prefix = stb->ncharPrefex ? stb->ncharPrefex : ""; | ||
|
|
||
| if (!buf || !stb || !k || size <= 0) { | ||
| return -1; | ||
| } | ||
|
|
||
| if (fields_cate == GEN_ROW_FIELDS_TAG) { | ||
| fields = stb->tags; | ||
| field_count = stb->tags->size; | ||
| } else { | ||
| fields = stb->cols; | ||
| field_count = stb->cols->size; | ||
| } | ||
|
|
||
| for (uint16_t i = 0; i < field_count; ++i) { | ||
| Field* field = benchArrayGet(fields, i); | ||
| for (int16_t i = 0; i < field_count; ++i) { | ||
| Field* field = benchArrayGet(fields, (size_t)i); | ||
| char* prefix = ""; |
There was a problem hiding this comment.
field_count is derived from stb->tags->size / stb->cols->size (container sizes), but it's stored as int16_t and used in the loop bound. This can truncate/overflow if the column/tag count exceeds INT16_MAX, causing incorrect iteration or an infinite loop. Use size_t (or at least int32_t) for field_count and the loop index, and avoid casting through signed 16-bit types here.
| # 注册信号处理器 | ||
| signal.signal(signal.SIGUSR1, self.signalHandler) # 暂停/恢复 alter 线程 | ||
| signal.signal(signal.SIGUSR2, self.signalHandler) # 停止 alter 线程 | ||
| signal.signal(signal.SIGINT, self.signalHandler) # Ctrl+C 停止所有 |
There was a problem hiding this comment.
signal.SIGUSR1/signal.SIGUSR2 are not available on Windows Python, but this test case is registered for Windows (tdCases.addWindows). Registering these handlers unconditionally will raise at runtime on Windows. Guard these registrations with hasattr(signal, "SIGUSR1")/hasattr(signal, "SIGUSR2") (or platform checks), or only register them on Linux.
| # 等待插入线程完成 | ||
| insertThread.join() | ||
| tdLog.info("Insert thread completed") | ||
|
|
||
| # 等待消费线程完成 | ||
| consumeThread1.join() | ||
| tdLog.info("Consumer thread g1 completed") | ||
| consumeThread2.join() | ||
| tdLog.info("Consumer thread g2 completed") | ||
|
|
||
| self.consume() | ||
| # 停止 alter 线程 | ||
| tdLog.info("Stopping alter threads...") | ||
| self.stopAlter = True | ||
| self.pauseAlter.set() # 确保线程不会卡在等待状态 | ||
|
|
There was a problem hiding this comment.
run() waits for the consumer threads (consumeThread1/2.join()) before setting self.stopAlter = True. Meanwhile the alter threads continue running and can keep generating new messages, preventing consumer.poll() from timing out and causing the consumer joins to block indefinitely (so the test may never reach the stop/cleanup logic). Consider signaling stopAlter (and/or a separate consumer stop condition) before joining consumers, or add a bounded consume loop/timeout so the test always terminates.
| bool hashMapInsert(HashMap *map, const char *key, void *value) { | ||
| // lock map | ||
| pthread_mutex_lock(&map->lock); | ||
| (void)pthread_mutex_lock(&map->lock); | ||
| uint32_t hash = bkdrHash(key) % HASH32_MAP_MAX_BUCKETS; | ||
| HashMapEntry *entry = (HashMapEntry *)malloc(sizeof(HashMapEntry)); |
There was a problem hiding this comment.
pthread_mutex_lock(&map->lock) return value is ignored. If it fails (e.g., EINVAL), the function will continue and mutate shared state without holding the lock. Since this code already treats mutex init failure as fatal, consider also checking the lock return and handling it (e.g., perror + abort or returning false).
Description
Issue(s)
Checklist
Please check the items in the checklist if applicable.