Skip to content

fix(metrics): run metadata backfill once - #2094

Open
svarlamov wants to merge 1 commit into
mainfrom
agent/metrics-backfill-once
Open

fix(metrics): run metadata backfill once#2094
svarlamov wants to merge 1 commit into
mainfrom
agent/metrics-backfill-once

Conversation

@svarlamov

@svarlamov svarlamov commented Aug 4, 2026

Copy link
Copy Markdown
Member

Summary

  • persist a completion marker after the legacy metrics metadata backfill reaches the end successfully
  • skip the full-table backfill scan on every later daemon startup
  • preserve bounded batch processing and retry the migration if any batch fails

Why

The backfill query scans the full metrics table when no legacy rows remain. On a 5.1 GB / 1.48M-row database this held the metrics DB mutex for 8-12 seconds on every daemon restart and caused telemetry flush exceeded its scheduling interval warnings. Current metric inserts already populate the migrated metadata columns, so the historical backfill is one-time work.

Validation

  • strict TDD: focused test failed before implementation and passes afterward
  • task test TEST_FILTER=backfill_event_metadata
  • task lint
  • task fmt
  • live 5.1 GB database: first fixed startup completed the final scan and persisted the marker; second startup uploaded metrics in ~3.2s with no scheduling warning
  • full local suite passes aside from existing environment-specific tests that assume droid is absent and a pre-existing wltrace timing failure on latest main

Copy link
Copy Markdown
Member Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant