6.3 KiB
6.3 KiB
Pithos v3 Design Critique & Architectural Risk Report
Target Document: Pithos - Planning Report v3 (1 October 2026)
Purpose: Technical assessment of architecture, edge cases, and failure modes prior to implementation. Pass this document to your AI editor / lead architect to guide the v4 plan revision.
Executive Summary
While Pithos v3 introduces significant improvements over v2 (such as global job locks, improved snapshot logic, and resumable restores), deep technical evaluation reveals 6 critical architectural risks. Left unaddressed, these issues can lead to unrecoverable server boot loops, extreme disk space exhaustion, registry/world corruption, or I/O timeouts during backup windows.
Key Risk Areas & Detailed Findings
1. The Bootstrap Paradox in Restore Rollbacks
- Issue: Relying on Pithos (a mod running inside the JVM) to perform crash recovery or finish directory rollbacks during server startup creates a circular dependency.
- Mechanism: If power is lost or a process crashes mid-swap while
mods/orconfig/is half-renamed to.pithos-old, the server will attempt to boot with corrupted core files. - Impact: NeoForge or Pithos itself will fail to load. Because the mod never reaches initialization, the pre-world boot logic (Steps 7–8 in v3) never runs, leaving the server permanently broken without automatic recovery.
- Action Required: Decouple swap/rollback recovery from the mod runtime. Move recovery checks to an external wrapper/loop script (
start-loop.sh/start-loop.bat) prior tojava -jarexecution, or ensure atomic directory renames.
2. The 4x Disk Space Multiplier During Restore
- Issue: The cumulative disk footprint during the restore lifecycle peaks significantly higher than estimated by the pre-restore space check.
- Mechanism: During a restore, the disk simultaneously holds:
- Active Live Directory (
1\times) - Uncompressed Staging Directory
.pithos-restore/(1\times) - Renamed Old State Directory
.pithos-old/(1\times) - In-Progress
pre-restore_<date>.tar.gzSafety Archive (0.5\timesto1\times) - Required Safety Buffer (
min_free_space_mb)
- Active Live Directory (
- Impact: A 30 GB modpack requires 100–120 GB of free space. On budget hosts, panel-managed nodes, or VPS setups with strict disk quotas, restores will consistently fail or run out of space mid-operation during the startup safety tar phase.
- Action Required: Stream
.pithos-olddirectly into thepre-restorecompressed archive before applying staged files, or allow admins to make the safety backup optional/configurable.
3. Windows Partial Restore Corruption Trap
- Issue: Skipping
mods/andlibraries/during a Windows restore (due to open JVM file locks) introduces silent world/registry corruption. - Mechanism: Restoring a 2-week-old
world/andconfig/while leaving today's activemods/intact causes severe ID map and registry desynchronization. - Impact: Mismatched Block/Item IDs, corrupted entity payloads, missing mod blocks, or fatal startup crashes.
- Action Required: Do not allow partial restores. Treat locked
mods//libraries/on Windows as a hard block that aborts the restore and prompts the admin to execute an out-of-band swap via a batch script while the JVM is completely stopped.
4. Runtime.halt() Hazards vs. Socket Cleansing
- Issue: Bypassing vanilla shutdown hooks via
Runtime.halt(code)avoids thread deadlocks but introduces severe network and database side effects. - Mechanism:
- Database/IO State: Mods utilizing SQLite, H2, LevelDB, or async I/O workers (e.g., Dynmap, BlueMap, LuckPerms) fail to flush or release database locks.
- Socket Binding: Standard TCP socket cleanup is bypassed, leaving port
25565bound in aTIME_WAITstate for 30–60 seconds.
- Impact: Rapid-restart supervisors (systemd, Pterodactyl, loop scripts) immediately attempt to restart the server, encounter a
java.net.BindException: Address already in useerror, and crash out. - Action Required: Dispatch custom mod teardown events or provide a short grace window before calling
Runtime.halt(). Add a configurable sleep delay in loop scripts prior to re-invoking Java.
5. Double-Read I/O Bottlenecks in SAVE_PAUSE
- Issue: The
StabilityReaderperforming double-read validation (before and after) on every world file during world pause causes extreme I/O contention. - Mechanism: Large modded worlds contain tens of thousands of region files and data structures. Synchronous double-reads over Java NIO during the save-pause window generate heavy disk queues.
- Impact: On HDDs or network storage (NFS/SMB), stability checking pushes backup durations beyond
max_pause_seconds(300s), causing frequent backup aborts and server lag spikes on active servers. - Action Required: Restrict stability double-reads strictly to active region files (
world/region/*.mca,world/entities/*.mca) or files modified within the lastNseconds, rather than reading every static file twice.
6. External Symlink Root Escalation
- Issue: Following top-level symlinks by default creates data leak risks and archive bloat.
- Mechanism: If an admin or mod creates a top-level symlink pointing to an external path (e.g.,
/var/logor/), Pithos will recursively follow and package external file trees into the tar archive. - Impact: Potential leakage of sensitive host system files, massive unexpected archive growth, or infinite recursion loops if a symlink loops back to a parent root.
- Action Required: Require symlink target paths to be explicitly validated against a whitelist in
pithos.toml, or requirefollow_symlinks = trueto explicitly list allowed target directories.
Suggested Topics for Next Planning Iteration (v4)
- Bootstrap Recovery: How should external script wrappers (
start-loop.sh) inspectpithos-restore.jsonbefore Java launches? - Restore Footprint Reduction: How can we restructure the staged-swap-safety sequence to keep space requirements closer to
1.5\timesworld size? - Windows Safety: Standardizing the process for generating an out-of-band
.batscript when open jars prevent inline folder swapping. - Selective Stability Check Policy: Defining exact glob patterns for files requiring double-read stability checks vs. single-read streaming.