Skip to content

merge: from 3.3.6 to main branch#33503

Merged
guanshengliang merged 3 commits intomainfrom
merge/3.3.6tomain
Nov 7, 2025
Merged

merge: from 3.3.6 to main branch#33503
guanshengliang merged 3 commits intomainfrom
merge/3.3.6tomain

Conversation

@guanshengliang
Copy link
Copy Markdown
Contributor

Description

Please briefly describe the code changes in this pull request.

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?

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @guanshengliang, 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 integrates a new authentication feature set, likely intended for enterprise deployments, by introducing necessary global variables, message types, and error codes. It establishes a periodic authentication heartbeat and updates the configuration system to manage these new parameters. Additionally, it refines message content handling during synchronous communication failures and ensures that new error codes are properly recognized in testing.

Highlights

  • Authentication Feature Introduction: Introduced new global configuration variables, message types, and error codes to support an authentication mechanism, primarily for enterprise versions of the software.
  • Authentication Heartbeat Mechanism: Implemented a periodic authentication heartbeat function within the mnode, which sends authentication timer messages based on configurable intervals.
  • Configuration and Error Handling: Added configuration parsing for new authentication parameters and defined a comprehensive set of error codes to handle various authentication-related scenarios.
  • Message Handling Adjustment: Modified the synchronous message sending logic to adjust how message content is handled upon failure, specifically by commenting out the immediate freeing of content.
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 👍 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

  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.

@guanshengliang guanshengliang merged commit 65cf8df into main Nov 7, 2025
8 checks passed
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces new authentication-related features, including global configuration variables, message types, and error codes. The changes are generally well-structured, but there are a few areas related to naming clarity and memory management that require attention. Specifically, the naming of authentication intervals could be more distinct, and a potential memory leak was identified in the tmsgSendSyncReq function due to commented-out cleanup logic. Additionally, error handling for message queue operations should be robust.

Comment on lines +54 to +57
// if (code != 0) {
// rpcFreeCont(pMsg->pCont);
// pMsg->pCont = NULL;
// }
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The lines responsible for freeing pMsg->pCont on error (if (code != 0) { rpcFreeCont(pMsg->pCont); pMsg->pCont = NULL; }) have been commented out. This changes the memory management contract: if tmsgSendSyncReq fails, the caller is now responsible for freeing pMsg->pCont. This could easily lead to memory leaks if callers are not updated to handle this new responsibility. Please either restore the memory freeing logic or clearly document this change in responsibility.

Suggested change
// if (code != 0) {
// rpcFreeCont(pMsg->pCont);
// pMsg->pCont = NULL;
// }
if (code != 0) {
rpcFreeCont(pMsg->pCont);
pMsg->pCont = NULL;
}

void *pReq = mndBuildTimerMsg(&contLen);
if (pReq != NULL) {
SRpcMsg rpcMsg = {.msgType = TDMT_MND_AUTH_HB_TIMER, .pCont = pReq, .contLen = contLen, .info.notFreeAhandle = 1, .info.ahandle = 0};
// TODO check return value
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The return value of tmsgPutToQueue is not checked. If this function fails, the memory allocated for pReq by mndBuildTimerMsg will not be freed, leading to a memory leak. It's crucial to always check return values for functions that can fail and handle errors appropriately, including freeing allocated resources.

    if (tmsgPutToQueue(&pMnode->msgCb, WRITE_QUEUE, &rpcMsg) < 0) {
      mError("failed to put into write-queue since %s, line:%d", terrstr(), __LINE__);
      rpcFreeCont(pReq);
    }

#ifdef TD_ENTERPRISE
bool tsAuthServer = 0;
bool tsAuthReq = 0;
int32_t tsAuthReqInterval = 2592000;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The variable tsAuthReqInterval is set to a default of 30 days, while tsAuthReqHBInterval is 5 seconds. Both names contain "Interval", which can be confusing. If tsAuthReqInterval represents a full re-authentication period rather than a heartbeat interval, consider renaming it to something like tsAuthReauthPeriod or tsAuthCheckPeriod for better clarity and to avoid ambiguity with tsAuthReqHBInterval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants