TDengine icon indicating copy to clipboard operation
TDengine copied to clipboard

Feat/3.0/TS-7230

Open xiao-77 opened this issue 3 weeks ago • 1 comments

Description

Please briefly describe the code changes in this pull request.

Jira: https://jira.taosdata.com:18080/browse/TD-

Checklist

Please check the items in the checklist if applicable.

  • [ ] Is the user manual updated?
  • [ ] Are the test cases passed and automated?
  • [ ] Is there no significant decrease in test coverage?

xiao-77 avatar Dec 03 '25 10:12 xiao-77

Summary of Changes

Hello @xiao-77, I'm Gemini Code Assist[^1]! 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 introduces a robust multi-layer encryption key management system, primarily targeting enterprise features. It establishes a secure and automated mechanism for dnodes to synchronize their encryption keys with mnodes, ensuring data consistency and security across the cluster. The changes involve defining new communication protocols, implementing client and server-side logic for key exchange, and updating the key loading process to support the new encryption architecture while maintaining compatibility with existing setups.

Highlights

  • Multi-Layer Encryption Key Definitions: Introduced a comprehensive set of global variables in include/common/tglobal.h and initialized in source/common/src/tglobal.c to support multi-layer encryption. These include flags for TAOSK encryption usage, server, database, config, metadata, and data keys, algorithm type, file format version, key update version, creation timestamps, and enabled flags for various key types.
  • Key Synchronization Messaging: Defined new message types TDMT_MND_ENCRYPT_KEY and TDMT_MND_KEY_SYNC in include/common/tmsgdef.h. Corresponding SKeySyncReq and SKeySyncRsp structures, along with their serialization and deserialization functions, were added in include/common/tmsg.h and implemented in source/common/src/msg/tmsg.c to facilitate key exchange between dnodes and mnodes.
  • Dnode Key Synchronization Logic: Implemented a new keySyncThread within the dnode management (SDnodeMgmt) in source/dnode/mgmt/mgmt_dnode/inc/dmInt.h and source/dnode/mgmt/mgmt_dnode/src/dmWorker.c. This thread periodically sends key synchronization requests (SKeySyncReq) to the mnode and processes the responses (SKeySyncRsp), updating local encryption keys if necessary. This ensures dnodes have the most current encryption keys from the mnode.
  • Mnode Key Synchronization Handling: The mnode now includes a handler (mndProcessKeySyncReq in source/dnode/mnode/impl/src/mndConfig.c) for TDMT_MND_KEY_SYNC messages. It loads the mnode's encryption keys and responds to dnodes, providing updated keys if the dnode's local key version is outdated.
  • Enhanced Encryption Key Loading: Modified the dmGetEncryptKey function in source/dnode/mgmt/node_util/src/dmFile.c to prioritize loading multi-layer encryption keys from a taosk encrypt.bin file. If this new format is not found or fails to load, it gracefully falls back to the legacy encryptCode.cfg format, ensuring backward compatibility.
  • Conditional Enterprise Features: Updated CMakeLists.txt files across dnode/mgmt and dnode/mnode modules to conditionally include TAOSK-related headers and functionality only when TD_ENTERPRISE is defined, ensuring that these encryption features are specific to the enterprise edition.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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 :thumbsup: and :thumbsdown: 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.

[^1]: Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

gemini-code-assist[bot] avatar Dec 03 '25 10:12 gemini-code-assist[bot]