|
| 1 | +rules: |
| 2 | + - metadata: |
| 3 | + kind: prequel |
| 4 | + id: SB8D1skFullMigrat11nErr |
| 5 | + gen: 1 |
| 6 | + cre: |
| 7 | + id: CRE-2025-0141 |
| 8 | + severity: 1 |
| 9 | + title: "Supabase Self-Hosted: Disk Full During Database Migration Operations" |
| 10 | + category: "storage-problem" |
| 11 | + author: Prequel |
| 12 | + description: | |
| 13 | + Detects when Supabase PostgreSQL database operations fail due to insufficient disk space during migrations, |
| 14 | + data imports, or large transactions. This can corrupt the database, leave migrations in inconsistent state, |
| 15 | + and cause complete service failure requiring manual intervention. |
| 16 | + cause: | |
| 17 | + - Insufficient disk space for database operations |
| 18 | + - Large migration files that exceed available storage |
| 19 | + - WAL (Write-Ahead Log) files consuming all available space |
| 20 | + - Temporary tables or indexes requiring more space than available |
| 21 | + - Docker volume size limits reached |
| 22 | + - Database backup/restore operations running out of space |
| 23 | + tags: |
| 24 | + - supabase |
| 25 | + - postgres |
| 26 | + - disk-full |
| 27 | + - storage |
| 28 | + - migration-failure |
| 29 | + - wal |
| 30 | + - self-hosted |
| 31 | + - critical-failure |
| 32 | + - data-loss-risk |
| 33 | + - public |
| 34 | + mitigation: | |
| 35 | + IMMEDIATE: |
| 36 | + - Stop database operations: `docker-compose stop db` |
| 37 | + - Check disk usage: `df -h` and `docker system df` |
| 38 | + - Free up disk space by removing unnecessary files |
| 39 | + - Increase volume size or move to larger storage |
| 40 | + RECOVERY: |
| 41 | + - Restart database service after freeing space |
| 42 | + - Check database integrity: `docker-compose exec db pg_check` |
| 43 | + - Manually complete failed migrations if needed |
| 44 | + - Restore from backup if database is corrupted |
| 45 | + PREVENTION: |
| 46 | + - Monitor disk usage continuously |
| 47 | + - Set up disk space alerts (< 10% free) |
| 48 | + - Use larger Docker volumes for production |
| 49 | + - Implement automated cleanup of old WAL files |
| 50 | + - Test migrations on staging with similar data volumes |
| 51 | + - Configure PostgreSQL to limit WAL retention |
| 52 | + references: |
| 53 | + - https://www.postgresql.org/docs/current/wal-internals.html |
| 54 | + - https://www.postgresql.org/docs/current/disk-usage.html |
| 55 | + applications: |
| 56 | + - name: postgres |
| 57 | + containerName: supabase-db |
| 58 | + version: "15.*" |
| 59 | + impact: | |
| 60 | + - Database corruption and data loss risk |
| 61 | + - Incomplete migrations leaving schema in inconsistent state |
| 62 | + - Complete service outage until disk space resolved |
| 63 | + - Potential need for database restore from backup |
| 64 | + - Development/production environment downtime |
| 65 | + impactScore: 10 |
| 66 | + mitigationScore: 7 |
| 67 | + reports: 8 |
| 68 | + rule: |
| 69 | + set: |
| 70 | + window: 5m |
| 71 | + event: |
| 72 | + source: cre.log.supabase |
| 73 | + match: |
| 74 | + - regex: 'No space left on device|disk full|insufficient disk space' |
| 75 | + - regex: 'could not.*write.*WAL|checkpoint.*failed.*disk full' |
| 76 | + - regex: 'ERROR.*disk full|could not extend file.*No space left' |
| 77 | + - value: "migration" |
| 78 | + |
| 79 | + |
0 commit comments