Loading src/backend.cpp +35 −26 Original line number Diff line number Diff line Loading @@ -3222,14 +3222,20 @@ void ClusterMediaBackend::vacuum_all_stores() { } replicate_index(); // Orphan cleanup: remove cluster groups not referenced by current data // Orphan cleanup: remove cluster groups not referenced by current data. // SAFETY: Skip orphan cleanup if the local database appears empty — // an empty local DB would cause ALL cluster groups to be treated as // orphans, deleting the entire dataset across all nodes. auto local_media = local_.media_ids(); auto local_stores = local_.store_ids(); if (!local_media.empty() || !local_stores.empty()) { std::unordered_set<uint64_t> known_gids; known_gids.insert(cluster_group_id("index")); known_gids.insert(cluster_group_id("tombstones")); for (const auto& sid : local_.store_ids()) { for (const auto& sid : local_stores) { known_gids.insert(cluster_group_id("store:" + sid)); } for (const auto& mid : local_.media_ids()) { for (const auto& mid : local_media) { known_gids.insert(cluster_group_id("media:" + mid)); } Loading @@ -3251,6 +3257,9 @@ void ClusterMediaBackend::vacuum_all_stores() { } if (orphans > 0) std::cerr << "[VACUUM] removed " << orphans << " orphan groups\n"; } else { std::cerr << "[VACUUM] skipping orphan cleanup: local database is empty\n"; } cguard.unlock(); cluster_.vacuum_all_nodes(); Loading Loading
src/backend.cpp +35 −26 Original line number Diff line number Diff line Loading @@ -3222,14 +3222,20 @@ void ClusterMediaBackend::vacuum_all_stores() { } replicate_index(); // Orphan cleanup: remove cluster groups not referenced by current data // Orphan cleanup: remove cluster groups not referenced by current data. // SAFETY: Skip orphan cleanup if the local database appears empty — // an empty local DB would cause ALL cluster groups to be treated as // orphans, deleting the entire dataset across all nodes. auto local_media = local_.media_ids(); auto local_stores = local_.store_ids(); if (!local_media.empty() || !local_stores.empty()) { std::unordered_set<uint64_t> known_gids; known_gids.insert(cluster_group_id("index")); known_gids.insert(cluster_group_id("tombstones")); for (const auto& sid : local_.store_ids()) { for (const auto& sid : local_stores) { known_gids.insert(cluster_group_id("store:" + sid)); } for (const auto& mid : local_.media_ids()) { for (const auto& mid : local_media) { known_gids.insert(cluster_group_id("media:" + mid)); } Loading @@ -3251,6 +3257,9 @@ void ClusterMediaBackend::vacuum_all_stores() { } if (orphans > 0) std::cerr << "[VACUUM] removed " << orphans << " orphan groups\n"; } else { std::cerr << "[VACUUM] skipping orphan cleanup: local database is empty\n"; } cguard.unlock(); cluster_.vacuum_all_nodes(); Loading