Skip to content

Open commit inject logging - #22116

Merged
XuPeng-SH merged 3 commits into
matrixorigin:2.2-devfrom
XuPeng-SH:open-commit-inject
Jul 7, 2025
Merged

XuPeng-SH merged 3 commits into
matrixorigin:2.2-devfrom
XuPeng-SH:open-commit-inject

Conversation

@XuPeng-SH

@XuPeng-SH XuPeng-SH commented Jul 7, 2025 •

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 #22115

What this PR does / why we need it:

Open commit inject logging


PR Type

Bug fix


Description

  • Enable commit insert logging injection for debugging

  • Uncomment and activate existing debug logging code

  • Add fault injection point for commit insert operations

  • Restore debug logging for delete operations


Changes diagram

flowchart LR
  A["Add FJ_CommitInsert constant"] --> B["Enable insert logging"]
  B --> C["Enable delete logging"]
  C --> D["Add test fault injection"]
Loading

Changes walkthrough 📝

Relevant files
Enhancement
injects.go
Add commit insert fault injection constant                             

pkg/objectio/injects.go

  • Add FJ_CommitInsert constant for fault injection
+1/-0     
Bug fix
handle.go
Enable commit operation debug logging                                       

pkg/vm/engine/tae/rpc/handle.go

  • Add vector import for type checking
  • Uncomment and enable insert operation debug logging
  • Uncomment and enable delete operation debug logging
  • Add fault injection triggers for both operations
  • +57/-57 
    Tests
    disttae_engine_test.go
    Add commit insert fault injection test                                     

    pkg/vm/engine/test/disttae_engine_test.go

  • Add fault injection setup for commit insert testing
  • Include proper cleanup with defer statement
  • +12/-0   

    Need help?
  • Type /help how to ... in the comments thread for any questions about Qodo Merge usage.
  • Check out the documentation for more information.
  • @qodo-code-review

    Copy link
    Copy Markdown

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    Performance Impact

    The debug logging code is now enabled for all operations when fault injection is triggered or for intercepted tables. This could generate excessive logs in production environments and impact performance, especially for high-throughput insert/delete operations.

    _, _, injected := fault.TriggerFault(objectio.FJ_CommitInsert)
    if h.IsInterceptTable(tb.Schema(false).(*catalog.Schema).Name) || injected {
    	schema := tb.Schema(false).(*catalog.Schema)
    	if schema.HasPK() {
    		pkDef := schema.GetSingleSortKey()
    		idx := pkDef.Idx
    		isCompositeKey := pkDef.IsCompositeColumn()
    		for i := 0; i < req.Batch.Vecs[0].Length(); i++ {
    			if isCompositeKey {
    				pkbuf := req.Batch.Vecs[idx].GetBytesAt(i)
    				tuple, _ := types.Unpack(pkbuf)
    				logutil.Info(
    					"op1",
    					zap.String("txn", txn.String()),
    					zap.String("pk", common.TypeStringValue(*req.Batch.Vecs[idx].GetType(), pkbuf, false)),
    					zap.Any("detail", tuple.SQLStrings(nil)),
    				)
    			} else {
    				logutil.Info(
    					"op1",
    					zap.String("txn", txn.String()),
    					zap.String("pk", common.MoVectorToString(req.Batch.Vecs[idx], i)),
    				)
    			}
    		}
    	}
    
    }
    Missing Import

    The code uses fault.TriggerFault but there's no visible import for the fault package in the diff. This could cause compilation errors if the import is not present elsewhere in the file.

    _, _, injected := fault.TriggerFault(objectio.FJ_CommitInsert)
    if h.IsInterceptTable(tb.Schema(false).(*catalog.Schema).Name) || injected {

    @mergify mergify Bot added the kind/bug Something isn't working label Jul 7, 2025
    @qodo-code-review

    qodo-code-review Bot commented Jul 7, 2025 •

    Copy link
    Copy Markdown

    PR Code Suggestions ✨

    Explore these optional code suggestions:

    CategorySuggestion                                                                                                                                    Impact
    Possible issue
    Add bounds and nil checks

    Add nil check for req.Batch.Vecs[idx] before accessing it to prevent potential
    panic. The vector at index idx might be nil or the index could be out of bounds.

    pkg/vm/engine/tae/rpc/handle.go [973-1000]

     _, _, injected := fault.TriggerFault(objectio.FJ_CommitInsert)
     if h.IsInterceptTable(tb.Schema(false).(*catalog.Schema).Name) || injected {
         schema := tb.Schema(false).(*catalog.Schema)
         if schema.HasPK() {
             pkDef := schema.GetSingleSortKey()
             idx := pkDef.Idx
    +        if idx >= len(req.Batch.Vecs) || req.Batch.Vecs[idx] == nil {
    +            return
    +        }
             isCompositeKey := pkDef.IsCompositeColumn()
             for i := 0; i < req.Batch.Vecs[0].Length(); i++ {
                 ...
             }
         }
     
     }

    [To ensure code accuracy, apply this suggestion manually]

    Suggestion importance[1-10]: 7

    __

    Why: The suggestion correctly identifies a potential panic from out-of-bounds access on req.Batch.Vecs[idx] and provides a valid check, improving the code's robustness.

    Medium
    • Update

    This branch was previously deployed

    1 inactive deployment
    ci — c8711822 Deployed Jul 7, 2025 by XuPeng-SH
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    kind/bug Something isn't working Review effort 2/5 size/M Denotes a PR that changes [100,499] lines

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    3 participants