Phase 10: Server Maintenance#82
Conversation
- MaintenanceResult<R,S> carries operation result, new session, and optional restart error - MaintenanceExecutor.execute() implements Go's stop-embed-op-restart error matrix
…ma backends - Expand ServerSession constructor from 7 to 12 params with 5 maintenance callbacks - Replace UnsupportedOperationException stubs with lock-protected callback delegation - Wire MaintenanceExecutor.execute in both JNA and Panama doStartServer() - Update ServerSessionTest for new constructor signature
…tenance # Conflicts: # .planning/ROADMAP.md # .planning/STATE.md
- 5 data-seeded tests for rebuild, compact, compactAll, pruneWAL, pruneAllWAL - HTTP helpers for collection creation and heartbeat verification - Error path tests: throws-after-close and rejects-null-options (split per operation) - Each test verifies stop-embed-op-restart lifecycle with collection survival
- Mirror of JNA tests with PanamaChromaRuntime substitution - 11 tests: 5 data-seeded ops, 1 throws-after-close, 5 rejects-null-options - Identical test structure ensures backend parity
- SUMMARY.md with 11 tests per backend, self-check passed - STATE.md updated: phase 10 complete, all 11 plans done - ROADMAP.md and REQUIREMENTS.md updated with plan progress
- Fix session invalidation on validation errors (null args no longer kill session) - Wrap closeServerAction in try-catch with ChromaException - Guarantee serverFree runs via try-finally in close lambdas - Enforce MaintenanceResult co-invariant (session/restartError) - Extract executeMaintenanceOp helper, rename backupLock to lifecycleLock - Simplify embedded-start recovery path - Add MaintenanceExecutorTest covering all error matrix branches - Add session invalidation + constructor null tests to ServerSessionTest - Fix integration test session leak with try-with-resources - Add nonexistent collection test to JNA and Panama
|
@claude PTAL |
|
Claude finished @tazarov's task in 2m 6s —— View job PR Review: Phase 10 - Server Maintenance
Overall this is a well-structured implementation. The 8-branch error matrix in
|
Add restartError as suppressed exception in closeError+restartError branch for consistency with opError+restartError branch. Narrow MaintenanceResult.restartError from Exception to RuntimeException to match actual usage.
|
Claude finished @tazarov's task in 59s —— View job PR Review: Phase 10 - Server Maintenance (follow-up)
Two of the four previous findings are resolved in commit Finding 1 — Finding 3 — Finding 2 — Steps 3 and 4 remain in separate // Before (current)
try { result = operation.apply(embedded); } catch (RuntimeException e) { opError = e; }
try { embedded.close(); } catch (RuntimeException e) { closeError = e; }
// After
try (EmbeddedSession emb = embedded) {
result = operation.apply(emb);
} catch (RuntimeException e) {
opError = e;
} catch (Exception e) { // close() threw — record as closeError
closeError = new ChromaException("embedded close failed", e);
}Finding 4 — Duplicate close lambda — style only, no action required (same as before) Overall the implementation is in good shape. Finding 2 is the only remaining correctness issue — it's an edge case but worth a one-time fix given the native handle exposure. |
Summary
Phase 10: Server Maintenance
Goal: Implement stop-embed-op-restart orchestration for all maintenance operations on ServerSession
Status: Verified (9/9 must-haves)
Adds server-side maintenance operations (rebuild, compact, compact-all, WAL prune, WAL prune-all) to the Java bindings. Each operation stops the server, starts a temporary embedded session, runs the maintenance operation, closes embedded, and restarts the server — with comprehensive error handling for all failure combinations.
Changes
Plan 10-01: Core maintenance API
MaintenanceResult<R,S>— generic result container with partial-failure semantics (session may be null if restart failed)MaintenanceExecutor— static orchestrator implementing stop-embed-op-restart with 8-branch error matrixServerSession— 5 new maintenance methods via extractedexecuteMaintenanceOptemplate, lock-protected withlifecycleLockserverFreerunsKey files created:
java/core/src/main/java/tech/amikos/chroma/local/core/MaintenanceResult.javajava/core/src/main/java/tech/amikos/chroma/local/core/MaintenanceExecutor.javaKey files modified:
java/core/src/main/java/tech/amikos/chroma/local/core/ServerSession.javajava/jna/src/main/java/tech/amikos/chroma/local/jna/JnaChromaRuntime.javajava/panama/src/main/java/tech/amikos/chroma/local/panama/PanamaChromaRuntime.javaPlan 10-02: Integration tests
Key files created:
java/jna/src/test/java/tech/amikos/chroma/local/jna/JnaServerMaintenanceTest.javajava/panama/src/test/java/tech/amikos/chroma/local/panama/PanamaServerMaintenanceTest.javaReview fixes
Verification
Test plan
gradle :core:test— unit tests (MaintenanceExecutorTest, ServerSessionTest)make test-java— JNA + Panama integration tests (requires CHROMA_LIB_PATH)make lint— Go + Rust linters pass