-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
Description
The goFdwBeginForeignScan() function in fdw.go has nested defer statements for panic recovery, but the code lacks comments explaining why this pattern is used. Additionally, the outer defer has an incorrect log message.
Current Code Issues
1. Incorrect log message
The outer defer logs goFdwExplainForeignScan but we're in goFdwBeginForeignScan:
func goFdwBeginForeignScan(node *C.ForeignScanState, eflags C.int) {
defer func() {
if r := recover(); r != nil {
log.Printf("[WARN] goFdwExplainForeignScan failed with panic: %v", r) // WRONG!
// ...
}
}()2. Missing documentation
The nested defer pattern is intentional but not documented:
defer func() { /* outer recover */ }()
// ... early init code ...
defer func() { /* inner recover */ }()
// ... main processing ...Proposed Fix
- Fix the log message to say
goFdwBeginForeignScan - Add comments explaining why nested defers exist:
- Outer: catches panics during early initialization
- Inner: catches panics during main scan processing
Impact
- Risk: None - Documentation only
- Functionality: No behavioral change
- Benefit: Easier maintenance and debugging
Metadata
Metadata
Assignees
Labels
No labels