Skip to content

[BugFix] Record audit stats for async materialized view refresh#74954

Open
spaces-X wants to merge 1 commit into
StarRocks:mainfrom
spaces-X:fix/mv-refresh-audit-stats
Open

[BugFix] Record audit stats for async materialized view refresh#74954
spaces-X wants to merge 1 commit into
StarRocks:mainfrom
spaces-X:fix/mv-refresh-audit-stats

Conversation

@spaces-X

@spaces-X spaces-X commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Why I'm doing:

Close #74942

Async materialized view refresh audit-log entries lost the CpuCostNs / MemCostBytes / ScanBytes / ScanRows fields. This is a regression introduced by #56257, which centralized audit-stats writing into StmtExecutor.recordExecStatsIntoContext() (only called from
execute() / executeStmtWithExecPlan() / executeStmtWithResultQueue()) and removed the old fallback in ConnectProcessor.auditAfterExec().

MV refresh does not go through execute(): it calls executor.handleDMLStmtWithProfile() directly, so recordExecStatsIntoContext() is never invoked and the statistics never reach the audit-event builder, even though the data is available via
executor.getQueryStatisticsForAuditLog().

What I'm doing:

Flush exec statistics into the audit-event builder on the MV-refresh path before auditAfterExec, mirroring what execute() does in its finally block. recordExecStatsIntoContext() is made public (it lives in qe, the caller in scheduler).

It is intentionally not placed inside handleDMLStmtWithProfile(): execute() also calls handleDMLStmtWithProfile() and then calls recordExecStatsIntoContext() in its own finally, so flushing inside handleDMLStmtWithProfile() would double-count for normal
INSERTs (the builder uses accumulating add*). The MV-refresh path uses a fresh ConnectContext whose builder starts at the default -1, so a single explicit call is correct and not double-counted.

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This PR needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport PR

Bugfix cherry-pick branch check:

  • I have checked the version labels which the PR will be auto-backported to the target branch
    • 4.1
    • 4.0
    • 3.5
    • 3.4
    • 3.3

Signed-off-by: WeiXiang <wx531766@alibaba-inc.com>
@spaces-X spaces-X force-pushed the fix/mv-refresh-audit-stats branch from 8c7ed7b to 4fed467 Compare June 18, 2026 06:41
@CelerData-Reviewer

Copy link
Copy Markdown

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 4fed4671c1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

Copy link
Copy Markdown
Contributor

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

@github-actions

Copy link
Copy Markdown
Contributor

[FE Incremental Coverage Report]

pass : 1 / 1 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 com/starrocks/scheduler/MVTaskRunProcessor.java 1 1 100.00% []

@github-actions

Copy link
Copy Markdown
Contributor

[BE Incremental Coverage Report]

pass : 0 / 0 (0%)

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.

[BugFix] Async materialized view refresh audit log misses CpuCostNs / MemCostBytes / ScanBytes

2 participants