Skip to content

Commit dc2f073

Browse files
committed
Update huntarr-dev.mdc with comprehensive Synology SQLite optimization documentation - Added GitHub Issue #615 pattern for Synology NAS performance issues - Documented detection methods, optimized settings, and user controls - Added Synology-specific debugging commands and violation scanning - Updated anti-patterns to include Synology optimization bypasses - Comprehensive guide for 70-90% performance improvement on Synology systems
1 parent 9e1c652 commit dc2f073

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

.cursor/rules/huntarr-dev.mdc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ conn = sqlite3.connect('/config/huntarr.db')
154154
- ❌ Hard-coded database paths: `/config/huntarr.db`
155155
- ❌ JSON file operations for persistent data
156156
- ❌ Not testing both Docker and local database operations
157+
- ❌ Bypassing Synology optimizations with direct SQLite configuration
158+
- ❌ Using `PRAGMA synchronous = FULL` outside of `_configure_connection()`
159+
- ❌ Not testing database performance on network file systems
157160

158161
### Frontend Anti-Patterns
159162
- ❌ Absolute URLs: `/api/endpoint`, `window.location.href = '/'`
@@ -204,6 +207,7 @@ conn = sqlite3.connect('/config/huntarr.db')
204207
7. Global state lock usage: `grep -r "stateful_lock" src/ --include="*.py" | grep -v "stateful_instance_locks"`
205208
8. Inconsistent app styling: `grep -r "background.*linear-gradient.*rgba(15, 23, 42" frontend/ --include="*.js"`
206209
9. Logs pagination conflicts: `grep -r "updateLogsPagination\|updatePagination" frontend/ --include="*.html" --include="*.js" | grep -v "LogsModule"`
210+
10. Synology optimization bypasses: `grep -r "sqlite3.connect\|PRAGMA synchronous = FULL" src/ --include="*.py" | grep -v "_configure_connection"`
207211

208212
### Violation Scanning Commands
209213
```bash
@@ -219,6 +223,7 @@ echo "7. Global state lock violations: $(grep -r "stateful_lock" src/ --include=
219223
echo "8. Inconsistent app styling violations: $(grep -r "background.*linear-gradient.*rgba(15, 23, 42" frontend/ --include="*.js" | wc -l)"
220224
echo "9. Logs pagination conflict violations: $(grep -r "updateLogsPagination\|updatePagination" frontend/ --include="*.html" --include="*.js" | grep -v "LogsModule" | wc -l)"
221225
echo "10. Hunt Manager non-Sonarr clickable links: $(grep -r "isClickable.*entry.app_type.*&&.*entry.instance_name" frontend/static/js/hunt_manager.js | grep -v "=== 'sonarr'" | wc -l)"
226+
echo "11. Synology optimization bypass violations: $(grep -r "sqlite3.connect\|PRAGMA synchronous = FULL" src/ --include="*.py" | grep -v "_configure_connection" | wc -l)"
222227
```
223228

224229
## 📊 SPECIFIC BUG PATTERNS TO AVOID
@@ -235,6 +240,18 @@ echo "10. Hunt Manager non-Sonarr clickable links: $(grep -r "isClickable.*entry
235240
- Use DatabaseManager with proper Windows AppData support
236241
- Never hard-code database paths
237242

243+
### GitHub Issue #615 Pattern (Synology NAS Performance Issues)
244+
- Synology NAS systems experience severe SQLite performance issues with default settings
245+
- Root cause: Network file systems (NFS/CIFS) perform poorly with `PRAGMA synchronous = FULL`
246+
- Symptoms: 20-39 second database operations, "database is locked" errors, general slowness
247+
- Solution: Automatic Synology detection with optimized SQLite settings
248+
- Detection methods: `/usr/syno`, `/etc/synoinfo.conf`, `SYNOPKG_PKGNAME` env var, hostname patterns
249+
- Optimized settings: `synchronous=NORMAL`, 40MB cache, 30s timeout, 128MB mmap, less frequent checkpoints
250+
- User control: `HUNTARR_SYNOLOGY_OPTIMIZATIONS=false` to disable optimizations
251+
- Expected improvement: 70-90% performance boost on Synology systems
252+
- Safety: WAL mode, integrity checks, and error handling preserved
253+
- File: `/src/primary/utils/database.py` - `_detect_synology_nas()` and `_configure_connection()` methods
254+
238255
### Frontend Log Regex Issues
239256
- Malformed regex with double backslashes
240257
- Fix: Use clean regex patterns without double backslashes
@@ -319,6 +336,11 @@ sqlite3 ./data/huntarr.db ".tables"
319336

320337
# Test DatabaseManager operations
321338
python3 -c "from src.primary.utils.database import DatabaseManager; db = DatabaseManager(); print('Database path:', db.db_path)"
339+
340+
# Synology-specific debugging
341+
docker exec huntarr python3 -c "from src.primary.utils.database import HuntarrDatabase; db = HuntarrDatabase(); print('Synology detected:', db._detect_synology_nas())"
342+
docker logs huntarr | grep -i "synology\|optimization"
343+
docker exec huntarr sqlite3 /config/huntarr.db "PRAGMA synchronous; PRAGMA cache_size; PRAGMA mmap_size;"
322344
```
323345

324346
### Subpath Deployment Debugging

0 commit comments

Comments
 (0)