mirror of
https://github.com/meilisearch/MeiliSearch
synced 2025-07-04 20:37:15 +02:00
fix snapshot bugs
This commit is contained in:
parent
d73fbdef2e
commit
e9da191b7d
6 changed files with 36 additions and 21 deletions
|
@ -2,9 +2,10 @@ use std::path::PathBuf;
|
|||
use std::time::Duration;
|
||||
|
||||
use anyhow::bail;
|
||||
use log::{error, info};
|
||||
use tokio::fs;
|
||||
use tokio::task::spawn_blocking;
|
||||
use tokio::time::interval;
|
||||
use tokio::time::sleep;
|
||||
|
||||
use crate::helpers::compression;
|
||||
use super::index_actor::IndexActorHandle;
|
||||
|
@ -38,11 +39,12 @@ impl<B> SnapshotService<B> {
|
|||
}
|
||||
|
||||
pub async fn run(self) {
|
||||
let mut interval = interval(self.snapshot_period);
|
||||
|
||||
loop {
|
||||
interval.tick().await;
|
||||
self.perform_snapshot().await.unwrap();
|
||||
sleep(self.snapshot_period).await;
|
||||
if let Err(e) = self.perform_snapshot().await {
|
||||
error!("{}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,6 +59,11 @@ impl<B> SnapshotService<B> {
|
|||
fs::create_dir_all(&temp_snapshot_path).await?;
|
||||
|
||||
let uuids = self.uuid_resolver_handle.snapshot(temp_snapshot_path.clone()).await?;
|
||||
|
||||
if uuids.is_empty() {
|
||||
return Ok(())
|
||||
}
|
||||
|
||||
for uuid in uuids {
|
||||
self.update_handle.snapshot(uuid, temp_snapshot_path.clone()).await?;
|
||||
}
|
||||
|
@ -69,6 +76,8 @@ impl<B> SnapshotService<B> {
|
|||
|
||||
fs::rename(temp_snapshot_file, &self.snapshot_path).await?;
|
||||
|
||||
info!("Created snapshot in {:?}.", self.snapshot_path);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue