Skip to content

Conversation

@Pengrongkun
Copy link
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
Contributor

Summary of Changes

Hello @Pengrongkun, 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 refines the handling of authentication configurations by ensuring that the authReqUrl setting is dynamically applied without delay. Furthermore, it introduces the capability to update key authentication parameters such as authServer, authReq, authReqInterval, and authReqUrl at runtime, specifically for enterprise builds. These changes enhance the flexibility and responsiveness of authentication management within the system.

Highlights

  • Auth Configuration Dynamism: The authReqUrl configuration parameter has been updated from CFG_DYN_SERVER_LAZY to CFG_DYN_SERVER, allowing it to be dynamically applied immediately rather than lazily.
  • Runtime Auth Setting Updates: New functionality has been added under the TD_ENTERPRISE flag to enable dynamic runtime updates for several authentication-related configurations, including authServer, authReq, authReqInterval, and authReqUrl.
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.

Copy link
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 fixes the dynamic configuration update for authentication settings. The change from CFG_DYN_SERVER_LAZY to CFG_DYN_SERVER for authReqUrl is now correctly handled by the new logic in taosCfgDynamicOptionsForServer. However, the new code block introduces a critical bug that could lead to a deadlock, and it also contains repetitive code. I've provided a refactoring suggestion to address these issues.

Comment on lines 2773 to 2795
#ifdef TD_ENTERPRISE
if (strcasecmp(name, "authServer") == 0) {
tsAuthServer = pItem->bval;
code = TSDB_CODE_SUCCESS;
goto _exit;
}
if (strcasecmp(name, "authReq") == 0) {
tsAuthReq = pItem->bval;
code = TSDB_CODE_SUCCESS;
goto _exit;
}
if (strcasecmp(name, "authReqInterval") == 0) {
tsAuthReqInterval = pItem->i32;
code = TSDB_CODE_SUCCESS;
goto _exit;
}
if (strcasecmp(name, "authReqUrl") == 0) {
TAOS_CHECK_RETURN(taosCheckCfgStrValueLen(pItem->name, pItem->str, TSDB_FQDN_LEN));
tstrncpy(tsAuthReqUrl, pItem->str, TSDB_FQDN_LEN);
code = TSDB_CODE_SUCCESS;
goto _exit;
}
#endif
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

This new block of code has a potential bug and can be refactored for better maintainability.

  1. Potential Bug (Lock not released): The TAOS_CHECK_RETURN macro likely expands to a return statement. Since this code is within a cfgLock/cfgUnLock pair, returning directly would skip the cfgUnLock call at the _exit label, leading to a deadlock. The error code should be stored and a goto _exit should be used instead.

  2. Code Duplication: The structure of the if blocks is very repetitive, especially the code = TSDB_CODE_SUCCESS; goto _exit; part. This can be consolidated to make the code cleaner and easier to maintain.

Here is a suggested refactoring that addresses both points:

#ifdef TD_ENTERPRISE
  bool config_handled = false;
  if (strcasecmp(name, "authServer") == 0) {
    tsAuthServer = pItem->bval;
    config_handled = true;
  } else if (strcasecmp(name, "authReq") == 0) {
    tsAuthReq = pItem->bval;
    config_handled = true;
  } else if (strcasecmp(name, "authReqInterval") == 0) {
    tsAuthReqInterval = pItem->i32;
    config_handled = true;
  } else if (strcasecmp(name, "authReqUrl") == 0) {
    code = taosCheckCfgStrValueLen(pItem->name, pItem->str, TSDB_FQDN_LEN);
    if (code != TSDB_CODE_SUCCESS) {
      goto _exit;
    }
    tstrncpy(tsAuthReqUrl, pItem->str, TSDB_FQDN_LEN);
    config_handled = true;
  }

  if (config_handled) {
    code = TSDB_CODE_SUCCESS;
    goto _exit;
  }
#endif

#ifdef TD_ENTERPRISE
if (strcasecmp(name, "authServer") == 0) {
tsAuthServer = pItem->bval;
code = TSDB_CODE_SUCCESS;
Copy link
Contributor

Choose a reason for hiding this comment

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

虽然之前都是这样写的,实际上,code = TSDB_CODE_SUCCESS 都是冗余的吧。

}
if (strcasecmp(name, "authReq") == 0) {
tsAuthReq = pItem->bval;
code = TSDB_CODE_SUCCESS;
Copy link
Contributor

Choose a reason for hiding this comment

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

冗余

}
if (strcasecmp(name, "authReqInterval") == 0) {
tsAuthReqInterval = pItem->i32;
code = TSDB_CODE_SUCCESS;
Copy link
Contributor

Choose a reason for hiding this comment

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

冗余

goto _exit;
}
if (strcasecmp(name, "authReqUrl") == 0) {
TAOS_CHECK_RETURN(taosCheckCfgStrValueLen(pItem->name, pItem->str, TSDB_FQDN_LEN));
Copy link
Contributor

Choose a reason for hiding this comment

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

返回的话,_exit 处的 cfgUnLock(pCfg) 未执行。

if (strcasecmp(name, "authReqUrl") == 0) {
TAOS_CHECK_RETURN(taosCheckCfgStrValueLen(pItem->name, pItem->str, TSDB_FQDN_LEN));
tstrncpy(tsAuthReqUrl, pItem->str, TSDB_FQDN_LEN);
code = TSDB_CODE_SUCCESS;
Copy link
Contributor

Choose a reason for hiding this comment

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

冗余

@Pengrongkun Pengrongkun requested a review from a team as a code owner November 11, 2025 10:03
@guanshengliang guanshengliang merged commit 47c45f3 into 3.3.6 Nov 11, 2025
12 of 13 checks passed
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.

4 participants