Skip to content

Conversation

@hjxilinx
Copy link
Contributor

@hjxilinx hjxilinx commented Nov 7, 2025

Description

refactor(query): refactor query task redirect process.

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 @hjxilinx, 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 focuses on a significant refactoring of the query task redirect and retry process within the scheduler. The changes aim to enhance the robustness and clarity of how tasks handle failures and subsequent retries. By simplifying internal data structures, centralizing common logic, and introducing more dynamic retry calculations, the system can better adapt to transient issues and improve overall task execution reliability.

Highlights

  • Retry Logic Refactoring: The core retry logic for query tasks has been significantly refactored. This includes simplifying the SSchRedirectCtx structure, centralizing retry decision-making into new helper functions, and updating how retry attempts and delays are calculated.
  • Increased Default Max Retries: The default maximum number of retries (SCH_DEFAULT_MAX_RETRY_NUM) has been increased from 6 to 12, providing more resilience for task execution.
  • Centralized Node Address Retrieval: A new helper function, schGetTaskCurrentNodeAddr, has been introduced and integrated across various scheduler components to standardize the retrieval of the current candidate node address for a task.
  • Dynamic Retry Calculation: The maxRetryTimes for tasks are now calculated more dynamically in schInitTaskRetryInfo, taking into account tsMaxRetryWaitTime, redirectDelayMs, and a REPLICA_FACTOR for data-bound tasks.
  • Simplified Redirect Context Update: The schChkUpdateRedirectCtx function has been streamlined, removing complex round-based logic and now using a simple resetRetry boolean flag to manage the redirect context.
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 refactors the query task redirect process, simplifying the retry logic and improving code structure by extracting helper functions. The changes make the retry mechanism more robust and the code easier to maintain. I've identified a likely bug involving a duplicated function call that could cause issues with node selection during retries. I've also included a couple of suggestions to replace magic numbers with named constants to improve maintainability.


void schInitTaskRetryTimes(SSchJob *pJob, SSchTask *pTask, SSchLevel *pLevel) {
void schInitTaskRetryInfo(SSchJob *pJob, SSchTask *pTask, SSchLevel *pLevel) {
pTask->redirectCtx.redirectDelayMs = 2000; // 2s by default
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The value 2000 is used as a default for redirectDelayMs. It would be better to define this as a named constant (e.g., SCH_DEFAULT_REDIRECT_DELAY_MS) in a relevant header file for better readability and maintainability.

pTask->redirectCtx.redirectDelayMs = 2000; // 2s by default

// 3 is the maximum replica factor in tsdb, so here multiply 3 to increase the retry chance
int32_t REPLICA_FACTOR = 3;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The replica factor 3 is hardcoded here. While the comment explains its purpose, defining it as a named constant (e.g., TSDB_MAX_REPLICA_FACTOR) would improve code clarity and make it easier to change if the system's replica factor changes in the future.

@guanshengliang guanshengliang merged commit 7c273f1 into 3.3.6 Nov 7, 2025
11 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.

3 participants