Skip to content

Add resilience to DuckDB read lock acquisition#425

Merged
erikdarlingdata merged 1 commit into
devfrom
fix/lock-resilience
Mar 4, 2026
Merged

Add resilience to DuckDB read lock acquisition#425
erikdarlingdata merged 1 commit into
devfrom
fix/lock-resilience

Conversation

@erikdarlingdata
Copy link
Copy Markdown
Owner

Summary

  • Catches LockRecursionException in AcquireReadLock() and returns a no-op disposable instead of throwing
  • If an unhandled exception (like the tray tooltip crash in System tray custom tooltip causes unhandled WPF crash #422) leaks a read lock on the UI thread, the lock is permanently poisoned — every subsequent EnterReadLock() throws because the thread already owns one
  • Since the thread already has read protection, it's safe to proceed without acquiring another lock
  • This makes the lock self-healing: operations recover gracefully rather than failing forever until restart

Files changed

File Change
Lite/Database/DuckDbInitializer.cs Add LockRecursionException catch in AcquireReadLock(), add NoOpDisposable class

Fixes #423

Test plan

  • Lite builds clean (0 warnings, 0 errors)
  • Normal operation: overview tab loads server summaries
  • Resilience: if tray tooltip crash leaks the lock, overview continues working

🤖 Generated with Claude Code

If an unhandled exception leaks a read lock on the UI thread,
subsequent EnterReadLock() calls throw LockRecursionException
permanently. Catch this and return a no-op disposable instead,
since the thread already has read protection in place.

This makes the lock self-healing: even if a crash leaks the lock,
subsequent operations recover gracefully rather than failing forever.

Fixes #423

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@erikdarlingdata erikdarlingdata merged commit 7b22d82 into dev Mar 4, 2026
3 checks passed
@erikdarlingdata erikdarlingdata deleted the fix/lock-resilience branch April 9, 2026 00:34
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