Conversation
WalkthroughChanges introduce per-entry execution context isolation in PostgreSQL wire protocol batch processing. PGPipelineEntry now maintains individual SqlExecutionContext and BindVariableService instances, while PGConnectionContext routes pipeline operations through entry-scoped contexts instead of the shared global sqlExecutionContext. Changes
Sequence DiagramsequenceDiagram
participant Client
participant PGConnectionContext
participant PGPipelineEntry
participant Engine
Note over Client,Engine: Batched Queries with Bound Parameters
Client->>PGConnectionContext: Send batch (Query 1 + params=1, Query 2 + params=2, ...)
PGConnectionContext->>PGPipelineEntry: Create entry N (entryExecutionContext initialized)
PGPipelineEntry->>PGPipelineEntry: BindVariableService created per entry
PGConnectionContext->>PGPipelineEntry: msgExecute(entryExecutionContext)
PGPipelineEntry->>Engine: execute(entryExecutionContext with params=N)
Engine-->>PGPipelineEntry: Result for Query N
PGPipelineEntry->>PGConnectionContext: Return result
Note over PGPipelineEntry: Parameters isolated per entry
alt Next entry in batch
PGConnectionContext->>PGPipelineEntry: Create entry N+1 (fresh entryExecutionContext)
PGPipelineEntry->>PGPipelineEntry: New BindVariableService created
PGConnectionContext->>PGPipelineEntry: msgExecute(entryExecutionContext)
PGPipelineEntry->>Engine: execute(entryExecutionContext with params=N+1)
Engine-->>PGPipelineEntry: Result for Query N+1
end
PGConnectionContext->>Client: Return all results in order
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
WIP
Fixes #6123
A single BindVariableService was shared between all PGPipelineEntry instances managed by a PGConnectionContext.
When running batched queries, bind-execute messages would be sent in sequence. These would re-bind the BindVariableService entries and then compile each subsequent query.
Unfortunately, only after a sync message would the results be returned. The cursors all share the same BindVariableService, so only the values of the last query are applied.
The proposed fix in this PR is to dedicate an execution context and bind variable service to each entry, so it is isolated from the other queries in the batch.
To run the test:
Update: the fix was PoCed but it needs proper attention, there will be a superceding PR.