Tutorial: Building with CleaveDB
HEAL — repair integrity
Over time, high-throughput systems experience orphaned references, corrupted secondary index entries, or dangling graph edges following hard deletes. The HEAL command performs automated consistency audits and cleans up broken pointers across the storage engine.
Repair variants
CleaveDB offers targeted repair scopes depending on the operational requirement:
| Variant | Syntax | Repair Effect |
|---|---|---|
| Bonds only | HEAL BONDS | Removes bonds whose source or target document no longer exists in _bonds |
| Links only | HEAL LINKS | Removes links whose source or target document no longer exists in _links |
| Secondary indexes | HEAL INDEXES | Rebuilds secondary indexes from primary document data |
| Full system repair | HEAL ALL | Heals bonds, links, secondary indexes, and structural inconsistencies |
Cleaning up ghost bonds (HEAL BONDS)
When a document is permanently purged from the recycling bin via INCINERATE, existing bonds pointing to that deleted document become orphaned ghost bonds. HEAL BONDS detects and prunes them automatically:
-- Run after bulk incinerations or migrations
HEAL BONDSThis ensures graph traversals (FOLLOW and MATCH) never traverse into non-existent nodes.
Automating HEAL via cron
In production environments, you can schedule periodic self-healing using the built-in scheduler:
EVERY 1 HOUR DO ( HEAL ALL )The background cron worker sweeps the database and guarantees graph consistency without manual database administrator intervention.
