Skip to content

fix:retry with table meta change#33977

Merged
guanshengliang merged 1 commit into3.3.6from
fix/3.3.6/6583546898
Dec 19, 2025
Merged

fix:retry with table meta change#33977
guanshengliang merged 1 commit into3.3.6from
fix/3.3.6/6583546898

Conversation

@Pengrongkun
Copy link
Contributor

Description

Issue(s)

  • Close/close/Fix/fix/Resolve/resolve: Issue Link

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 enhances the robustness of INSERT operations by refining the error handling logic for schema mismatches. It introduces a mechanism to signal when an INSERT might need to be retried due to underlying table metadata changes, thereby improving the system's ability to adapt to dynamic schema environments and reducing the likelihood of hard failures during data ingestion.

Highlights

  • Improved INSERT Error Handling: The parseOneRow function has been updated to provide more specific error feedback when an INSERT statement's column count doesn't match the expected table schema. Instead of a generic syntax error, it now returns TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER under certain conditions.
  • Retry Mechanism for Table Meta Changes: When pCxt->forceUpdate is false and a column mismatch is detected, the system will now issue a warning and return a specific error code, indicating that a retry is needed. This is designed to handle scenarios where the table's metadata might have changed, allowing the client to re-fetch schema information and retry the operation.

🧠 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.

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 introduces a fix to handle table metadata changes during INSERT operations by triggering a retry. The implementation is sound, but I've suggested a small improvement to make the retry condition more specific to avoid unnecessary retries on genuine syntax errors. Overall, a good enhancement for robustness.

Comment on lines +2399 to +2405
if (!pCxt->forceUpdate) {
code = TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER;
parserWarn("QID:0x%" PRIx64 ", column number is smaller than %d, need retry", pCxt->pComCxt->requestId,
pCols->numOfBound);
} else {
code = buildSyntaxErrMsg(&pCxt->msg, ", expected", pToken->z);
}
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 current logic for retrying on schema changes is a bit too broad. It triggers a retry for any token that is not a comma, which includes genuine syntax errors like a missing comma between values (e.g., VALUES(1 2)). This leads to an unnecessary retry cycle for what is a clear syntax error.

To make the retry mechanism more precise, we should only trigger it when we encounter a closing parenthesis ) prematurely, as this is a clear signal that the client is providing fewer columns than the server expects due to a stale schema. Other cases should be treated as syntax errors immediately.

        if (pToken->type == TK_NK_RP && !pCxt->forceUpdate) {
          code = TSDB_CODE_TDB_INVALID_TABLE_SCHEMA_VER;
          parserWarn("QID:0x%" PRIx64 ", column number is smaller than %d, need retry", pCxt->pComCxt->requestId,
                     pCols->numOfBound);
        } else {
          code = buildSyntaxErrMsg(&pCxt->msg, ", expected", pToken->z);
        }

@guanshengliang guanshengliang merged commit 17ae1e5 into 3.3.6 Dec 19, 2025
12 of 13 checks passed
@guanshengliang guanshengliang deleted the fix/3.3.6/6583546898 branch December 19, 2025 02:54
zitsen added a commit that referenced this pull request Dec 21, 2025
* 3.0: (1127 commits)
  fix: confilcts
  enh(grant): support data source Pulsar (#33978)
  feat: support TOTP code login and password expired tip (#33969)
  refactor: support Python3.12 (#33985)
  fix: audit req, select and insert support (#33960)
  fix: [6589381451] Add virtual table datatype check when query. (#33973)
  fix: [6589381451] Add virtual table datatype check when query. (#33972)
  fix: fix wal unittest (#33970)
  fix: retry with table meta change (#33977)
  fix: ci case
  docs: update 02-concept.md (#33981)
  fix: build error
  fix(TS-7676): sub query with window main test (#33790)
  docs: update nodejs docs (#33807)
  enh: window query without agg function support (#33759)
  fix lint
  docs: update cloud quick start
  Update new-framework-test.yml (#33966)
  Update new-framework-test.yml (#33965)
  feat: TS-7270 add doc (#33955)
  ...
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