fix: enable WAL mode and add Windows-specific SQLite optimizations#316
fix: enable WAL mode and add Windows-specific SQLite optimizations#316phernandez merged 6 commits intomainfrom
Conversation
- Enable WAL (Write-Ahead Logging) mode for better concurrency - Add Windows-specific database configuration: - Increased timeout to 30 seconds for better reliability - Use NullPool to avoid connection pooling issues on Windows - Set isolation level to autocommit mode - Add SQLite optimizations: - Set busy timeout to 10 seconds to handle locked databases - Configure cache size and temp storage for performance - Ensure normal locking mode on Windows - These changes should resolve the sync issues requiring periodic memory.db deletion Fixes #214 Co-authored-by: Paul Hernandez <phernandez@users.noreply.github.com>
|
Claude finished @phernandez's task —— View job Code Review for PR #316: Enable WAL mode and Windows-specific SQLite optimizationsReview SummaryI've reviewed the changes to Team Checklist Review✅ Code Quality & Standards
|
…e checking Pyright on Windows was inferring connect_args as dict[str, bool] from the initial value, causing type errors when updating with float and None values. Adding an explicit type annotation resolves the issue while maintaining type safety. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Claude finished @phernandez's task —— View job Code Review for PR #316: Enable WAL mode and Windows-specific SQLite optimizationsI've completed a thorough review of this PR against the Basic Memory team checklist. Here are my findings: ✅ Code Quality & StandardsStrengths:
Minor Issues:
|
…e optimizations - Test WAL mode is properly enabled on filesystem databases - Test busy timeout configuration (10 seconds) - Test synchronous mode set to NORMAL for performance - Test cache size configured to 64MB - Test temp_store set to MEMORY - Test Windows-specific locking mode (NORMAL) - Test NullPool usage on Windows vs regular pooling on other platforms - Test Windows-specific timeout configuration path Fixes type annotation issue where Pyright on Windows inferred connect_args as dict[str, bool] instead of dict[str, bool | float | None]. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
|
Claude finished @phernandez's task —— View job Code Review: PR #316 - WAL Mode and Windows SQLite OptimizationsComprehensive review completed against the Basic Memory team checklist. This PR successfully addresses issue #214 by implementing WAL mode and Windows-specific SQLite optimizations. ✅ Code Quality & StandardsExcellent adherence to Basic Memory conventions:
Minor observation:
✅ Testing & DocumentationOutstanding test coverage added:
Test quality highlights:
Minor suggestion:
✅ Basic Memory ArchitecturePerfect alignment with architecture principles:
✅ Security & PerformanceWell-designed optimizations: Security:
Performance optimizations are industry-standard:
Windows-specific improvements address the root cause:
🎯 Detailed FindingsImplementation QualityWhat's excellent:
Code locations reference:
Test Coverage AnalysisThe test suite is comprehensive and properly structured: # Excellent test design patterns observed:
✓ Test WAL mode on FILESYSTEM type (in-memory doesn't support WAL)
✓ Test other PRAGMAs on MEMORY type (faster, sufficient for config tests)
✓ Mock os.name for Windows-specific tests
✓ Verify both Windows and non-Windows pooling behavior
✓ All tests use proper async patternsTest file: 📋 Final Verdict✅ APPROVED - Ready to Merge SummaryThis PR represents high-quality work that:
What Changed Since Previous ReviewsThe author has addressed all critical feedback from previous reviews:
Impact AssessmentBenefits:
Risks: Minimal - WAL mode is well-established, tests verify behavior, changes are isolated to connection configuration RecommendationMerge this PR. All checklist items pass, test coverage is excellent, and the implementation follows best practices. This will significantly improve the Windows user experience and benefit all users through WAL mode's concurrency improvements. |
Extracted _configure_sqlite_connection() function to eliminate duplicate code in _create_engine_and_session() and engine_session_factory(). This DRY refactoring makes the WAL mode and PRAGMA configuration easier to maintain and test. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
|
Claude finished @phernandez's task —— View job Code Review: PR #316 - WAL Mode and Windows SQLite OptimizationsReviewing against the Basic Memory team checklist... Todo:
Latest ChangesSince the last approval, a new commit was added:
This addresses the code duplication concern from previous reviews by extracting the ✅ Code Quality & StandardsAll standards met:
Code quality highlights:
✅ Testing & DocumentationExcellent test coverage:
Test quality:
✅ Basic Memory ArchitecturePerfect alignment:
✅ Security & PerformanceWell-designed optimizations: Security:
Performance (industry-standard SQLite optimizations):
Windows-specific improvements:
🎯 Final Verdict✅ APPROVED - Excellent Work This PR successfully addresses issue #214 and represents high-quality collaborative development: What's excellent:
Impact:
Code locations:
Recommendation: This PR is ready to merge. All checklist items pass, the latest refactoring addresses previous feedback, and the implementation follows all Basic Memory standards. |
WAL mode is not supported by SQLite for in-memory databases. This was causing all tests on Windows to fail with "no such table" errors because the database schema wasn't being created properly. Changes: - Modified _configure_sqlite_connection() to accept enable_wal parameter - Conditionally enable WAL mode only for filesystem databases - Moved WAL mode tests to test-int/ to use real filesystem databases - Updated tests to use engine_factory fixture from integration test setup This fixes the Windows CI failures while maintaining WAL mode for production filesystem databases. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
|
Claude finished @phernandez's task —— View job PR Review: WAL Mode and Windows SQLite Optimizations ✅Comprehensive review completed against the Basic Memory team checklist. ✅ Code Quality & StandardsExcellent adherence to project conventions:
✅ Testing & DocumentationComprehensive test coverage:
Test quality highlights:
✅ Basic Memory ArchitecturePerfect alignment with architecture principles:
✅ Security & PerformanceWell-designed optimizations following SQLite best practices: Security:
Performance (industry-standard SQLite optimizations):
Windows-specific improvements (addresses root cause of issue #214):
🎯 Key Implementation DetailsCommit History AnalysisThis PR shows excellent iterative development:
The latest commit (9743965) is particularly important - it correctly disables WAL mode for in-memory databases: # src/basic_memory/db.py:78-98
def _configure_sqlite_connection(dbapi_conn, enable_wal: bool = True) -> None:
"""Configure SQLite connection with WAL mode and optimizations.
Args:
dbapi_conn: Database API connection object
enable_wal: Whether to enable WAL mode (should be False for in-memory databases)
"""
cursor = dbapi_conn.cursor()
# Enable WAL mode for better concurrency (not supported for in-memory databases)
if enable_wal:
cursor.execute("PRAGMA journal_mode=WAL")
# ... other optimizationsThis is used correctly in both engine factory functions:
Test ArchitectureTests properly use the integration test
📋 Final Verdict✅ APPROVED - Excellent Work, Ready to Merge SummaryThis PR successfully addresses issue #214 and represents high-quality collaborative development with multiple iterative improvements: What's excellent:
Impact:
Code quality:
RecommendationThis PR is ready to merge. All concerns from previous reviews have been addressed, the latest commit fixes the in-memory database issue, and the implementation is production-ready. |
The critical issue was using NullPool for ALL databases on Windows, including in-memory databases. NullPool closes connections immediately after use, which destroys in-memory SQLite databases, causing "no such table" errors in tests. Changes: - Only use NullPool for FILESYSTEM databases on Windows - In-memory databases now use regular connection pooling to maintain state - Added error handling in _configure_sqlite_connection to prevent PRAGMA failures from breaking connections - Added test to verify in-memory databases don't use NullPool This should fix all Windows test failures while maintaining the benefits of NullPool for filesystem databases on Windows. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
|
Claude finished @phernandez's task —— View job PR Review: WAL Mode and Windows SQLite OptimizationsReviewing against the Basic Memory team checklist... Todo:
Latest Changes AnalysisThe most recent commit ( Problem Fixed: NullPool was being used for ALL databases on Windows, including in-memory databases. Since NullPool closes connections immediately after use, this destroyed in-memory SQLite databases, causing "no such table" errors in tests. Solution Implemented:
✅ Code Quality & StandardsExcellent adherence to project conventions:
Code quality highlights:
✅ Testing & DocumentationComprehensive test coverage:
Test quality highlights:
✅ Basic Memory ArchitecturePerfect alignment with architecture principles:
✅ Security & PerformanceWell-designed optimizations following SQLite best practices: Security:
Performance (industry-standard SQLite optimizations):
Windows-specific improvements (addresses root cause of issue #214):
🎯 Key Implementation DetailsCritical Bug Fix in Latest CommitThe latest commit ( Before (buggy): if os.name == "nt": # Windows
# PROBLEM: NullPool used for ALL databases, including in-memory
engine = create_async_engine(
db_url,
connect_args=connect_args,
poolclass=NullPool, # This destroys in-memory databases!
)After (fixed): if os.name == "nt": # Windows
if db_type == DatabaseType.FILESYSTEM:
engine = create_async_engine(
db_url,
connect_args=connect_args,
poolclass=NullPool, # Only for filesystem databases
)
else:
# In-memory databases need connection pooling to maintain state
engine = create_async_engine(db_url, connect_args=connect_args)Commit HistoryThis PR shows excellent iterative development:
📋 Final Verdict✅ APPROVED - Excellent Work, Ready to MergeThis PR successfully addresses issue #214 and represents high-quality collaborative development with multiple iterative improvements. What's excellent:
Impact:
All checklist items pass: Code Quality & Standards
Testing & Documentation
Basic Memory Architecture
Security & Performance
RecommendationThis PR is ready to merge. All concerns from previous reviews have been addressed, the latest commit fixes a critical NullPool bug for in-memory databases, and the implementation is production-ready with comprehensive test coverage. The iterative development process demonstrated here—with 6 commits progressively improving the implementation—shows excellent collaborative problem-solving between human and AI contributors. |
|
fixes #158 |
Fixes #214
Summary
Implements WAL mode and Windows-specific SQLite optimizations to resolve sync issues that required periodic deletion of memory.db on Windows.
Changes
These changes should eliminate the need to manually delete memory.db every 2 weeks.
Generated with Claude Code