Skip to content

Conversation

cuiweixie
Copy link

Description

Please explain the changes you made here.

Checklist

  • Code compiles correctly and linting passes locally
  • For all code changes, an entry added to the CHANGELOG.md file describing and linking to
    this PR
  • Tests added for new functionality, or regression tests for bug fixes added as applicable
  • For public APIs, new features, etc., PR on
    docs repo staged and linked here

Instructions

  • The PR title should follow the Conventional Commits
    syntax, leading with fix:, feat:, chore:, ci:, etc.
  • The description should briefly explain what the PR is about. In the case of a bugfix, describe or
    link to the bug.
  • In the checklist section, check the boxes in that are applicable, using [x] syntax.
    • If not applicable, remove the entire line. Only leave the box unchecked if you intend to come
      back and check the box later.
  • Delete the Instructions line and everything below it, to indicate you have read and are
    following these instructions. 🙂

Thank you for your contribution to Dgraph!

@Copilot Copilot AI review requested due to automatic review settings August 22, 2025 01:59
@cuiweixie cuiweixie requested a review from a team as a code owner August 22, 2025 01:59
Copy link

@Copilot 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 PR refactors the audit module to use the atomic type atomic.Uint32 instead of manually using atomic package functions with a uint32 variable. This change modernizes the code to use Go's newer atomic types that provide cleaner syntax and better type safety.

  • Replaces uint32 variable with atomic.Uint32 type
  • Updates all atomic operations to use the built-in methods
  • Simplifies code by removing explicit atomic package function calls

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
audit/audit.go Changes variable declaration from uint32 to atomic.Uint32 and updates Store/Load operations
audit/interceptor.go Updates all Load operations to use the new atomic type's built-in methods

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@@ -116,7 +116,7 @@ func InitAuditor(conf *x.LoggerConf, gId, nId uint64) error {
// It also sets the log to nil, because its being called by zero when license expires.
// If license added, InitLogger will take care of the file.
func Close() {
if atomic.LoadUint32(&auditEnabled) == 0 {
if auditEnabled.Load() == 0 {
return
}
auditor.log.Sync()
Copy link
Preview

Copilot AI Aug 22, 2025

Choose a reason for hiding this comment

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

The audit log is being synchronized but auditEnabled is not being reset to 0 after closing. This means the enabled check will continue to pass even after the auditor is closed, potentially causing nil pointer dereferences when trying to use the closed log.

Copilot uses AI. Check for mistakes.

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

Successfully merging this pull request may close these issues.

1 participant