Skip to content

Fix repair of corrupt BlobSizes.sql and mount tolerance#2008

Draft
tyrielv wants to merge 1 commit into
tyrielv/remove-extra-coveragefrom
tyrielv/fix-blobsizes-repair
Draft

Fix repair of corrupt BlobSizes.sql and mount tolerance#2008
tyrielv wants to merge 1 commit into
tyrielv/remove-extra-coveragefrom
tyrielv/fix-blobsizes-repair

Conversation

@tyrielv
Copy link
Copy Markdown
Contributor

@tyrielv tyrielv commented Jun 4, 2026

Summary

Fix gvfs repair --confirm failing to delete corrupt BlobSizes.sql on Windows, and add defense-in-depth so mount tolerates corruption.

Stacked on #1997

Root Cause

SqliteDatabase.HasIssue() opened a pooled SQLite connection for the integrity check. On Windows, disposing the connection returned the handle to the pool but kept the file locked. When repair tried to delete the corrupt folder, TryDeleteFolder failed silently (repair still exited 0). The corrupt file remained, causing mount to crash with a broken pipe.

Changes

  1. SqliteDatabase.HasIssue — Use Pooling=False for integrity-check connections so handles are released on dispose.
  2. BlobSizes.Initialize — Catch SQLITE_CORRUPT/SQLITE_NOTADB, call ClearAllPools(), delete corrupt DB + WAL/SHM sidecars, recreate fresh. BlobSizes is a cache, so recreation is safe.
  3. SqliteErrorCodes.cs — New constants for SQLite result codes.
  4. Test — Remove [SkipInCI] from RepairFixesCorruptBlobSizesDatabase, add assertion that repair deletes the blob sizes folder.

The repair job for BlobSizes.sql was unable to delete the corrupt
database file on Windows because SQLite connection pooling kept
the file handle open after the integrity check in HasIssue().

Two fixes:

1. SqliteDatabase.HasIssue: Use Pooling=False for integrity check
   connections so file handles are released immediately on dispose,
   allowing repair to delete the corrupt file.

2. BlobSizes.Initialize: Tolerate corrupt databases by catching
   SQLITE_CORRUPT and SQLITE_NOTADB errors, deleting the corrupt
   file (and WAL/SHM sidecars), and recreating a fresh database.
   This provides defense-in-depth since BlobSizes is a cache.

Also remove SkipInCI from RepairFixesCorruptBlobSizesDatabase and
add an assertion that repair actually cleans up the corrupt folder.

Assisted-by: Claude Opus 4.6
Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
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