mirror of
https://github.com/meilisearch/MeiliSearch
synced 2024-11-04 20:18:55 +01:00
Adjust task details correctly following index swap
This commit is contained in:
parent
4de445d386
commit
493a8cff31
@ -1373,12 +1373,20 @@ mod tests {
|
|||||||
|
|
||||||
for task in to_enqueue {
|
for task in to_enqueue {
|
||||||
let _ = index_scheduler.register(task).unwrap();
|
let _ = index_scheduler.register(task).unwrap();
|
||||||
|
index_scheduler.assert_internally_consistent();
|
||||||
}
|
}
|
||||||
|
|
||||||
handle.wait_till(Breakpoint::AfterProcessing);
|
handle.wait_till(Breakpoint::AfterProcessing);
|
||||||
|
index_scheduler.assert_internally_consistent();
|
||||||
|
|
||||||
handle.wait_till(Breakpoint::AfterProcessing);
|
handle.wait_till(Breakpoint::AfterProcessing);
|
||||||
|
index_scheduler.assert_internally_consistent();
|
||||||
|
|
||||||
handle.wait_till(Breakpoint::AfterProcessing);
|
handle.wait_till(Breakpoint::AfterProcessing);
|
||||||
|
index_scheduler.assert_internally_consistent();
|
||||||
|
|
||||||
handle.wait_till(Breakpoint::AfterProcessing);
|
handle.wait_till(Breakpoint::AfterProcessing);
|
||||||
|
index_scheduler.assert_internally_consistent();
|
||||||
|
|
||||||
snapshot!(snapshot_index_scheduler(&index_scheduler), name: "initial_tasks_processed");
|
snapshot!(snapshot_index_scheduler(&index_scheduler), name: "initial_tasks_processed");
|
||||||
|
|
||||||
@ -1387,14 +1395,19 @@ mod tests {
|
|||||||
swaps: vec![("a".to_owned(), "b".to_owned()), ("c".to_owned(), "d".to_owned())],
|
swaps: vec![("a".to_owned(), "b".to_owned()), ("c".to_owned(), "d".to_owned())],
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
index_scheduler.assert_internally_consistent();
|
||||||
|
|
||||||
handle.wait_till(Breakpoint::AfterProcessing);
|
handle.wait_till(Breakpoint::AfterProcessing);
|
||||||
|
index_scheduler.assert_internally_consistent();
|
||||||
snapshot!(snapshot_index_scheduler(&index_scheduler), name: "first_swap_processed");
|
snapshot!(snapshot_index_scheduler(&index_scheduler), name: "first_swap_processed");
|
||||||
|
|
||||||
index_scheduler
|
index_scheduler
|
||||||
.register(KindWithContent::IndexSwap { swaps: vec![("a".to_owned(), "c".to_owned())] })
|
.register(KindWithContent::IndexSwap { swaps: vec![("a".to_owned(), "c".to_owned())] })
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
index_scheduler.assert_internally_consistent();
|
||||||
|
|
||||||
handle.wait_till(Breakpoint::AfterProcessing);
|
handle.wait_till(Breakpoint::AfterProcessing);
|
||||||
|
index_scheduler.assert_internally_consistent();
|
||||||
snapshot!(snapshot_index_scheduler(&index_scheduler), name: "second_swap_processed");
|
snapshot!(snapshot_index_scheduler(&index_scheduler), name: "second_swap_processed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ source: index-scheduler/src/lib.rs
|
|||||||
1 {uid: 1, status: succeeded, details: { primary_key: Some("id") }, kind: IndexCreation { index_uid: "c", primary_key: Some("id") }}
|
1 {uid: 1, status: succeeded, details: { primary_key: Some("id") }, kind: IndexCreation { index_uid: "c", primary_key: Some("id") }}
|
||||||
2 {uid: 2, status: succeeded, details: { primary_key: Some("id") }, kind: IndexCreation { index_uid: "d", primary_key: Some("id") }}
|
2 {uid: 2, status: succeeded, details: { primary_key: Some("id") }, kind: IndexCreation { index_uid: "d", primary_key: Some("id") }}
|
||||||
3 {uid: 3, status: succeeded, details: { primary_key: Some("id") }, kind: IndexCreation { index_uid: "a", primary_key: Some("id") }}
|
3 {uid: 3, status: succeeded, details: { primary_key: Some("id") }, kind: IndexCreation { index_uid: "a", primary_key: Some("id") }}
|
||||||
4 {uid: 4, status: succeeded, details: { indexes: [("a", "b"), ("c", "d")] }, kind: IndexSwap { swaps: [("c", "b"), ("a", "d")] }}
|
4 {uid: 4, status: succeeded, details: { indexes: [("c", "b"), ("a", "d")] }, kind: IndexSwap { swaps: [("c", "b"), ("a", "d")] }}
|
||||||
5 {uid: 5, status: succeeded, details: { indexes: [("a", "c")] }, kind: IndexSwap { swaps: [("a", "c")] }}
|
5 {uid: 5, status: succeeded, details: { indexes: [("a", "c")] }, kind: IndexSwap { swaps: [("a", "c")] }}
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
### Status:
|
### Status:
|
||||||
|
@ -5,7 +5,7 @@ use std::ops::Bound;
|
|||||||
use meilisearch_types::heed::types::{DecodeIgnore, OwnedType};
|
use meilisearch_types::heed::types::{DecodeIgnore, OwnedType};
|
||||||
use meilisearch_types::heed::{Database, RoTxn, RwTxn};
|
use meilisearch_types::heed::{Database, RoTxn, RwTxn};
|
||||||
use meilisearch_types::milli::{CboRoaringBitmapCodec, BEU32};
|
use meilisearch_types::milli::{CboRoaringBitmapCodec, BEU32};
|
||||||
use meilisearch_types::tasks::{Kind, KindWithContent, Status};
|
use meilisearch_types::tasks::{Details, Kind, KindWithContent, Status};
|
||||||
use roaring::{MultiOps, RoaringBitmap};
|
use roaring::{MultiOps, RoaringBitmap};
|
||||||
use time::OffsetDateTime;
|
use time::OffsetDateTime;
|
||||||
|
|
||||||
@ -270,6 +270,22 @@ pub fn swap_index_uid_in_task(task: &mut Task, swap: (&str, &str)) {
|
|||||||
| K::DumpCreation { .. }
|
| K::DumpCreation { .. }
|
||||||
| K::Snapshot => {}
|
| K::Snapshot => {}
|
||||||
};
|
};
|
||||||
|
match &mut task.details {
|
||||||
|
Some(details) => match details {
|
||||||
|
Details::IndexSwap { swaps } => {
|
||||||
|
for (lhs, rhs) in swaps.iter_mut() {
|
||||||
|
if lhs == swap.0 || lhs == swap.1 {
|
||||||
|
index_uids.push(lhs);
|
||||||
|
}
|
||||||
|
if rhs == swap.0 || rhs == swap.1 {
|
||||||
|
index_uids.push(rhs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
},
|
||||||
|
None => {}
|
||||||
|
}
|
||||||
for index_uid in index_uids {
|
for index_uid in index_uids {
|
||||||
if index_uid == swap.0 {
|
if index_uid == swap.0 {
|
||||||
*index_uid = swap.1.to_owned();
|
*index_uid = swap.1.to_owned();
|
||||||
@ -279,8 +295,6 @@ pub fn swap_index_uid_in_task(task: &mut Task, swap: (&str, &str)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
use meilisearch_types::tasks::Details;
|
|
||||||
#[cfg(test)]
|
|
||||||
impl IndexScheduler {
|
impl IndexScheduler {
|
||||||
/// Asserts that the index scheduler's content is internally consistent.
|
/// Asserts that the index scheduler's content is internally consistent.
|
||||||
pub fn assert_internally_consistent(&self) {
|
pub fn assert_internally_consistent(&self) {
|
||||||
@ -347,9 +361,12 @@ impl IndexScheduler {
|
|||||||
}
|
}
|
||||||
match details {
|
match details {
|
||||||
Some(details) => match details {
|
Some(details) => match details {
|
||||||
Details::IndexSwap { swaps } => {
|
Details::IndexSwap { swaps: sw1 } => match &kind {
|
||||||
todo!()
|
KindWithContent::IndexSwap { swaps: sw2 } => {
|
||||||
}
|
assert_eq!(&sw1, sw2);
|
||||||
|
}
|
||||||
|
_ => panic!(),
|
||||||
|
},
|
||||||
Details::DocumentAdditionOrUpdate { received_documents, indexed_documents } => {
|
Details::DocumentAdditionOrUpdate { received_documents, indexed_documents } => {
|
||||||
assert_eq!(kind.as_kind(), Kind::DocumentAdditionOrUpdate);
|
assert_eq!(kind.as_kind(), Kind::DocumentAdditionOrUpdate);
|
||||||
if let Some(indexed_documents) = indexed_documents {
|
if let Some(indexed_documents) = indexed_documents {
|
||||||
|
Loading…
Reference in New Issue
Block a user