pub async fn cleanup_duplicate_keys(pool: &Pool<MySql>) -> Result<usize>
Expand description
Cleans up duplicate metadata keys in a thread-safe manner.
This function provides a public, mutex-protected interface to clean up duplicate keys in the metadata table. It ensures that only one thread can perform this operation at a time.
§Arguments
pool
- Database connection pool for executing the query
§Returns
Ok(usize)
- Number of duplicate entries that were removedErr(anyhow::Error)
- Failed to clean up duplicate keys
§Concurrency
This function acquires the global metadata mutex to ensure thread safety when cleaning up duplicate keys.
§Use Cases
This function is useful for:
- Periodic maintenance of the metadata table
- Resolving inconsistencies that might have been introduced by bugs
- Cleaning up after schema migrations or application upgrades