fix: concurrent access for internal proto map#1369
Conversation
…resolvers-causes-issues
|
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThis PR introduces ID-based tracking for gRPC RPC calls across the execution planning and data fetching pipeline. It adds an ID field to ServiceCall and RPCCall, implements protobuf cloning on ServiceCall output, refactors the DependencyGraph to use synchronized access with fetch items keyed by call ID, and overhauls the execution plan visitors to properly correlate calls with field resolvers. Test infrastructure is extended with new category resolver scenarios. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant Visitor as Execution<br/>Plan Visitor
participant Compiler
participant DS as Data Source
participant Graph as Dependency<br/>Graph
participant GRPC as gRPC<br/>Service
Client->>Visitor: Build Execution Plan
Visitor->>Compiler: Compile Calls & Fetches
Compiler->>Compiler: Assign ID to each Call
Visitor->>Compiler: Store Node ID in ServiceCall.ID
Compiler-->>Visitor: RPCExecutionPlan
Visitor->>Graph: NewDependencyGraph(plan)
Graph->>Graph: Initialize nodes/fetches<br/>keyed by call.ID
Note over DS,GRPC: Fetch Phase
DS->>GRPC: Execute RPC Call
GRPC-->>DS: Response (protobuf message)
DS->>DS: cloneOutput()<br/>(deep clone via proto.Clone)
DS->>Graph: SetFetchData(call.ID, clonedOutput)
Graph->>Graph: Lock (write)<br/>FetchItem[call.ID].Output = clonedOutput
Note over Graph,Client: Resolution Phase
Graph->>Graph: TopologicalSortResolve()
Graph->>Graph: Lock (read)<br/>Fetch(callIndex)
Graph-->>Graph: FetchItem with Output
Graph->>Client: Resolved Dependencies
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes The changes span multiple interconnected components with significant structural modifications: introduction of global call indexing and ID-based correlation across visitors, replacement of field types in public structs (FetchItem.ServiceCall → Output), addition of mutex-protected synchronization, refactored planning state with new tracking mechanisms (callIndex, fieldResolverAncestors, operationFieldRefs), and 1600+ lines of heterogeneous test additions combining new test cases with extensive mock service extensions and protobuf schema changes. Possibly related PRs
✨ Finishing touches
Comment |
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.
Checklist