Skip to content

Conversation

@JinqingKuang
Copy link
Contributor

@JinqingKuang JinqingKuang commented Jan 29, 2026

Description

fix(stream): fix tsma delay time report

Issue(s)

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?
Copilot AI review requested due to automatic review settings January 29, 2026 09:48
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @JinqingKuang, 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 addresses an issue with the reporting of delay times within the TSMA (Time-Series Moving Average) stream processing. The core changes involve standardizing the unit of time for verTime to microseconds, ensuring this timestamp is consistently and correctly populated across various stream processing stages, and accurately transmitted in RPC responses. Additionally, the calculation of stream delay has been corrected to reflect these standardized units, and a minor adjustment to a CI test configuration has been made.

Highlights

  • verTime Unit Clarification: The verTime field in the SSTriggerWalNewRsp structure is explicitly marked as using microseconds (us) for clarity.
  • Consistent verTime Population: Logic has been added or modified in processWalVerMetaNew and prepareIndexMetaData to ensure verTime is correctly populated with either 0 or the current microsecond timestamp (taosGetTimestampUs()) when WAL logs are not found.
  • Enhanced RPC Response for No Data: When a stream pull request returns TSDB_CODE_STREAM_NO_DATA, the RPC response now includes both the version (ver) and the version time (verTime), requiring a larger buffer allocation.
  • Corrected Delay Calculation: The stTriggerTaskGetDelay function now uses microsecond timestamps for now and converts the difference to nanoseconds, fixing a potential unit mismatch in delay reporting.
  • Robust Pull Response Processing: The stRealtimeContextProcPullRsp function has been updated to correctly parse the extended RPC response, extracting both the version and version time when TSDB_CODE_STREAM_NO_DATA is received.
  • CI Test Configuration Update: A CI test task for test_tsma.py has been adjusted by removing a numerical prefix, potentially affecting its execution priority or timeout.

🧠 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 fixes a delay time reporting issue for TSMA by introducing a verTime field and propagating it through the stream processing pipeline. When there's no data, the current time is used as verTime to calculate the delay. The delay calculation logic is also updated to use microseconds. The changes appear correct and address the issue described in the title. My feedback focuses on improving code readability in a few places where complex pointer arithmetic is used, suggesting a more conventional array-style access.

Comment on lines +3033 to +3034
*(int64_t*)buf = resultRsp.ver;
*(((int64_t*)buf) + 1) = resultRsp.verTime;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better readability and maintainability, consider using array-style access instead of pointer arithmetic to access elements in the buffer.

    ((int64_t*)buf)[0] = resultRsp.ver;
    ((int64_t*)buf)[1] = resultRsp.verTime;
Comment on lines +3086 to +3087
*(int64_t*)buf = resultRsp.ver;
*(((int64_t*)buf) + 1) = resultRsp.verTime;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better readability and maintainability, consider using array-style access instead of pointer arithmetic to access elements in the buffer.

    *(int64_t*)buf = resultRsp.ver;
    ((int64_t*)buf)[1] = resultRsp.verTime;
blockDataEmpty(pContext->pDropBlock);
pContext->pMetaBlock->info.version = *(int64_t *)pRsp->pCont;
if (pRsp->contLen > sizeof(int64_t)) {
pProgress->verTime = *(((int64_t *)pRsp->pCont) + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better readability and maintainability, consider using array-style access instead of pointer arithmetic to access elements in the buffer.

          pProgress->verTime = ((int64_t *)pRsp->pCont)[1];
blockDataEmpty(pContext->pDropBlock);
pContext->pMetaBlock->info.version = *(int64_t *)pRsp->pCont;
if (pRsp->contLen > sizeof(int64_t)) {
pProgress->verTime = *(((int64_t *)pRsp->pCont) + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For better readability and maintainability, consider using array-style access instead of pointer arithmetic to access elements in the buffer.

            pProgress->verTime = ((int64_t *)pRsp->pCont)[1];
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes TSMA (Time-Series Moving Average) delay time reporting by correcting timestamp unit handling and ensuring consistent verTime tracking across the streaming system.

Changes:

  • Fixed timestamp unit conversion in delay calculation from nanoseconds to microseconds
  • Enhanced protocol to optionally include verTime in no-data responses
  • Added verTime initialization in WAL scanning paths

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
test/ci/cases.task Removed timeout configuration for test_tsma.py test (likely no longer needed after timing fix)
source/libs/new-stream/src/streamTriggerTask.c Fixed delay calculation to use microseconds and made protocol backward compatible for optional verTime extraction
source/dnode/vnode/src/vnd/vnodeStream.c Added verTime initialization in WAL scan paths and updated no-data responses to include verTime
include/common/streamMsg.h Added documentation clarifying verTime is in microseconds

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

2 participants