← Back to Pull requests

refactor(inkless:delete): improve retention-enforcement observability #725

Closed
unknown closed this pull request without merging on Jul 29, 2026 12:57 UTC
View on GitHub
unknown unknown commented on Jul 28, 2026 13:40 UTC
Author

Improves observability of diskless retention enforcement and file cleanup. No change to enforcement or cleanup behavior. Three focused commits, all in the io.aiven.inkless.delete / control-plane area.

What changed

  • Schedule-lag gauge — new RetentionEnforcementScheduleLagMs gauge: milliseconds the most overdue diskless partition is past its scheduled enforcement time (0 when on schedule; a sustained positive value means enforcement is falling behind its per-partition cadence). Fed by the scheduler's oldest past-due queue entry, read under a lock so the metrics/JMX thread and the enforcement thread don't race the PriorityQueue.

  • Per-partition enforce latency — EnforceRetentionJob runs one transaction per partition (post-#705), so EnforceRetentionQueryTime/QueryRate are now recorded per partition instead of once per wave. No new metric.

  • Intent/result run logs — enforcer and file cleaner now log a "starting" intent line before the potentially-blocking work and a "done" line after, so a stuck operation shows as intent-without-completion.
  • Metrics

    New:

  • RetentionEnforcer.RetentionEnforcementScheduleLagMs — gauge (ms).
  • Redefined (operator impact — re-baseline any dashboards/alerts on these): PostgresControlPlane.EnforceRetentionQueryTime and EnforceRetentionQueryRate now measure a single enforce_retention_v2 call (one partition) rather than the whole wave. QueryRate rises by roughly partitions-per-wave with no config change; QueryTime percentiles become per-partition latencies. Nothing is lost — the whole-wave duration remains RetentionEnforcer.RetentionEnforcementTotalTime and the wave count remains RetentionEnforcementRate. Per-transaction latency is the more accurate thing to measure since each partition is its own transaction.

    Logs

  • Enforcer: per-cycle summary promoted DEBUG -> INFO and paired with an intent line — Enforcing retention for {n} partitions / Enforced retention for {n} partitions in {ms} ms: {b} batches, {y} bytes deleted. One pair per non-empty cycle; empty cycles stay silent (no per-tick heartbeat, since the enforcer ticks every 500ms).

  • File cleaner: replaced the per-run Running file cleaner at {now} heartbeat (redundant with the log framework timestamp and the outcome line) with a work-gated pair — Running file cleaner: deleting {n} of {m} marked files / File cleaner deleted {n} files in {ms} ms (the m - n files are still within the retention grace period).

  • Also fixes a latent partition misattribution in the enforcer's per-partition log lines (they indexed readyPartitions while responses align with the delete-policy-filtered requests); now uses a list kept aligned 1:1 with requests/responses. Latent today (diskless doesn't support compaction, so the lists don't diverge) but made correct.
  • Operator notes

  • Re-baseline dashboards/alerts on EnforceRetentionQueryTime/EnforceRetentionQueryRate (semantics changed as above).

  • The enforcer now emits an INFO intent+result pair per non-empty cycle; if that volume is a concern on high-delete clusters, the pair can be gated on deletions later.

  • RetentionEnforcementScheduleLagMs returns 0 for both "on schedule" and "empty queue" (no diskless delete-policy partitions yet, or during startup); pair it with queue activity if that distinction matters.

  • Partition/size counts are intentionally absent from the file-cleaner logs: FileToDelete carries only the object key, and batches are already deleted by cleanup time.
  • Testing

  • scheduleLagTracksOverduePartition (empty -> 0, future head -> 0, advance past due -> exact lag).

  • durationCallbackFiresOncePerPartition (3 callbacks for 3 requests, including a non-existent partition).

  • File-cleaner mocked + integration tests.

  • metrics.rst regenerated; checkstyle (main + test) clean.
  • Diff: 485 lines (+363 / -122) across 6 files Reviewer: giuseppelillo Review duration: 1396m
    All Vouch review confidence checks passed
    Residual risk 0.19 = Change Risk (0.47) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.47 · 485 lines diff across 6 files
    0.47
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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
    Diff Size diff_size
    0.370
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #725"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 47.3% (MEDIUM) · Higher = larger blast radius
    47.3%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 18.7% · Safe to merge
    18.7%
    Repository