Skip to content

Fix DuckDB IO errors from concurrent file access#164

Merged
erikdarlingdata merged 1 commit intodevfrom
feature/duckdb-io-safety
Feb 19, 2026
Merged

Fix DuckDB IO errors from concurrent file access#164
erikdarlingdata merged 1 commit intodevfrom
feature/duckdb-io-safety

Conversation

@erikdarlingdata
Copy link
Owner

Summary

  • Fixes "DuckDBOpen failed: Cannot open file" errors introduced by PR DuckDB checkpoint optimization and timing fix #159 (checkpoint) and PR Parquet archive visibility and scheduled compaction #162 (compaction)
  • Timer initialization changed from DateTime.MinValue to DateTime.UtcNow — prevents compaction/archival/retention from all firing on the very first collection cycle
  • Moved CHECKPOINT inline to end of RunDueCollectorsAsync instead of opening a separate DuckDB instance that conflicts via OS file locks
  • Replaced two-step File.Move in CompactAsync with atomic File.Replace (no window where the database file is missing) plus retry logic for locked files

Test plan

  • dotnet build -c Debug — 0 warnings, 0 errors
  • Launched Lite, no DuckDB IO errors in log
  • Run for 2+ hours to verify archival cycle doesn't trigger IO errors
  • Verify compaction still works correctly after 24h uptime (or temporarily lower CompactionInterval for testing)

🤖 Generated with Claude Code

Three fixes for "DuckDBOpen failed: Cannot open file" errors introduced
by PR #159 (checkpoint) and PR #162 (compaction):

1. Timer initialization: DateTime.MinValue → DateTime.UtcNow prevents
   compaction/archival from firing on the very first collection cycle

2. Inline checkpoint: moved CHECKPOINT to end of RunDueCollectorsAsync
   using the existing connection pool instead of opening a separate
   DuckDB instance that conflicts via OS file locks

3. Atomic file swap: replaced two-step File.Move in CompactAsync with
   File.Replace (single OS operation, no window where the database file
   is missing) plus retry logic for locked files and WAL cleanup

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit 03033ae into dev Feb 19, 2026
3 checks passed
@erikdarlingdata erikdarlingdata deleted the feature/duckdb-io-safety branch February 19, 2026 21:54
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