Skip to content

fix drop account error - #18500

Merged
mergify[bot] merged 3 commits into
matrixorigin:1.2-devfrom
YANGGMM:fix-18487-1.2
Sep 3, 2024
Merged

mergify[bot] merged 3 commits into
matrixorigin:1.2-devfrom
YANGGMM:fix-18487-1.2

Conversation

@YANGGMM

@YANGGMM YANGGMM commented Sep 3, 2024 •

Copy link
Copy Markdown
Contributor

User description

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #18499 #18475 #16583

What this PR does / why we need it:

fix drop account error
drop account if not exists will post drop sys account request and add sys account to kill queue


PR Type

Bug fix


Description

  • Fixed a bug in doDropAccount by adding a check to return an error if the account does not exist.
  • Added a condition in postDropSuspendAccount to return an error if the account ID is zero.
  • Removed unnecessary logging in deleteRoutine method of AccountRoutineManager.

Changes walkthrough 📝

Relevant files
Bug fix
authenticate.go
Add error checks in account drop logic                                     

pkg/frontend/authenticate.go

  • Added a check to return error if account does not exist.
  • Added a check to return error if account ID is zero.
  • +6/-0     
    routine_manager.go
    Remove logging for account deletion routine                           

    pkg/frontend/routine_manager.go

    • Removed logging statement for account deletion.
    +0/-1     

    💡 PR-Agent usage:
    Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    @qodo-code-review

    Copy link
    Copy Markdown

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Reviewer Guide 🔍

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 No relevant tests
    🔒 No security concerns identified
    ⚡ Key issues to review

    Error Handling
    The new error checks in doDropAccount and postDropSuspendAccount return the error variable err without setting it. This might lead to returning nil errors when actual errors should be returned.

    Incomplete Fix
    The check for accountID == 0 in postDropSuspendAccount might not cover all cases of invalid account IDs. Consider adding a more comprehensive check or explanation for why only zero is checked.

    @mergify
    mergify Bot requested a review from sukki37 September 3, 2024 07:54
    @mergify mergify Bot added the kind/bug Something isn't working label Sep 3, 2024
    @qodo-code-review

    Copy link
    Copy Markdown

    PR-Agent was enabled for this repository. To continue using it, please link your git user with your CodiumAI identity here.

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Error handling
    Log error information before returning it

    Consider logging the error before returning it, to provide more context for
    debugging.

    pkg/frontend/authenticate.go [4304-4306]

     if accountID == 0 {
    -    return err
    +    logutil.Errorf("Invalid account ID: %d", accountID)
    +    return fmt.Errorf("invalid account ID")
     }
     
    • Apply this suggestion
    Suggestion importance[1-10]: 9

    Why: Logging the error before returning provides valuable context for debugging and helps trace issues related to invalid account IDs.

    9
    Return a specific error when the account doesn't exist

    Consider returning a specific error indicating that the account doesn't exist,
    instead of returning a potentially unrelated error.

    pkg/frontend/authenticate.go [4288-4290]

     if !hasAccount {
    -    return err
    +    return fmt.Errorf("account does not exist")
     }
     
    • Apply this suggestion
    Suggestion importance[1-10]: 8

    Why: The suggestion improves error handling by returning a specific error message when the account doesn't exist, which enhances clarity and debugging.

    8
    Check for nil error before returning it

    Consider checking if err is nil before returning it, to avoid returning a
    potentially nil error.

    pkg/frontend/authenticate.go [4288-4290]

     if !hasAccount {
    -    return err
    +    if err != nil {
    +        return err
    +    }
    +    return fmt.Errorf("account does not exist")
     }
     
    • Apply this suggestion
    Suggestion importance[1-10]: 7

    Why: This suggestion ensures that a nil error is not returned, which prevents potential runtime issues and improves error handling robustness.

    7

    @matrix-meow matrix-meow added the size/XS Denotes a PR that changes [1, 9] lines label Sep 3, 2024
    @mergify
    mergify Bot merged commit 8dec1bc into matrixorigin:1.2-dev Sep 3, 2024
    @YANGGMM
    YANGGMM deleted the fix-18487-1.2 branch October 15, 2024 07:40
    iamlinjunhong pushed a commit to iamlinjunhong/matrixone that referenced this pull request Jun 25, 2025
    fix drop account error
    drop account if not exists will post drop sys account request and add sys account to kill queue
    
    Approved by: @daviszhen, @sukki37
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    Bug fix kind/bug Something isn't working Review effort [1-5]: 2 size/XS Denotes a PR that changes [1, 9] lines

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    4 participants