← Back to Pull requests

hdfs: close file writer on write error and return close errors #5061

Open
unknown opened this pull request with 189 lines diff across 2 files
View on GitHub
unknown unknown commented on Oct 27, 2026 01:57 UTC
Author

The hdfs output dropped the error from FileWriter.Close(), and if Write() failed it returned before closing the writer at all. Close() is where the client flushes the last block and sends complete to the namenode, so when it fails the file stays under construction while the message is still acked. That's what made the stuck files in #5051 so hard to spot: nothing showed up in the logs.

This change:

  • reads the message bytes before creating the file, so a failed AsBytes() no longer leaves an open writer behind

  • closes the writer when Write() fails

  • returns the Close() error (wrapped with the file path), so the message gets retried instead of acked
  • To make the write path testable without a cluster, the writer now holds a small hdfsClient interface (MkdirAll and Create), and Connect wraps *hdfs.Client in an adapter. output_test.go adds unit tests for the success path, a failing Write, and a failing Close. The two error tests fail on the current code and pass with this change.

    This doesn't add erasure-coding support. colinmarc/hdfs can't write striped files (colinmarc/hdfs#318), and v1.1.3 also ignores complete returning false, so this fix alone won't surface that case. It does mean a real Close() failure is no longer silent.

    Tested locally with Go 1.27.3 on macOS arm64: go test ./internal/impl/hdfs/ passes (the integration test is skipped without Docker), and go vet and gofmt -l are clean. I didn't run golangci-lint or the HDFS integration test.

    Diff: 189 lines (+141 / -48) across 2 files Reviewer: ska2704 Review duration: 49766m
    All Vouch review confidence checks passed
    Residual risk 0.25 = Change Risk (0.43) × (1 − Review Confidence (0.41)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 189 lines diff across 2 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    40%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.314
    Real PR Conversation Timeline
    1 comments
    "Review active on #5061"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 40.9% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.9% (MEDIUM) · Higher = larger blast radius
    42.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 40.9% · Lower = rushed or shallow review
    40.9%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 25.3% · Safe to merge
    25.3%