8000 Fix critical bugs in audit record processing: NULL checks, memory leaks, and statistics corruption by Copilot · Pull Request #34425 · taosdata/TDengine · GitHub
[go: up one dir, main page]

Skip to content

Conversation

Copy link
Copilot AI commented Jan 28, 2026

Code review identified critical bugs in the audit self-save functionality that could cause crashes, memory leaks, and incorrect statistics on failure paths.

Changes

  • Fix statistics corruption: Wrap all statistics/metrics updates in success check - nInsert, nInsertSuccess, nBatchInsert, and monitoring counters were being incremented even when operations failed

  • Add NULL pointer guards:

    • Check tjsonGetArrayItem() result before use (can return NULL for invalid arrays)
    • Check req.data after deserialization (can be NULL for empty strings)
  • Fix memory leaks: Replace early returns with TAOS_CHECK_GOTO to ensure tFreeSVAuditRecordReq() cleanup always runs

  • Code quality: Remove duplicate "failed" in error message, add braces for multi-line if statements

// Before: Statistics updated unconditionally
_exit:
  atomic_add_fetch_64(&pVnode->statis.nInsertSuccess, rows);  // Wrong on failure
  
// After: Only update on success
_exit:
  if (code == 0) {
    atomic_add_fetch_64(&pVnode->statis.nInsertSuccess, rows);
  }

Files Changed

  • source/dnode/vnode/src/vnd/vnodeSvr.c - Error handling in vnodeProcessAuditRecordReq and vnodeSaveOneAuditRecord

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI mentioned this pull request Jan 28, 2026
3 tasks
@cadem cadem marked this pull request as ready for review January 28, 2026 07:20
@gemini-code-assist
Copy link
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

Co-authored-by: cadem <3262235+cadem@users.noreply.github.com>
Co-authored-by: cadem <3262235+cadem@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix issue in self audit git Fix critical bugs in audit record processing: NULL checks, memory leaks, and statistics corruption Jan 28, 2026
Copilot AI requested a review from cadem January 28, 2026 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0