3023: Update error codes related to tasks cancelation + add canceledBy filter r=Kerollmops a=Kerollmops

<details>This PR changes the error codes [to follow the specification](https://github.com/meilisearch/specifications/pull/195).

 - [x] The `missing_filters` error code is renamed `missing_task_filters` to be more accurate and follow the `invalid_task_*` convention.
 - [x] The error code `invalid_task_uids_filter` is added.
 - [x] The error code `invalid_task_canceled_by_filter` is added.
 - [x] The error code `invalid_task_date_filter` is added.
      -  The error message is the same as for expires_at in the API Key  EXCEPT that it does not explicitly mention that a date must be given in the future.
</details>

Edit by `@loiclec` :
I have added a few more changes into this PR. The related issues are:

- Fixes https://github.com/meilisearch/meilisearch/issues/3029
- Implements https://github.com/meilisearch/meilisearch/issues/3026
- Fixes https://github.com/meilisearch/meilisearch/issues/2940
- Fixes https://github.com/meilisearch/meilisearch/issues/2939

Additionally:
- Fixes a bug where global tasks were returned by `GET /tasks` queries even if the user did not have the `index.*` API key action.
- Rename `originalQuery` to `originalFilters`
- Display `error: null` and `canceledBy: null` in the task views
- Allow using the star operator in the task filters in the `DELETE /tasks` and `POST /tasks/cancel` routes
- Make sure that the index scheduler keeps making progress even when a grave error occurs.


Co-authored-by: Kerollmops <clement@meilisearch.com>
Co-authored-by: Clément Renault <clement@meilisearch.com>
Co-authored-by: Loïc Lecrenier <loic.lecrenier@me.com>
This commit is contained in:
bors[bot] 2022-11-10 10:51:41 +00:00 committed by GitHub
commit 379522ace3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
90 changed files with 1129 additions and 362 deletions

View File

@ -535,7 +535,7 @@ impl IndexScheduler {
Some(Details::TaskCancelation { Some(Details::TaskCancelation {
matched_tasks: _, matched_tasks: _,
canceled_tasks, canceled_tasks,
original_query: _, original_filters: _,
}) => { }) => {
*canceled_tasks = Some(canceled_tasks_content_uuids.len() as u64); *canceled_tasks = Some(canceled_tasks_content_uuids.len() as u64);
} }
@ -579,7 +579,7 @@ impl IndexScheduler {
Some(Details::TaskDeletion { Some(Details::TaskDeletion {
matched_tasks: _, matched_tasks: _,
deleted_tasks, deleted_tasks,
original_query: _, original_filters: _,
}) => { }) => {
*deleted_tasks = Some(deleted_tasks_count); *deleted_tasks = Some(deleted_tasks_count);
} }
@ -1187,6 +1187,7 @@ impl IndexScheduler {
let mut affected_indexes = HashSet::new(); let mut affected_indexes = HashSet::new();
let mut affected_statuses = HashSet::new(); let mut affected_statuses = HashSet::new();
let mut affected_kinds = HashSet::new(); let mut affected_kinds = HashSet::new();
let mut affected_canceled_by = RoaringBitmap::new();
for task_id in to_delete_tasks.iter() { for task_id in to_delete_tasks.iter() {
let task = self.get_task(wtxn, task_id)?.ok_or(Error::CorruptedTaskQueue)?; let task = self.get_task(wtxn, task_id)?.ok_or(Error::CorruptedTaskQueue)?;
@ -1205,6 +1206,9 @@ impl IndexScheduler {
if let Some(finished_at) = task.finished_at { if let Some(finished_at) = task.finished_at {
utils::remove_task_datetime(wtxn, self.finished_at, finished_at, task.uid)?; utils::remove_task_datetime(wtxn, self.finished_at, finished_at, task.uid)?;
} }
if let Some(canceled_by) = task.canceled_by {
affected_canceled_by.insert(canceled_by);
}
} }
for index in affected_indexes { for index in affected_indexes {
@ -1222,6 +1226,17 @@ impl IndexScheduler {
for task in to_delete_tasks.iter() { for task in to_delete_tasks.iter() {
self.all_tasks.delete(wtxn, &BEU32::new(task))?; self.all_tasks.delete(wtxn, &BEU32::new(task))?;
} }
for canceled_by in affected_canceled_by {
let canceled_by = BEU32::new(canceled_by);
if let Some(mut tasks) = self.canceled_by.get(wtxn, &canceled_by)? {
tasks -= &to_delete_tasks;
if tasks.is_empty() {
self.canceled_by.delete(wtxn, &canceled_by)?;
} else {
self.canceled_by.put(wtxn, &canceled_by, &tasks)?;
}
}
}
Ok(to_delete_tasks.len()) Ok(to_delete_tasks.len())
} }
@ -1259,6 +1274,7 @@ impl IndexScheduler {
task.finished_at = Some(now); task.finished_at = Some(now);
self.update_task(wtxn, &task)?; self.update_task(wtxn, &task)?;
} }
self.canceled_by.put(wtxn, &BEU32::new(cancel_task_id), &tasks_to_cancel)?;
Ok(content_files_to_delete) Ok(content_files_to_delete)
} }

View File

@ -1,4 +1,5 @@
use meilisearch_types::error::{Code, ErrorCode}; use meilisearch_types::error::{Code, ErrorCode};
use meilisearch_types::tasks::{Kind, Status};
use meilisearch_types::{heed, milli}; use meilisearch_types::{heed, milli};
use thiserror::Error; use thiserror::Error;
@ -27,6 +28,36 @@ pub enum Error {
SwapDuplicateIndexesFound(Vec<String>), SwapDuplicateIndexesFound(Vec<String>),
#[error("Corrupted dump.")] #[error("Corrupted dump.")]
CorruptedDump, CorruptedDump,
#[error(
"Task `{field}` `{date}` is invalid. It should follow the YYYY-MM-DD or RFC 3339 date-time format."
)]
InvalidTaskDate { field: String, date: String },
#[error("Task uid `{task_uid}` is invalid. It should only contain numeric characters.")]
InvalidTaskUids { task_uid: String },
#[error(
"Task status `{status}` is invalid. Available task statuses are {}.",
enum_iterator::all::<Status>()
.map(|s| format!("`{s}`"))
.collect::<Vec<String>>()
.join(", ")
)]
InvalidTaskStatuses { status: String },
#[error(
"Task type `{type_}` is invalid. Available task types are {}",
enum_iterator::all::<Kind>()
.map(|s| format!("`{s}`"))
.collect::<Vec<String>>()
.join(", ")
)]
InvalidTaskTypes { type_: String },
#[error(
"Task canceledBy `{canceled_by}` is invalid. It should only contains numeric characters separated by `,` character."
)]
InvalidTaskCanceledBy { canceled_by: String },
#[error(
"{index_uid} is not a valid index uid. Index uid can be an integer or a string containing only alphanumeric characters, hyphens (-) and underscores (_)."
)]
InvalidIndexUid { index_uid: String },
#[error("Task `{0}` not found.")] #[error("Task `{0}` not found.")]
TaskNotFound(TaskId), TaskNotFound(TaskId),
#[error("Query parameters to filter the tasks to delete are missing. Available query parameters are: `uid`, `indexUid`, `status`, `type`.")] #[error("Query parameters to filter the tasks to delete are missing. Available query parameters are: `uid`, `indexUid`, `status`, `type`.")]
@ -71,6 +102,12 @@ impl ErrorCode for Error {
Error::IndexAlreadyExists(_) => Code::IndexAlreadyExists, Error::IndexAlreadyExists(_) => Code::IndexAlreadyExists,
Error::SwapDuplicateIndexesFound(_) => Code::DuplicateIndexFound, Error::SwapDuplicateIndexesFound(_) => Code::DuplicateIndexFound,
Error::SwapDuplicateIndexFound(_) => Code::DuplicateIndexFound, Error::SwapDuplicateIndexFound(_) => Code::DuplicateIndexFound,
Error::InvalidTaskDate { .. } => Code::InvalidTaskDate,
Error::InvalidTaskUids { .. } => Code::InvalidTaskUids,
Error::InvalidTaskStatuses { .. } => Code::InvalidTaskStatuses,
Error::InvalidTaskTypes { .. } => Code::InvalidTaskTypes,
Error::InvalidTaskCanceledBy { .. } => Code::InvalidTaskCanceledBy,
Error::InvalidIndexUid { .. } => Code::InvalidIndexUid,
Error::TaskNotFound(_) => Code::TaskNotFound, Error::TaskNotFound(_) => Code::TaskNotFound,
Error::TaskDeletionWithEmptyQuery => Code::TaskDeletionWithEmptyQuery, Error::TaskDeletionWithEmptyQuery => Code::TaskDeletionWithEmptyQuery,
Error::TaskCancelationWithEmptyQuery => Code::TaskCancelationWithEmptyQuery, Error::TaskCancelationWithEmptyQuery => Code::TaskCancelationWithEmptyQuery,

View File

@ -20,6 +20,7 @@ pub fn snapshot_index_scheduler(scheduler: &IndexScheduler) -> String {
status, status,
kind, kind,
index_tasks, index_tasks,
canceled_by,
enqueued_at, enqueued_at,
started_at, started_at,
finished_at, finished_at,
@ -64,6 +65,10 @@ pub fn snapshot_index_scheduler(scheduler: &IndexScheduler) -> String {
snap.push_str(&snapshot_index_mapper(&rtxn, index_mapper)); snap.push_str(&snapshot_index_mapper(&rtxn, index_mapper));
snap.push_str("\n----------------------------------------------------------------------\n"); snap.push_str("\n----------------------------------------------------------------------\n");
snap.push_str("### Canceled By:\n");
snap.push_str(&snapshot_canceled_by(&rtxn, *canceled_by));
snap.push_str("\n----------------------------------------------------------------------\n");
snap.push_str("### Enqueued At:\n"); snap.push_str("### Enqueued At:\n");
snap.push_str(&snapshot_date_db(&rtxn, *enqueued_at)); snap.push_str(&snapshot_date_db(&rtxn, *enqueued_at));
snap.push_str("----------------------------------------------------------------------\n"); snap.push_str("----------------------------------------------------------------------\n");
@ -179,16 +184,16 @@ fn snapshot_details(d: &Details) -> String {
Details::TaskCancelation { Details::TaskCancelation {
matched_tasks, matched_tasks,
canceled_tasks, canceled_tasks,
original_query, original_filters,
} => { } => {
format!("{{ matched_tasks: {matched_tasks:?}, canceled_tasks: {canceled_tasks:?}, original_query: {original_query:?} }}") format!("{{ matched_tasks: {matched_tasks:?}, canceled_tasks: {canceled_tasks:?}, original_filters: {original_filters:?} }}")
} }
Details::TaskDeletion { Details::TaskDeletion {
matched_tasks, matched_tasks,
deleted_tasks, deleted_tasks,
original_query, original_filters,
} => { } => {
format!("{{ matched_tasks: {matched_tasks:?}, deleted_tasks: {deleted_tasks:?}, original_query: {original_query:?} }}") format!("{{ matched_tasks: {matched_tasks:?}, deleted_tasks: {deleted_tasks:?}, original_filters: {original_filters:?} }}")
}, },
Details::Dump { dump_uid } => { Details::Dump { dump_uid } => {
format!("{{ dump_uid: {dump_uid:?} }}") format!("{{ dump_uid: {dump_uid:?} }}")
@ -231,7 +236,18 @@ pub fn snapshot_index_tasks(rtxn: &RoTxn, db: Database<Str, RoaringBitmapCodec>)
} }
snap snap
} }
pub fn snapshot_canceled_by(
rtxn: &RoTxn,
db: Database<OwnedType<BEU32>, RoaringBitmapCodec>,
) -> String {
let mut snap = String::new();
let iter = db.iter(rtxn).unwrap();
for next in iter {
let (kind, task_ids) = next.unwrap();
writeln!(snap, "{kind} {}", snapshot_bitmap(&task_ids)).unwrap();
}
snap
}
pub fn snapshot_index_mapper(rtxn: &RoTxn, mapper: &IndexMapper) -> String { pub fn snapshot_index_mapper(rtxn: &RoTxn, mapper: &IndexMapper) -> String {
let names = mapper.indexes(rtxn).unwrap().into_iter().map(|(n, _)| n).collect::<Vec<_>>(); let names = mapper.indexes(rtxn).unwrap().into_iter().map(|(n, _)| n).collect::<Vec<_>>();
format!("{names:?}") format!("{names:?}")

View File

@ -70,7 +70,7 @@ pub struct Query {
/// The minimum [task id](`meilisearch_types::tasks::Task::uid`) to be matched /// The minimum [task id](`meilisearch_types::tasks::Task::uid`) to be matched
pub from: Option<u32>, pub from: Option<u32>,
/// The allowed [statuses](`meilisearch_types::tasks::Task::status`) of the matched tasls /// The allowed [statuses](`meilisearch_types::tasks::Task::status`) of the matched tasls
pub status: Option<Vec<Status>>, pub statuses: Option<Vec<Status>>,
/// The allowed [kinds](meilisearch_types::tasks::Kind) of the matched tasks. /// The allowed [kinds](meilisearch_types::tasks::Kind) of the matched tasks.
/// ///
/// The kind of a task is given by: /// The kind of a task is given by:
@ -80,12 +80,14 @@ pub struct Query {
/// task.kind.as_kind() /// task.kind.as_kind()
/// # } /// # }
/// ``` /// ```
pub kind: Option<Vec<Kind>>, pub types: Option<Vec<Kind>>,
/// The allowed [index ids](meilisearch_types::tasks::Task::index_uid) of the matched tasks /// The allowed [index ids](meilisearch_types::tasks::Task::index_uid) of the matched tasks
pub index_uid: Option<Vec<String>>, pub index_uids: Option<Vec<String>>,
/// The [task ids](`meilisearch_types::tasks::Task::uid`) to be matched /// The [task ids](`meilisearch_types::tasks::Task::uid`) to be matched
pub uid: Option<Vec<TaskId>>, pub uids: Option<Vec<TaskId>>,
/// The [task ids](`meilisearch_types::tasks::Task::uid`) of the [`TaskCancelation`](meilisearch_types::tasks::Task::Kind::TaskCancelation) tasks
/// that canceled the matched tasks.
pub canceled_by: Option<Vec<TaskId>>,
/// Exclusive upper bound of the matched tasks' [`enqueued_at`](meilisearch_types::tasks::Task::enqueued_at) field. /// Exclusive upper bound of the matched tasks' [`enqueued_at`](meilisearch_types::tasks::Task::enqueued_at) field.
pub before_enqueued_at: Option<OffsetDateTime>, pub before_enqueued_at: Option<OffsetDateTime>,
/// Exclusive lower bound of the matched tasks' [`enqueued_at`](meilisearch_types::tasks::Task::enqueued_at) field. /// Exclusive lower bound of the matched tasks' [`enqueued_at`](meilisearch_types::tasks::Task::enqueued_at) field.
@ -109,10 +111,11 @@ impl Query {
Query { Query {
limit: None, limit: None,
from: None, from: None,
status: None, statuses: None,
kind: None, types: None,
index_uid: None, index_uids: None,
uid: None, uids: None,
canceled_by: None,
before_enqueued_at: None, before_enqueued_at: None,
after_enqueued_at: None, after_enqueued_at: None,
before_started_at: None, before_started_at: None,
@ -125,9 +128,9 @@ impl Query {
/// Add an [index id](meilisearch_types::tasks::Task::index_uid) to the list of permitted indexes. /// Add an [index id](meilisearch_types::tasks::Task::index_uid) to the list of permitted indexes.
pub fn with_index(self, index_uid: String) -> Self { pub fn with_index(self, index_uid: String) -> Self {
let mut index_vec = self.index_uid.unwrap_or_default(); let mut index_vec = self.index_uids.unwrap_or_default();
index_vec.push(index_uid); index_vec.push(index_uid);
Self { index_uid: Some(index_vec), ..self } Self { index_uids: Some(index_vec), ..self }
} }
} }
@ -185,6 +188,7 @@ mod db_name {
pub const STATUS: &str = "status"; pub const STATUS: &str = "status";
pub const KIND: &str = "kind"; pub const KIND: &str = "kind";
pub const INDEX_TASKS: &str = "index-tasks"; pub const INDEX_TASKS: &str = "index-tasks";
pub const CANCELED_BY: &str = "canceled_by";
pub const ENQUEUED_AT: &str = "enqueued-at"; pub const ENQUEUED_AT: &str = "enqueued-at";
pub const STARTED_AT: &str = "started-at"; pub const STARTED_AT: &str = "started-at";
pub const FINISHED_AT: &str = "finished-at"; pub const FINISHED_AT: &str = "finished-at";
@ -256,6 +260,9 @@ pub struct IndexScheduler {
/// Store the tasks associated to an index. /// Store the tasks associated to an index.
pub(crate) index_tasks: Database<Str, RoaringBitmapCodec>, pub(crate) index_tasks: Database<Str, RoaringBitmapCodec>,
/// Store the tasks that were canceled by a task uid
pub(crate) canceled_by: Database<OwnedType<BEU32>, RoaringBitmapCodec>,
/// Store the task ids of tasks which were enqueued at a specific date /// Store the task ids of tasks which were enqueued at a specific date
pub(crate) enqueued_at: Database<OwnedType<BEI128>, CboRoaringBitmapCodec>, pub(crate) enqueued_at: Database<OwnedType<BEI128>, CboRoaringBitmapCodec>,
@ -316,6 +323,7 @@ impl IndexScheduler {
status: self.status, status: self.status,
kind: self.kind, kind: self.kind,
index_tasks: self.index_tasks, index_tasks: self.index_tasks,
canceled_by: self.canceled_by,
enqueued_at: self.enqueued_at, enqueued_at: self.enqueued_at,
started_at: self.started_at, started_at: self.started_at,
finished_at: self.finished_at, finished_at: self.finished_at,
@ -349,7 +357,7 @@ impl IndexScheduler {
std::fs::create_dir_all(&options.dumps_path)?; std::fs::create_dir_all(&options.dumps_path)?;
let env = heed::EnvOpenOptions::new() let env = heed::EnvOpenOptions::new()
.max_dbs(9) .max_dbs(10)
.map_size(options.task_db_size) .map_size(options.task_db_size)
.open(options.tasks_path)?; .open(options.tasks_path)?;
let file_store = FileStore::new(&options.update_file_path)?; let file_store = FileStore::new(&options.update_file_path)?;
@ -363,6 +371,7 @@ impl IndexScheduler {
status: env.create_database(Some(db_name::STATUS))?, status: env.create_database(Some(db_name::STATUS))?,
kind: env.create_database(Some(db_name::KIND))?, kind: env.create_database(Some(db_name::KIND))?,
index_tasks: env.create_database(Some(db_name::INDEX_TASKS))?, index_tasks: env.create_database(Some(db_name::INDEX_TASKS))?,
canceled_by: env.create_database(Some(db_name::CANCELED_BY))?,
enqueued_at: env.create_database(Some(db_name::ENQUEUED_AT))?, enqueued_at: env.create_database(Some(db_name::ENQUEUED_AT))?,
started_at: env.create_database(Some(db_name::STARTED_AT))?, started_at: env.create_database(Some(db_name::STARTED_AT))?,
finished_at: env.create_database(Some(db_name::FINISHED_AT))?, finished_at: env.create_database(Some(db_name::FINISHED_AT))?,
@ -403,7 +412,6 @@ impl IndexScheduler {
/// only once per index scheduler. /// only once per index scheduler.
fn run(&self) { fn run(&self) {
let run = self.private_clone(); let run = self.private_clone();
std::thread::spawn(move || loop { std::thread::spawn(move || loop {
run.wake_up.wait(); run.wake_up.wait();
@ -422,6 +430,7 @@ impl IndexScheduler {
) { ) {
std::thread::sleep(Duration::from_secs(1)); std::thread::sleep(Duration::from_secs(1));
} }
run.wake_up.signal();
} }
} }
}); });
@ -458,7 +467,7 @@ impl IndexScheduler {
tasks.remove_range(from.saturating_add(1)..); tasks.remove_range(from.saturating_add(1)..);
} }
if let Some(status) = &query.status { if let Some(status) = &query.statuses {
let mut status_tasks = RoaringBitmap::new(); let mut status_tasks = RoaringBitmap::new();
for status in status { for status in status {
match status { match status {
@ -475,12 +484,22 @@ impl IndexScheduler {
tasks &= status_tasks; tasks &= status_tasks;
} }
if let Some(uids) = &query.uid { if let Some(uids) = &query.uids {
let uids = RoaringBitmap::from_iter(uids); let uids = RoaringBitmap::from_iter(uids);
tasks &= &uids; tasks &= &uids;
} }
if let Some(kind) = &query.kind { if let Some(canceled_by) = &query.canceled_by {
for cancel_task_uid in canceled_by {
if let Some(canceled_by_uid) =
self.canceled_by.get(rtxn, &BEU32::new(*cancel_task_uid))?
{
tasks &= canceled_by_uid;
}
}
}
if let Some(kind) = &query.types {
let mut kind_tasks = RoaringBitmap::new(); let mut kind_tasks = RoaringBitmap::new();
for kind in kind { for kind in kind {
kind_tasks |= self.get_kind(rtxn, *kind)?; kind_tasks |= self.get_kind(rtxn, *kind)?;
@ -488,7 +507,7 @@ impl IndexScheduler {
tasks &= &kind_tasks; tasks &= &kind_tasks;
} }
if let Some(index) = &query.index_uid { if let Some(index) = &query.index_uids {
let mut index_tasks = RoaringBitmap::new(); let mut index_tasks = RoaringBitmap::new();
for index in index { for index in index {
index_tasks |= self.index_tasks(rtxn, index)?; index_tasks |= self.index_tasks(rtxn, index)?;
@ -590,9 +609,9 @@ impl IndexScheduler {
) -> Result<RoaringBitmap> { ) -> Result<RoaringBitmap> {
let mut tasks = self.get_task_ids(rtxn, query)?; let mut tasks = self.get_task_ids(rtxn, query)?;
// If the query contains a list of `index_uid`, then we must exclude all the kind that // If the query contains a list of index uid or there is a finite list of authorized indexes,
// arn't associated to one and only one index. // then we must exclude all the kinds that aren't associated to one and only one index.
if query.index_uid.is_some() { if query.index_uids.is_some() || authorized_indexes.is_some() {
for kind in enum_iterator::all::<Kind>().filter(|kind| !kind.related_to_one_index()) { for kind in enum_iterator::all::<Kind>().filter(|kind| !kind.related_to_one_index()) {
tasks -= self.get_kind(rtxn, kind)?; tasks -= self.get_kind(rtxn, kind)?;
} }
@ -1786,6 +1805,7 @@ mod tests {
.unwrap(); .unwrap();
index_scheduler.assert_internally_consistent(); index_scheduler.assert_internally_consistent();
snapshot!(snapshot_index_scheduler(&index_scheduler), name: "cancel_task_registered");
// Now we check that we can reach the AbortedIndexation error handling // Now we check that we can reach the AbortedIndexation error handling
handle.wait_till(Breakpoint::AbortedIndexation); handle.wait_till(Breakpoint::AbortedIndexation);
index_scheduler.assert_internally_consistent(); index_scheduler.assert_internally_consistent();
@ -2218,18 +2238,18 @@ mod tests {
let rtxn = index_scheduler.env.read_txn().unwrap(); let rtxn = index_scheduler.env.read_txn().unwrap();
let query = Query { status: Some(vec![Status::Processing]), ..Default::default() }; let query = Query { statuses: Some(vec![Status::Processing]), ..Default::default() };
let tasks = let tasks =
index_scheduler.get_task_ids_from_authorized_indexes(&rtxn, &query, &None).unwrap(); index_scheduler.get_task_ids_from_authorized_indexes(&rtxn, &query, &None).unwrap();
snapshot!(snapshot_bitmap(&tasks), @"[0,]"); // only the processing tasks in the first tick snapshot!(snapshot_bitmap(&tasks), @"[0,]"); // only the processing tasks in the first tick
let query = Query { status: Some(vec![Status::Enqueued]), ..Default::default() }; let query = Query { statuses: Some(vec![Status::Enqueued]), ..Default::default() };
let tasks = let tasks =
index_scheduler.get_task_ids_from_authorized_indexes(&rtxn, &query, &None).unwrap(); index_scheduler.get_task_ids_from_authorized_indexes(&rtxn, &query, &None).unwrap();
snapshot!(snapshot_bitmap(&tasks), @"[1,2,]"); // only the enqueued tasks in the first tick snapshot!(snapshot_bitmap(&tasks), @"[1,2,]"); // only the enqueued tasks in the first tick
let query = Query { let query = Query {
status: Some(vec![Status::Enqueued, Status::Processing]), statuses: Some(vec![Status::Enqueued, Status::Processing]),
..Default::default() ..Default::default()
}; };
let tasks = let tasks =
@ -2237,7 +2257,7 @@ mod tests {
snapshot!(snapshot_bitmap(&tasks), @"[0,1,2,]"); // both enqueued and processing tasks in the first tick snapshot!(snapshot_bitmap(&tasks), @"[0,1,2,]"); // both enqueued and processing tasks in the first tick
let query = Query { let query = Query {
status: Some(vec![Status::Enqueued, Status::Processing]), statuses: Some(vec![Status::Enqueued, Status::Processing]),
after_started_at: Some(start_time), after_started_at: Some(start_time),
..Default::default() ..Default::default()
}; };
@ -2248,7 +2268,7 @@ mod tests {
snapshot!(snapshot_bitmap(&tasks), @"[0,]"); snapshot!(snapshot_bitmap(&tasks), @"[0,]");
let query = Query { let query = Query {
status: Some(vec![Status::Enqueued, Status::Processing]), statuses: Some(vec![Status::Enqueued, Status::Processing]),
before_started_at: Some(start_time), before_started_at: Some(start_time),
..Default::default() ..Default::default()
}; };
@ -2259,7 +2279,7 @@ mod tests {
snapshot!(snapshot_bitmap(&tasks), @"[]"); snapshot!(snapshot_bitmap(&tasks), @"[]");
let query = Query { let query = Query {
status: Some(vec![Status::Enqueued, Status::Processing]), statuses: Some(vec![Status::Enqueued, Status::Processing]),
after_started_at: Some(start_time), after_started_at: Some(start_time),
before_started_at: Some(start_time + Duration::minutes(1)), before_started_at: Some(start_time + Duration::minutes(1)),
..Default::default() ..Default::default()
@ -2278,7 +2298,7 @@ mod tests {
let second_start_time = OffsetDateTime::now_utc(); let second_start_time = OffsetDateTime::now_utc();
let query = Query { let query = Query {
status: Some(vec![Status::Succeeded, Status::Processing]), statuses: Some(vec![Status::Succeeded, Status::Processing]),
after_started_at: Some(start_time), after_started_at: Some(start_time),
before_started_at: Some(start_time + Duration::minutes(1)), before_started_at: Some(start_time + Duration::minutes(1)),
..Default::default() ..Default::default()
@ -2291,7 +2311,7 @@ mod tests {
snapshot!(snapshot_bitmap(&tasks), @"[0,1,]"); snapshot!(snapshot_bitmap(&tasks), @"[0,1,]");
let query = Query { let query = Query {
status: Some(vec![Status::Succeeded, Status::Processing]), statuses: Some(vec![Status::Succeeded, Status::Processing]),
before_started_at: Some(start_time), before_started_at: Some(start_time),
..Default::default() ..Default::default()
}; };
@ -2302,7 +2322,7 @@ mod tests {
snapshot!(snapshot_bitmap(&tasks), @"[]"); snapshot!(snapshot_bitmap(&tasks), @"[]");
let query = Query { let query = Query {
status: Some(vec![Status::Enqueued, Status::Succeeded, Status::Processing]), statuses: Some(vec![Status::Enqueued, Status::Succeeded, Status::Processing]),
after_started_at: Some(second_start_time), after_started_at: Some(second_start_time),
before_started_at: Some(second_start_time + Duration::minutes(1)), before_started_at: Some(second_start_time + Duration::minutes(1)),
..Default::default() ..Default::default()
@ -2325,7 +2345,7 @@ mod tests {
snapshot!(snapshot_bitmap(&tasks), @"[2,]"); snapshot!(snapshot_bitmap(&tasks), @"[2,]");
let query = Query { let query = Query {
status: Some(vec![Status::Enqueued, Status::Succeeded, Status::Processing]), statuses: Some(vec![Status::Enqueued, Status::Succeeded, Status::Processing]),
after_started_at: Some(second_start_time), after_started_at: Some(second_start_time),
before_started_at: Some(second_start_time + Duration::minutes(1)), before_started_at: Some(second_start_time + Duration::minutes(1)),
..Default::default() ..Default::default()
@ -2347,7 +2367,7 @@ mod tests {
snapshot!(snapshot_bitmap(&tasks), @"[]"); snapshot!(snapshot_bitmap(&tasks), @"[]");
let query = Query { let query = Query {
status: Some(vec![Status::Failed]), statuses: Some(vec![Status::Failed]),
after_started_at: Some(second_start_time), after_started_at: Some(second_start_time),
before_started_at: Some(second_start_time + Duration::minutes(1)), before_started_at: Some(second_start_time + Duration::minutes(1)),
..Default::default() ..Default::default()
@ -2358,7 +2378,7 @@ mod tests {
snapshot!(snapshot_bitmap(&tasks), @"[2,]"); snapshot!(snapshot_bitmap(&tasks), @"[2,]");
let query = Query { let query = Query {
status: Some(vec![Status::Failed]), statuses: Some(vec![Status::Failed]),
after_started_at: Some(second_start_time), after_started_at: Some(second_start_time),
before_started_at: Some(second_start_time + Duration::minutes(1)), before_started_at: Some(second_start_time + Duration::minutes(1)),
..Default::default() ..Default::default()
@ -2369,8 +2389,8 @@ mod tests {
snapshot!(snapshot_bitmap(&tasks), @"[2,]"); snapshot!(snapshot_bitmap(&tasks), @"[2,]");
let query = Query { let query = Query {
status: Some(vec![Status::Failed]), statuses: Some(vec![Status::Failed]),
uid: Some(vec![1]), uids: Some(vec![1]),
after_started_at: Some(second_start_time), after_started_at: Some(second_start_time),
before_started_at: Some(second_start_time + Duration::minutes(1)), before_started_at: Some(second_start_time + Duration::minutes(1)),
..Default::default() ..Default::default()
@ -2381,8 +2401,8 @@ mod tests {
snapshot!(snapshot_bitmap(&tasks), @"[]"); snapshot!(snapshot_bitmap(&tasks), @"[]");
let query = Query { let query = Query {
status: Some(vec![Status::Failed]), statuses: Some(vec![Status::Failed]),
uid: Some(vec![2]), uids: Some(vec![2]),
after_started_at: Some(second_start_time), after_started_at: Some(second_start_time),
before_started_at: Some(second_start_time + Duration::minutes(1)), before_started_at: Some(second_start_time + Duration::minutes(1)),
..Default::default() ..Default::default()
@ -2417,13 +2437,13 @@ mod tests {
let rtxn = index_scheduler.env.read_txn().unwrap(); let rtxn = index_scheduler.env.read_txn().unwrap();
let query = Query { index_uid: Some(vec!["catto".to_owned()]), ..Default::default() }; let query = Query { index_uids: Some(vec!["catto".to_owned()]), ..Default::default() };
let tasks = let tasks =
index_scheduler.get_task_ids_from_authorized_indexes(&rtxn, &query, &None).unwrap(); index_scheduler.get_task_ids_from_authorized_indexes(&rtxn, &query, &None).unwrap();
// only the first task associated with catto is returned, the indexSwap tasks are excluded! // only the first task associated with catto is returned, the indexSwap tasks are excluded!
snapshot!(snapshot_bitmap(&tasks), @"[0,]"); snapshot!(snapshot_bitmap(&tasks), @"[0,]");
let query = Query { index_uid: Some(vec!["catto".to_owned()]), ..Default::default() }; let query = Query { index_uids: Some(vec!["catto".to_owned()]), ..Default::default() };
let tasks = index_scheduler let tasks = index_scheduler
.get_task_ids_from_authorized_indexes(&rtxn, &query, &Some(vec!["doggo".to_owned()])) .get_task_ids_from_authorized_indexes(&rtxn, &query, &Some(vec!["doggo".to_owned()]))
.unwrap(); .unwrap();
@ -2449,7 +2469,7 @@ mod tests {
.unwrap(); .unwrap();
// we asked for all the tasks, but we are only authorized to retrieve the doggo and catto tasks // we asked for all the tasks, but we are only authorized to retrieve the doggo and catto tasks
// -> all tasks except the swap of catto with whalo are returned // -> all tasks except the swap of catto with whalo are returned
snapshot!(snapshot_bitmap(&tasks), @"[0,1,2,]"); snapshot!(snapshot_bitmap(&tasks), @"[0,1,]");
let query = Query::default(); let query = Query::default();
let tasks = let tasks =
@ -2459,23 +2479,43 @@ mod tests {
} }
#[test] #[test]
fn fail_in_create_batch_for_index_creation() { fn query_tasks_canceled_by() {
let (index_scheduler, handle) = let (index_scheduler, handle) =
IndexScheduler::test(true, vec![(1, FailureLocation::InsideCreateBatch)]); IndexScheduler::test(true, vec![(3, FailureLocation::InsideProcessBatch)]);
let kinds = [index_creation_task("catto", "mouse")]; let kind = index_creation_task("catto", "mouse");
let _ = index_scheduler.register(kind).unwrap();
for kind in kinds { let kind = index_creation_task("doggo", "sheep");
let _ = index_scheduler.register(kind).unwrap();
let kind = KindWithContent::IndexSwap {
swaps: vec![IndexSwap { indexes: ("catto".to_owned(), "doggo".to_owned()) }],
};
let _task = index_scheduler.register(kind).unwrap(); let _task = index_scheduler.register(kind).unwrap();
index_scheduler.assert_internally_consistent();
}
handle.wait_till(Breakpoint::BatchCreated);
// We skipped an iteration of `tick` to reach BatchCreated handle.advance_n_batch(1);
assert_eq!(*index_scheduler.run_loop_iteration.read().unwrap(), 2); let kind = KindWithContent::TaskCancelation {
// Otherwise nothing weird happened query: "test_query".to_string(),
index_scheduler.assert_internally_consistent(); tasks: [0, 1, 2, 3].into_iter().collect(),
snapshot!(snapshot_index_scheduler(&index_scheduler)); };
let task_cancelation = index_scheduler.register(kind).unwrap();
handle.advance_n_batch(1);
snapshot!(snapshot_index_scheduler(&index_scheduler), name: "start");
let rtxn = index_scheduler.read_txn().unwrap();
let query = Query { canceled_by: Some(vec![task_cancelation.uid]), ..Query::default() };
let tasks =
index_scheduler.get_task_ids_from_authorized_indexes(&rtxn, &query, &None).unwrap();
// 0 is not returned because it was not canceled, 3 is not returned because it is the uid of the
// taskCancelation itself
snapshot!(snapshot_bitmap(&tasks), @"[1,2,]");
let query = Query { canceled_by: Some(vec![task_cancelation.uid]), ..Query::default() };
let tasks = index_scheduler
.get_task_ids_from_authorized_indexes(&rtxn, &query, &Some(vec!["doggo".to_string()]))
.unwrap();
// Return only 1 because the user is not authorized to see task 2
snapshot!(snapshot_bitmap(&tasks), @"[1,]");
} }
#[test] #[test]

View File

@ -7,7 +7,7 @@ source: index-scheduler/src/lib.rs
---------------------------------------------------------------------- ----------------------------------------------------------------------
### All Tasks: ### All Tasks:
0 {uid: 0, status: canceled, canceled_by: 1, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "catto", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }} 0 {uid: 0, status: canceled, canceled_by: 1, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "catto", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }}
1 {uid: 1, status: succeeded, details: { matched_tasks: 1, canceled_tasks: Some(1), original_query: "test_query" }, kind: TaskCancelation { query: "test_query", tasks: RoaringBitmap<[0]> }} 1 {uid: 1, status: succeeded, details: { matched_tasks: 1, canceled_tasks: Some(1), original_filters: "test_query" }, kind: TaskCancelation { query: "test_query", tasks: RoaringBitmap<[0]> }}
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Status: ### Status:
enqueued [] enqueued []
@ -23,6 +23,10 @@ catto [0,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
1 [0,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -7,7 +7,7 @@ source: index-scheduler/src/lib.rs
---------------------------------------------------------------------- ----------------------------------------------------------------------
### All Tasks: ### All Tasks:
0 {uid: 0, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "catto", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }} 0 {uid: 0, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "catto", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }}
1 {uid: 1, status: enqueued, details: { matched_tasks: 1, canceled_tasks: None, original_query: "test_query" }, kind: TaskCancelation { query: "test_query", tasks: RoaringBitmap<[0]> }} 1 {uid: 1, status: enqueued, details: { matched_tasks: 1, canceled_tasks: None, original_filters: "test_query" }, kind: TaskCancelation { query: "test_query", tasks: RoaringBitmap<[0]> }}
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Status: ### Status:
enqueued [0,1,] enqueued [0,1,]
@ -21,6 +21,9 @@ catto [0,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -9,7 +9,7 @@ source: index-scheduler/src/lib.rs
0 {uid: 0, status: succeeded, details: { received_documents: 1, indexed_documents: Some(1) }, kind: DocumentAdditionOrUpdate { index_uid: "catto", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }} 0 {uid: 0, status: succeeded, details: { received_documents: 1, indexed_documents: Some(1) }, kind: DocumentAdditionOrUpdate { index_uid: "catto", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }}
1 {uid: 1, status: canceled, canceled_by: 3, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "beavero", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000001, documents_count: 1, allow_index_creation: true }} 1 {uid: 1, status: canceled, canceled_by: 3, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "beavero", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000001, documents_count: 1, allow_index_creation: true }}
2 {uid: 2, status: canceled, canceled_by: 3, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "wolfo", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000002, documents_count: 1, allow_index_creation: true }} 2 {uid: 2, status: canceled, canceled_by: 3, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "wolfo", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000002, documents_count: 1, allow_index_creation: true }}
3 {uid: 3, status: succeeded, details: { matched_tasks: 3, canceled_tasks: Some(2), original_query: "test_query" }, kind: TaskCancelation { query: "test_query", tasks: RoaringBitmap<[0, 1, 2]> }} 3 {uid: 3, status: succeeded, details: { matched_tasks: 3, canceled_tasks: Some(2), original_filters: "test_query" }, kind: TaskCancelation { query: "test_query", tasks: RoaringBitmap<[0, 1, 2]> }}
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Status: ### Status:
enqueued [] enqueued []
@ -27,6 +27,10 @@ wolfo [2,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["beavero", "catto"] ["beavero", "catto"]
----------------------------------------------------------------------
### Canceled By:
3 [1,2,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -24,6 +24,9 @@ wolfo [2,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["catto"] ["catto"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -9,7 +9,7 @@ source: index-scheduler/src/lib.rs
0 {uid: 0, status: succeeded, details: { received_documents: 1, indexed_documents: Some(1) }, kind: DocumentAdditionOrUpdate { index_uid: "catto", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }} 0 {uid: 0, status: succeeded, details: { received_documents: 1, indexed_documents: Some(1) }, kind: DocumentAdditionOrUpdate { index_uid: "catto", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }}
1 {uid: 1, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "beavero", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000001, documents_count: 1, allow_index_creation: true }} 1 {uid: 1, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "beavero", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000001, documents_count: 1, allow_index_creation: true }}
2 {uid: 2, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "wolfo", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000002, documents_count: 1, allow_index_creation: true }} 2 {uid: 2, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "wolfo", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000002, documents_count: 1, allow_index_creation: true }}
3 {uid: 3, status: enqueued, details: { matched_tasks: 3, canceled_tasks: None, original_query: "test_query" }, kind: TaskCancelation { query: "test_query", tasks: RoaringBitmap<[0, 1, 2]> }} 3 {uid: 3, status: enqueued, details: { matched_tasks: 3, canceled_tasks: None, original_filters: "test_query" }, kind: TaskCancelation { query: "test_query", tasks: RoaringBitmap<[0, 1, 2]> }}
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Status: ### Status:
enqueued [1,2,3,] enqueued [1,2,3,]
@ -26,6 +26,9 @@ wolfo [2,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["catto"] ["catto"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -7,7 +7,7 @@ source: index-scheduler/src/lib.rs
---------------------------------------------------------------------- ----------------------------------------------------------------------
### All Tasks: ### All Tasks:
0 {uid: 0, status: canceled, canceled_by: 1, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "catto", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }} 0 {uid: 0, status: canceled, canceled_by: 1, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "catto", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }}
1 {uid: 1, status: succeeded, details: { matched_tasks: 1, canceled_tasks: Some(1), original_query: "test_query" }, kind: TaskCancelation { query: "test_query", tasks: RoaringBitmap<[0]> }} 1 {uid: 1, status: succeeded, details: { matched_tasks: 1, canceled_tasks: Some(1), original_filters: "test_query" }, kind: TaskCancelation { query: "test_query", tasks: RoaringBitmap<[0]> }}
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Status: ### Status:
enqueued [] enqueued []
@ -23,6 +23,10 @@ catto [0,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["catto"] ["catto"]
----------------------------------------------------------------------
### Canceled By:
1 [0,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -6,28 +6,35 @@ source: index-scheduler/src/lib.rs
[0,] [0,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### All Tasks: ### All Tasks:
0 {uid: 0, status: enqueued, details: { primary_key: Some("mouse") }, kind: IndexCreation { index_uid: "catto", primary_key: Some("mouse") }} 0 {uid: 0, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "catto", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }}
1 {uid: 1, status: enqueued, details: { matched_tasks: 1, canceled_tasks: None, original_filters: "test_query" }, kind: TaskCancelation { query: "test_query", tasks: RoaringBitmap<[0]> }}
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Status: ### Status:
enqueued [0,] enqueued [0,1,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Kind: ### Kind:
"indexCreation" [0,] "documentAdditionOrUpdate" [0,]
"taskCancelation" [1,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Tasks: ### Index Tasks:
catto [0,] catto [0,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]
[timestamp] [1,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Started At: ### Started At:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Finished At: ### Finished At:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### File Store: ### File Store:
00000000-0000-0000-0000-000000000000
---------------------------------------------------------------------- ----------------------------------------------------------------------

View File

@ -19,6 +19,9 @@ catto [0,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -7,7 +7,7 @@ source: index-scheduler/src/lib.rs
---------------------------------------------------------------------- ----------------------------------------------------------------------
### All Tasks: ### All Tasks:
0 {uid: 0, status: succeeded, details: { received_documents: 1, indexed_documents: Some(1) }, kind: DocumentAdditionOrUpdate { index_uid: "catto", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }} 0 {uid: 0, status: succeeded, details: { received_documents: 1, indexed_documents: Some(1) }, kind: DocumentAdditionOrUpdate { index_uid: "catto", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }}
1 {uid: 1, status: succeeded, details: { matched_tasks: 1, canceled_tasks: Some(0), original_query: "test_query" }, kind: TaskCancelation { query: "test_query", tasks: RoaringBitmap<[0]> }} 1 {uid: 1, status: succeeded, details: { matched_tasks: 1, canceled_tasks: Some(0), original_filters: "test_query" }, kind: TaskCancelation { query: "test_query", tasks: RoaringBitmap<[0]> }}
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Status: ### Status:
enqueued [] enqueued []
@ -22,6 +22,10 @@ catto [0,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["catto"] ["catto"]
----------------------------------------------------------------------
### Canceled By:
1 []
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -20,6 +20,9 @@ catto [0,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["catto"] ["catto"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -28,6 +28,9 @@ girafos [2,5,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["cattos", "doggos", "girafos"] ["cattos", "doggos", "girafos"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -19,6 +19,9 @@ doggos [0,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -19,6 +19,9 @@ doggos [0,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -20,6 +20,9 @@ doggos [0,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["doggos"] ["doggos"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -23,6 +23,9 @@ doggos [0,1,2,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -24,6 +24,9 @@ doggos [0,1,2,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -21,6 +21,9 @@ doggos [0,1,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -22,6 +22,9 @@ doggos [0,1,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -19,6 +19,9 @@ doggos [0,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -20,6 +20,9 @@ doggos [0,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -20,6 +20,9 @@ catto [0,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -19,6 +19,9 @@ doggos [0,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -20,6 +20,9 @@ doggos [0,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["doggos"] ["doggos"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -23,6 +23,9 @@ index_b [1,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -20,6 +20,9 @@ catto [0,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -24,6 +24,9 @@ doggos [0,2,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["cattos"] ["cattos"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -24,6 +24,9 @@ doggos [0,1,2,3,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["doggos"] ["doggos"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -0,0 +1,53 @@
---
source: index-scheduler/src/lib.rs
---
### Autobatching Enabled = true
### Processing Tasks:
[]
----------------------------------------------------------------------
### All Tasks:
0 {uid: 0, status: succeeded, details: { primary_key: Some("mouse") }, kind: IndexCreation { index_uid: "catto", primary_key: Some("mouse") }}
1 {uid: 1, status: canceled, canceled_by: 3, details: { primary_key: Some("sheep") }, kind: IndexCreation { index_uid: "doggo", primary_key: Some("sheep") }}
2 {uid: 2, status: canceled, canceled_by: 3, details: { swaps: [IndexSwap { indexes: ("catto", "doggo") }] }, kind: IndexSwap { swaps: [IndexSwap { indexes: ("catto", "doggo") }] }}
3 {uid: 3, status: succeeded, details: { matched_tasks: 3, canceled_tasks: Some(0), original_filters: "test_query" }, kind: TaskCancelation { query: "test_query", tasks: RoaringBitmap<[0, 1, 2]> }}
----------------------------------------------------------------------
### Status:
enqueued []
succeeded [0,3,]
canceled [1,2,]
----------------------------------------------------------------------
### Kind:
"indexCreation" [0,1,]
"indexSwap" [2,]
"taskCancelation" [3,]
----------------------------------------------------------------------
### Index Tasks:
catto [0,2,]
doggo [1,2,]
----------------------------------------------------------------------
### Index Mapper:
["catto"]
----------------------------------------------------------------------
### Canceled By:
3 [1,2,]
----------------------------------------------------------------------
### Enqueued At:
[timestamp] [0,]
[timestamp] [1,]
[timestamp] [2,]
[timestamp] [3,]
----------------------------------------------------------------------
### Started At:
[timestamp] [0,]
[timestamp] [3,]
----------------------------------------------------------------------
### Finished At:
[timestamp] [0,]
[timestamp] [1,2,]
[timestamp] [3,]
----------------------------------------------------------------------
### File Store:
----------------------------------------------------------------------

View File

@ -24,6 +24,9 @@ whalo [1,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["catto", "doggo", "whalo"] ["catto", "doggo", "whalo"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -23,6 +23,9 @@ whalo [1,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -25,6 +25,9 @@ whalo [2,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["catto", "doggo"] ["catto", "doggo"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -23,6 +23,9 @@ whalo [2,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -25,6 +25,9 @@ whalo [3,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -24,6 +24,9 @@ doggo [3,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -29,6 +29,9 @@ d [2,4,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["a", "b", "c", "d"] ["a", "b", "c", "d"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -26,6 +26,9 @@ d [3,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["a", "b", "c", "d"] ["a", "b", "c", "d"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -29,6 +29,9 @@ d [2,4,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["a", "b", "c", "d"] ["a", "b", "c", "d"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -30,6 +30,9 @@ d [2,4,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["a", "b", "c", "d"] ["a", "b", "c", "d"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -29,6 +29,9 @@ d [3,4,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["a", "b", "c", "d"] ["a", "b", "c", "d"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -31,6 +31,9 @@ f [4,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["a", "b", "c", "d"] ["a", "b", "c", "d"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -26,6 +26,9 @@ d [3,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["a", "b", "c", "d"] ["a", "b", "c", "d"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -21,6 +21,9 @@ doggo [1,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -22,6 +22,9 @@ doggo [1,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["catto"] ["catto"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -7,8 +7,8 @@ source: index-scheduler/src/lib.rs
---------------------------------------------------------------------- ----------------------------------------------------------------------
### All Tasks: ### All Tasks:
1 {uid: 1, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "doggo", primary_key: Some("bone"), method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000001, documents_count: 1, allow_index_creation: true }} 1 {uid: 1, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "doggo", primary_key: Some("bone"), method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000001, documents_count: 1, allow_index_creation: true }}
2 {uid: 2, status: succeeded, details: { matched_tasks: 1, deleted_tasks: Some(1), original_query: "test_query" }, kind: TaskDeletion { query: "test_query", tasks: RoaringBitmap<[0]> }} 2 {uid: 2, status: succeeded, details: { matched_tasks: 1, deleted_tasks: Some(1), original_filters: "test_query" }, kind: TaskDeletion { query: "test_query", tasks: RoaringBitmap<[0]> }}
3 {uid: 3, status: succeeded, details: { matched_tasks: 1, deleted_tasks: Some(0), original_query: "test_query" }, kind: TaskDeletion { query: "test_query", tasks: RoaringBitmap<[0]> }} 3 {uid: 3, status: succeeded, details: { matched_tasks: 1, deleted_tasks: Some(0), original_filters: "test_query" }, kind: TaskDeletion { query: "test_query", tasks: RoaringBitmap<[0]> }}
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Status: ### Status:
enqueued [1,] enqueued [1,]
@ -23,6 +23,9 @@ doggo [1,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["catto"] ["catto"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [1,] [timestamp] [1,]

View File

@ -21,6 +21,9 @@ doggo [1,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -22,6 +22,9 @@ doggo [1,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["catto"] ["catto"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -7,7 +7,7 @@ source: index-scheduler/src/lib.rs
---------------------------------------------------------------------- ----------------------------------------------------------------------
### All Tasks: ### All Tasks:
1 {uid: 1, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "doggo", primary_key: Some("bone"), method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000001, documents_count: 1, allow_index_creation: true }} 1 {uid: 1, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "doggo", primary_key: Some("bone"), method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000001, documents_count: 1, allow_index_creation: true }}
2 {uid: 2, status: succeeded, details: { matched_tasks: 1, deleted_tasks: Some(1), original_query: "test_query" }, kind: TaskDeletion { query: "test_query", tasks: RoaringBitmap<[0]> }} 2 {uid: 2, status: succeeded, details: { matched_tasks: 1, deleted_tasks: Some(1), original_filters: "test_query" }, kind: TaskDeletion { query: "test_query", tasks: RoaringBitmap<[0]> }}
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Status: ### Status:
enqueued [1,] enqueued [1,]
@ -22,6 +22,9 @@ doggo [1,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["catto"] ["catto"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [1,] [timestamp] [1,]

View File

@ -23,6 +23,9 @@ doggo [2,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -9,7 +9,7 @@ source: index-scheduler/src/lib.rs
0 {uid: 0, status: enqueued, details: { primary_key: Some("mouse") }, kind: IndexCreation { index_uid: "catto", primary_key: Some("mouse") }} 0 {uid: 0, status: enqueued, details: { primary_key: Some("mouse") }, kind: IndexCreation { index_uid: "catto", primary_key: Some("mouse") }}
1 {uid: 1, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "catto", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }} 1 {uid: 1, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "catto", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }}
2 {uid: 2, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "doggo", primary_key: Some("bone"), method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000001, documents_count: 1, allow_index_creation: true }} 2 {uid: 2, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "doggo", primary_key: Some("bone"), method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000001, documents_count: 1, allow_index_creation: true }}
3 {uid: 3, status: succeeded, details: { matched_tasks: 2, deleted_tasks: Some(0), original_query: "test_query" }, kind: TaskDeletion { query: "test_query", tasks: RoaringBitmap<[0, 1]> }} 3 {uid: 3, status: succeeded, details: { matched_tasks: 2, deleted_tasks: Some(0), original_filters: "test_query" }, kind: TaskDeletion { query: "test_query", tasks: RoaringBitmap<[0, 1]> }}
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Status: ### Status:
enqueued [0,1,2,] enqueued [0,1,2,]
@ -26,6 +26,9 @@ doggo [2,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -9,7 +9,7 @@ source: index-scheduler/src/lib.rs
0 {uid: 0, status: enqueued, details: { primary_key: Some("mouse") }, kind: IndexCreation { index_uid: "catto", primary_key: Some("mouse") }} 0 {uid: 0, status: enqueued, details: { primary_key: Some("mouse") }, kind: IndexCreation { index_uid: "catto", primary_key: Some("mouse") }}
1 {uid: 1, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "catto", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }} 1 {uid: 1, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "catto", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }}
2 {uid: 2, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "doggo", primary_key: Some("bone"), method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000001, documents_count: 1, allow_index_creation: true }} 2 {uid: 2, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "doggo", primary_key: Some("bone"), method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000001, documents_count: 1, allow_index_creation: true }}
3 {uid: 3, status: enqueued, details: { matched_tasks: 2, deleted_tasks: None, original_query: "test_query" }, kind: TaskDeletion { query: "test_query", tasks: RoaringBitmap<[0, 1]> }} 3 {uid: 3, status: enqueued, details: { matched_tasks: 2, deleted_tasks: None, original_filters: "test_query" }, kind: TaskDeletion { query: "test_query", tasks: RoaringBitmap<[0, 1]> }}
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Status: ### Status:
enqueued [0,1,2,3,] enqueued [0,1,2,3,]
@ -25,6 +25,9 @@ doggo [2,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -9,7 +9,7 @@ source: index-scheduler/src/lib.rs
0 {uid: 0, status: enqueued, details: { primary_key: Some("mouse") }, kind: IndexCreation { index_uid: "catto", primary_key: Some("mouse") }} 0 {uid: 0, status: enqueued, details: { primary_key: Some("mouse") }, kind: IndexCreation { index_uid: "catto", primary_key: Some("mouse") }}
1 {uid: 1, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "catto", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }} 1 {uid: 1, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "catto", primary_key: None, method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }}
2 {uid: 2, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "doggo", primary_key: Some("bone"), method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000001, documents_count: 1, allow_index_creation: true }} 2 {uid: 2, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "doggo", primary_key: Some("bone"), method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000001, documents_count: 1, allow_index_creation: true }}
3 {uid: 3, status: enqueued, details: { matched_tasks: 2, deleted_tasks: None, original_query: "test_query" }, kind: TaskDeletion { query: "test_query", tasks: RoaringBitmap<[0, 1]> }} 3 {uid: 3, status: enqueued, details: { matched_tasks: 2, deleted_tasks: None, original_filters: "test_query" }, kind: TaskDeletion { query: "test_query", tasks: RoaringBitmap<[0, 1]> }}
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Status: ### Status:
enqueued [0,1,2,3,] enqueued [0,1,2,3,]
@ -25,6 +25,9 @@ doggo [2,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -31,6 +31,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,10,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["doggos"] ["doggos"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -31,6 +31,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,10,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["doggos"] ["doggos"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -31,6 +31,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,10,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["doggos"] ["doggos"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -31,6 +31,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,10,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["doggos"] ["doggos"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -31,6 +31,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,10,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["doggos"] ["doggos"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -28,6 +28,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -29,6 +29,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -28,6 +28,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -29,6 +29,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -29,6 +29,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -28,6 +28,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -29,6 +29,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -30,6 +30,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["doggos"] ["doggos"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -31,6 +31,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,10,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["doggos"] ["doggos"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -31,6 +31,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,10,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["doggos"] ["doggos"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -28,6 +28,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -29,6 +29,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["doggos"] ["doggos"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -28,6 +28,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -29,6 +29,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["doggos"] ["doggos"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -29,6 +29,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["doggos"] ["doggos"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -28,6 +28,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -29,6 +29,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["doggos"] ["doggos"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -28,6 +28,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -29,6 +29,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["doggos"] ["doggos"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -29,6 +29,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["doggos"] ["doggos"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -28,6 +28,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
[] []
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -29,6 +29,9 @@ doggos [0,1,2,3,4,5,6,7,8,9,]
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Index Mapper: ### Index Mapper:
["doggos"] ["doggos"]
----------------------------------------------------------------------
### Canceled By:
---------------------------------------------------------------------- ----------------------------------------------------------------------
### Enqueued At: ### Enqueued At:
[timestamp] [0,] [timestamp] [0,]

View File

@ -451,13 +451,17 @@ impl IndexScheduler {
assert_ne!(status, Status::Succeeded); assert_ne!(status, Status::Succeeded);
} }
} }
Details::TaskCancelation { matched_tasks, canceled_tasks, original_query } => { Details::TaskCancelation {
matched_tasks,
canceled_tasks,
original_filters,
} => {
if let Some(canceled_tasks) = canceled_tasks { if let Some(canceled_tasks) = canceled_tasks {
assert_eq!(status, Status::Succeeded); assert_eq!(status, Status::Succeeded);
assert!(canceled_tasks <= matched_tasks); assert!(canceled_tasks <= matched_tasks);
match &kind { match &kind {
KindWithContent::TaskCancelation { query, tasks } => { KindWithContent::TaskCancelation { query, tasks } => {
assert_eq!(query, &original_query); assert_eq!(query, &original_filters);
assert_eq!(tasks.len(), matched_tasks); assert_eq!(tasks.len(), matched_tasks);
} }
_ => panic!(), _ => panic!(),
@ -466,13 +470,13 @@ impl IndexScheduler {
assert_ne!(status, Status::Succeeded); assert_ne!(status, Status::Succeeded);
} }
} }
Details::TaskDeletion { matched_tasks, deleted_tasks, original_query } => { Details::TaskDeletion { matched_tasks, deleted_tasks, original_filters } => {
if let Some(deleted_tasks) = deleted_tasks { if let Some(deleted_tasks) = deleted_tasks {
assert_eq!(status, Status::Succeeded); assert_eq!(status, Status::Succeeded);
assert!(deleted_tasks <= matched_tasks); assert!(deleted_tasks <= matched_tasks);
match &kind { match &kind {
KindWithContent::TaskDeletion { query, tasks } => { KindWithContent::TaskDeletion { query, tasks } => {
assert_eq!(query, &original_query); assert_eq!(query, &original_filters);
assert_eq!(tasks.len(), matched_tasks); assert_eq!(tasks.len(), matched_tasks);
} }
_ => panic!(), _ => panic!(),

View File

@ -271,7 +271,7 @@ pub fn create_all_stats(
let mut indexes = BTreeMap::new(); let mut indexes = BTreeMap::new();
let mut database_size = 0; let mut database_size = 0;
let processing_task = index_scheduler.get_tasks_from_authorized_indexes( let processing_task = index_scheduler.get_tasks_from_authorized_indexes(
Query { status: Some(vec![Status::Processing]), limit: Some(1), ..Query::default() }, Query { statuses: Some(vec![Status::Processing]), limit: Some(1), ..Query::default() },
search_rules.authorized_indexes(), search_rules.authorized_indexes(),
)?; )?;
let processing_index = processing_task.first().and_then(|task| task.index_uid()); let processing_index = processing_task.first().and_then(|task| task.index_uid());

File diff suppressed because it is too large Load Diff

View File

@ -106,17 +106,17 @@ impl Index<'_> {
} }
pub async fn list_tasks(&self) -> (Value, StatusCode) { pub async fn list_tasks(&self) -> (Value, StatusCode) {
let url = format!("/tasks?indexUid={}", self.uid); let url = format!("/tasks?indexUids={}", self.uid);
self.service.get(url).await self.service.get(url).await
} }
pub async fn filtered_tasks(&self, type_: &[&str], status: &[&str]) -> (Value, StatusCode) { pub async fn filtered_tasks(&self, type_: &[&str], status: &[&str]) -> (Value, StatusCode) {
let mut url = format!("/tasks?indexUid={}", self.uid); let mut url = format!("/tasks?indexUids={}", self.uid);
if !type_.is_empty() { if !type_.is_empty() {
let _ = write!(url, "&type={}", type_.join(",")); let _ = write!(url, "&types={}", type_.join(","));
} }
if !status.is_empty() { if !status.is_empty() {
let _ = write!(url, "&status={}", status.join(",")); let _ = write!(url, "&statuses={}", status.join(","));
} }
self.service.get(url).await self.service.get(url).await
} }

View File

@ -59,7 +59,7 @@ async fn import_dump_v2_movie_raw() {
assert_eq!(code, 200); assert_eq!(code, 200);
assert_eq!( assert_eq!(
tasks, tasks,
json!({ "results": [{"uid": 0, "indexUid": "indexUID", "status": "succeeded", "type": "documentAdditionOrUpdate", "details": { "receivedDocuments": 0, "indexedDocuments": 31944 }, "duration": "PT41.751156S", "enqueuedAt": "2021-09-08T08:30:30.550282Z", "startedAt": "2021-09-08T08:30:30.553012Z", "finishedAt": "2021-09-08T08:31:12.304168Z" }], "limit": 20, "from": 0, "next": null }) json!({ "results": [{"uid": 0, "indexUid": "indexUID", "status": "succeeded", "type": "documentAdditionOrUpdate", "canceledBy": null, "details": { "receivedDocuments": 0, "indexedDocuments": 31944 }, "error": null, "duration": "PT41.751156S", "enqueuedAt": "2021-09-08T08:30:30.550282Z", "startedAt": "2021-09-08T08:30:30.553012Z", "finishedAt": "2021-09-08T08:31:12.304168Z" }], "limit": 20, "from": 0, "next": null })
); );
// finally we're just going to check that we can still get a few documents by id // finally we're just going to check that we can still get a few documents by id
@ -122,7 +122,7 @@ async fn import_dump_v2_movie_with_settings() {
assert_eq!(code, 200); assert_eq!(code, 200);
assert_eq!( assert_eq!(
tasks, tasks,
json!({ "results": [{ "uid": 1, "indexUid": "indexUID", "status": "succeeded", "type": "settingsUpdate", "details": { "displayedAttributes": ["title", "genres", "overview", "poster", "release_date"], "searchableAttributes": ["title", "overview"], "filterableAttributes": ["genres"], "stopWords": ["of", "the"] }, "duration": "PT37.488777S", "enqueuedAt": "2021-09-08T08:24:02.323444Z", "startedAt": "2021-09-08T08:24:02.324145Z", "finishedAt": "2021-09-08T08:24:39.812922Z" }, { "uid": 0, "indexUid": "indexUID", "status": "succeeded", "type": "documentAdditionOrUpdate", "details": { "receivedDocuments": 0, "indexedDocuments": 31944 }, "duration": "PT39.941318S", "enqueuedAt": "2021-09-08T08:21:14.742672Z", "startedAt": "2021-09-08T08:21:14.750166Z", "finishedAt": "2021-09-08T08:21:54.691484Z" }], "limit": 20, "from": 1, "next": null }) json!({ "results": [{ "uid": 1, "indexUid": "indexUID", "status": "succeeded", "type": "settingsUpdate", "canceledBy": null, "details": { "displayedAttributes": ["title", "genres", "overview", "poster", "release_date"], "searchableAttributes": ["title", "overview"], "filterableAttributes": ["genres"], "stopWords": ["of", "the"] }, "error": null, "duration": "PT37.488777S", "enqueuedAt": "2021-09-08T08:24:02.323444Z", "startedAt": "2021-09-08T08:24:02.324145Z", "finishedAt": "2021-09-08T08:24:39.812922Z" }, { "uid": 0, "indexUid": "indexUID", "status": "succeeded", "type": "documentAdditionOrUpdate", "canceledBy": null, "details": { "receivedDocuments": 0, "indexedDocuments": 31944 }, "error": null, "duration": "PT39.941318S", "enqueuedAt": "2021-09-08T08:21:14.742672Z", "startedAt": "2021-09-08T08:21:14.750166Z", "finishedAt": "2021-09-08T08:21:54.691484Z" }], "limit": 20, "from": 1, "next": null })
); );
// finally we're just going to check that we can still get a few documents by id // finally we're just going to check that we can still get a few documents by id
@ -185,7 +185,7 @@ async fn import_dump_v2_rubygems_with_settings() {
assert_eq!(code, 200); assert_eq!(code, 200);
assert_eq!( assert_eq!(
tasks["results"][0], tasks["results"][0],
json!({"uid": 92, "indexUid": "rubygems", "status": "succeeded", "type": "documentAdditionOrUpdate", "details": {"receivedDocuments": 0, "indexedDocuments": 1042}, "duration": "PT14.034672S", "enqueuedAt": "2021-09-08T08:40:31.390775Z", "startedAt": "2021-09-08T08:51:39.060642Z", "finishedAt": "2021-09-08T08:51:53.095314Z"}) json!({"uid": 92, "indexUid": "rubygems", "status": "succeeded", "type": "documentAdditionOrUpdate", "canceledBy": null, "details": {"receivedDocuments": 0, "indexedDocuments": 1042}, "error": null, "duration": "PT14.034672S", "enqueuedAt": "2021-09-08T08:40:31.390775Z", "startedAt": "2021-09-08T08:51:39.060642Z", "finishedAt": "2021-09-08T08:51:53.095314Z"})
); );
// finally we're just going to check that we can still get a few documents by id // finally we're just going to check that we can still get a few documents by id
@ -246,7 +246,7 @@ async fn import_dump_v3_movie_raw() {
assert_eq!(code, 200); assert_eq!(code, 200);
assert_eq!( assert_eq!(
tasks, tasks,
json!({ "results": [{"uid": 0, "indexUid": "indexUID", "status": "succeeded", "type": "documentAdditionOrUpdate", "details": { "receivedDocuments": 0, "indexedDocuments": 31944 }, "duration": "PT41.751156S", "enqueuedAt": "2021-09-08T08:30:30.550282Z", "startedAt": "2021-09-08T08:30:30.553012Z", "finishedAt": "2021-09-08T08:31:12.304168Z" }], "limit": 20, "from": 0, "next": null }) json!({ "results": [{"uid": 0, "indexUid": "indexUID", "status": "succeeded", "type": "documentAdditionOrUpdate", "canceledBy": null, "details": { "receivedDocuments": 0, "indexedDocuments": 31944 }, "error": null, "duration": "PT41.751156S", "enqueuedAt": "2021-09-08T08:30:30.550282Z", "startedAt": "2021-09-08T08:30:30.553012Z", "finishedAt": "2021-09-08T08:31:12.304168Z" }], "limit": 20, "from": 0, "next": null })
); );
// finally we're just going to check that we can still get a few documents by id // finally we're just going to check that we can still get a few documents by id
@ -309,7 +309,7 @@ async fn import_dump_v3_movie_with_settings() {
assert_eq!(code, 200); assert_eq!(code, 200);
assert_eq!( assert_eq!(
tasks, tasks,
json!({ "results": [{ "uid": 1, "indexUid": "indexUID", "status": "succeeded", "type": "settingsUpdate", "details": { "displayedAttributes": ["title", "genres", "overview", "poster", "release_date"], "searchableAttributes": ["title", "overview"], "filterableAttributes": ["genres"], "stopWords": ["of", "the"] }, "duration": "PT37.488777S", "enqueuedAt": "2021-09-08T08:24:02.323444Z", "startedAt": "2021-09-08T08:24:02.324145Z", "finishedAt": "2021-09-08T08:24:39.812922Z" }, { "uid": 0, "indexUid": "indexUID", "status": "succeeded", "type": "documentAdditionOrUpdate", "details": { "receivedDocuments": 0, "indexedDocuments": 31944 }, "duration": "PT39.941318S", "enqueuedAt": "2021-09-08T08:21:14.742672Z", "startedAt": "2021-09-08T08:21:14.750166Z", "finishedAt": "2021-09-08T08:21:54.691484Z" }], "limit": 20, "from": 1, "next": null }) json!({ "results": [{ "uid": 1, "indexUid": "indexUID", "status": "succeeded", "type": "settingsUpdate", "canceledBy": null, "details": { "displayedAttributes": ["title", "genres", "overview", "poster", "release_date"], "searchableAttributes": ["title", "overview"], "filterableAttributes": ["genres"], "stopWords": ["of", "the"] }, "error": null, "duration": "PT37.488777S", "enqueuedAt": "2021-09-08T08:24:02.323444Z", "startedAt": "2021-09-08T08:24:02.324145Z", "finishedAt": "2021-09-08T08:24:39.812922Z" }, { "uid": 0, "indexUid": "indexUID", "status": "succeeded", "type": "documentAdditionOrUpdate", "canceledBy": null, "details": { "receivedDocuments": 0, "indexedDocuments": 31944 }, "error": null, "duration": "PT39.941318S", "enqueuedAt": "2021-09-08T08:21:14.742672Z", "startedAt": "2021-09-08T08:21:14.750166Z", "finishedAt": "2021-09-08T08:21:54.691484Z" }], "limit": 20, "from": 1, "next": null })
); );
// finally we're just going to check that we can["results"] still get a few documents by id // finally we're just going to check that we can["results"] still get a few documents by id
@ -372,7 +372,7 @@ async fn import_dump_v3_rubygems_with_settings() {
assert_eq!(code, 200); assert_eq!(code, 200);
assert_eq!( assert_eq!(
tasks["results"][0], tasks["results"][0],
json!({"uid": 92, "indexUid": "rubygems", "status": "succeeded", "type": "documentAdditionOrUpdate", "details": {"receivedDocuments": 0, "indexedDocuments": 1042}, "duration": "PT14.034672S", "enqueuedAt": "2021-09-08T08:40:31.390775Z", "startedAt": "2021-09-08T08:51:39.060642Z", "finishedAt": "2021-09-08T08:51:53.095314Z"}) json!({"uid": 92, "indexUid": "rubygems", "status": "succeeded", "type": "documentAdditionOrUpdate", "canceledBy": null, "details": {"receivedDocuments": 0, "indexedDocuments": 1042}, "error": null, "duration": "PT14.034672S", "enqueuedAt": "2021-09-08T08:40:31.390775Z", "startedAt": "2021-09-08T08:51:39.060642Z", "finishedAt": "2021-09-08T08:51:53.095314Z"})
); );
// finally we're just going to check that we can still get a few documents by id // finally we're just going to check that we can still get a few documents by id
@ -433,7 +433,7 @@ async fn import_dump_v4_movie_raw() {
assert_eq!(code, 200); assert_eq!(code, 200);
assert_eq!( assert_eq!(
tasks, tasks,
json!({ "results": [{"uid": 0, "indexUid": "indexUID", "status": "succeeded", "type": "documentAdditionOrUpdate", "details": { "receivedDocuments": 0, "indexedDocuments": 31944 }, "duration": "PT41.751156S", "enqueuedAt": "2021-09-08T08:30:30.550282Z", "startedAt": "2021-09-08T08:30:30.553012Z", "finishedAt": "2021-09-08T08:31:12.304168Z" }], "limit" : 20, "from": 0, "next": null }) json!({ "results": [{"uid": 0, "indexUid": "indexUID", "status": "succeeded", "type": "documentAdditionOrUpdate", "canceledBy": null, "details": { "receivedDocuments": 0, "indexedDocuments": 31944 }, "error": null, "duration": "PT41.751156S", "enqueuedAt": "2021-09-08T08:30:30.550282Z", "startedAt": "2021-09-08T08:30:30.553012Z", "finishedAt": "2021-09-08T08:31:12.304168Z" }], "limit" : 20, "from": 0, "next": null })
); );
// finally we're just going to check that we can still get a few documents by id // finally we're just going to check that we can still get a few documents by id
@ -496,7 +496,7 @@ async fn import_dump_v4_movie_with_settings() {
assert_eq!(code, 200); assert_eq!(code, 200);
assert_eq!( assert_eq!(
tasks, tasks,
json!({ "results": [{ "uid": 1, "indexUid": "indexUID", "status": "succeeded", "type": "settingsUpdate", "details": { "displayedAttributes": ["title", "genres", "overview", "poster", "release_date"], "searchableAttributes": ["title", "overview"], "filterableAttributes": ["genres"], "stopWords": ["of", "the"] }, "duration": "PT37.488777S", "enqueuedAt": "2021-09-08T08:24:02.323444Z", "startedAt": "2021-09-08T08:24:02.324145Z", "finishedAt": "2021-09-08T08:24:39.812922Z" }, { "uid": 0, "indexUid": "indexUID", "status": "succeeded", "type": "documentAdditionOrUpdate", "details": { "receivedDocuments": 0, "indexedDocuments": 31944 }, "duration": "PT39.941318S", "enqueuedAt": "2021-09-08T08:21:14.742672Z", "startedAt": "2021-09-08T08:21:14.750166Z", "finishedAt": "2021-09-08T08:21:54.691484Z" }], "limit": 20, "from": 1, "next": null }) json!({ "results": [{ "uid": 1, "indexUid": "indexUID", "status": "succeeded", "type": "settingsUpdate", "canceledBy": null, "details": { "displayedAttributes": ["title", "genres", "overview", "poster", "release_date"], "searchableAttributes": ["title", "overview"], "filterableAttributes": ["genres"], "stopWords": ["of", "the"] }, "error": null, "duration": "PT37.488777S", "enqueuedAt": "2021-09-08T08:24:02.323444Z", "startedAt": "2021-09-08T08:24:02.324145Z", "finishedAt": "2021-09-08T08:24:39.812922Z" }, { "uid": 0, "indexUid": "indexUID", "status": "succeeded", "type": "documentAdditionOrUpdate", "canceledBy": null, "details": { "receivedDocuments": 0, "indexedDocuments": 31944 }, "error": null, "duration": "PT39.941318S", "enqueuedAt": "2021-09-08T08:21:14.742672Z", "startedAt": "2021-09-08T08:21:14.750166Z", "finishedAt": "2021-09-08T08:21:54.691484Z" }], "limit": 20, "from": 1, "next": null })
); );
// finally we're just going to check that we can still get a few documents by id // finally we're just going to check that we can still get a few documents by id
@ -559,7 +559,7 @@ async fn import_dump_v4_rubygems_with_settings() {
assert_eq!(code, 200); assert_eq!(code, 200);
assert_eq!( assert_eq!(
tasks["results"][0], tasks["results"][0],
json!({ "uid": 92, "indexUid": "rubygems", "status": "succeeded", "type": "documentAdditionOrUpdate", "details": {"receivedDocuments": 0, "indexedDocuments": 1042}, "duration": "PT14.034672S", "enqueuedAt": "2021-09-08T08:40:31.390775Z", "startedAt": "2021-09-08T08:51:39.060642Z", "finishedAt": "2021-09-08T08:51:53.095314Z"}) json!({ "uid": 92, "indexUid": "rubygems", "status": "succeeded", "type": "documentAdditionOrUpdate", "canceledBy": null, "details": {"receivedDocuments": 0, "indexedDocuments": 1042}, "error": null, "duration": "PT14.034672S", "enqueuedAt": "2021-09-08T08:40:31.390775Z", "startedAt": "2021-09-08T08:51:39.060642Z", "finishedAt": "2021-09-08T08:51:53.095314Z"})
); );
// finally we're just going to check that we can still get a few documents by id // finally we're just going to check that we can still get a few documents by id

View File

@ -67,37 +67,37 @@ async fn list_tasks_with_star_filters() {
index index
.add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None) .add_documents(serde_json::from_str(include_str!("../assets/test_set.json")).unwrap(), None)
.await; .await;
let (response, code) = index.service.get("/tasks?indexUid=test").await; let (response, code) = index.service.get("/tasks?indexUids=test").await;
assert_eq!(code, 200); assert_eq!(code, 200);
assert_eq!(response["results"].as_array().unwrap().len(), 2); assert_eq!(response["results"].as_array().unwrap().len(), 2);
let (response, code) = index.service.get("/tasks?indexUid=*").await; let (response, code) = index.service.get("/tasks?indexUids=*").await;
assert_eq!(code, 200); assert_eq!(code, 200);
assert_eq!(response["results"].as_array().unwrap().len(), 2); assert_eq!(response["results"].as_array().unwrap().len(), 2);
let (response, code) = index.service.get("/tasks?indexUid=*,pasteque").await; let (response, code) = index.service.get("/tasks?indexUids=*,pasteque").await;
assert_eq!(code, 200); assert_eq!(code, 200);
assert_eq!(response["results"].as_array().unwrap().len(), 2); assert_eq!(response["results"].as_array().unwrap().len(), 2);
let (response, code) = index.service.get("/tasks?type=*").await; let (response, code) = index.service.get("/tasks?types=*").await;
assert_eq!(code, 200); assert_eq!(code, 200);
assert_eq!(response["results"].as_array().unwrap().len(), 2); assert_eq!(response["results"].as_array().unwrap().len(), 2);
let (response, code) = let (response, code) =
index.service.get("/tasks?type=*,documentAdditionOrUpdate&status=*").await; index.service.get("/tasks?types=*,documentAdditionOrUpdate&statuses=*").await;
assert_eq!(code, 200, "{:?}", response); assert_eq!(code, 200, "{:?}", response);
assert_eq!(response["results"].as_array().unwrap().len(), 2); assert_eq!(response["results"].as_array().unwrap().len(), 2);
let (response, code) = index let (response, code) = index
.service .service
.get("/tasks?type=*,documentAdditionOrUpdate&status=*,failed&indexUid=test") .get("/tasks?types=*,documentAdditionOrUpdate&statuses=*,failed&indexUids=test")
.await; .await;
assert_eq!(code, 200, "{:?}", response); assert_eq!(code, 200, "{:?}", response);
assert_eq!(response["results"].as_array().unwrap().len(), 2); assert_eq!(response["results"].as_array().unwrap().len(), 2);
let (response, code) = index let (response, code) = index
.service .service
.get("/tasks?type=*,documentAdditionOrUpdate&status=*,failed&indexUid=test,*") .get("/tasks?types=*,documentAdditionOrUpdate&statuses=*,failed&indexUids=test,*")
.await; .await;
assert_eq!(code, 200, "{:?}", response); assert_eq!(code, 200, "{:?}", response);
assert_eq!(response["results"].as_array().unwrap().len(), 2); assert_eq!(response["results"].as_array().unwrap().len(), 2);
@ -231,10 +231,12 @@ async fn test_summarized_document_addition_or_update() {
"indexUid": "test", "indexUid": "test",
"status": "succeeded", "status": "succeeded",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
"canceledBy": null,
"details": { "details": {
"receivedDocuments": 1, "receivedDocuments": 1,
"indexedDocuments": 1 "indexedDocuments": 1
}, },
"error": null,
"duration": "[duration]", "duration": "[duration]",
"enqueuedAt": "[date]", "enqueuedAt": "[date]",
"startedAt": "[date]", "startedAt": "[date]",
@ -253,10 +255,12 @@ async fn test_summarized_document_addition_or_update() {
"indexUid": "test", "indexUid": "test",
"status": "succeeded", "status": "succeeded",
"type": "documentAdditionOrUpdate", "type": "documentAdditionOrUpdate",
"canceledBy": null,
"details": { "details": {
"receivedDocuments": 1, "receivedDocuments": 1,
"indexedDocuments": 1 "indexedDocuments": 1
}, },
"error": null,
"duration": "[duration]", "duration": "[duration]",
"enqueuedAt": "[date]", "enqueuedAt": "[date]",
"startedAt": "[date]", "startedAt": "[date]",
@ -280,6 +284,7 @@ async fn test_summarized_delete_batch() {
"indexUid": "test", "indexUid": "test",
"status": "failed", "status": "failed",
"type": "documentDeletion", "type": "documentDeletion",
"canceledBy": null,
"details": { "details": {
"matchedDocuments": 3, "matchedDocuments": 3,
"deletedDocuments": null "deletedDocuments": null
@ -309,10 +314,12 @@ async fn test_summarized_delete_batch() {
"indexUid": "test", "indexUid": "test",
"status": "succeeded", "status": "succeeded",
"type": "documentDeletion", "type": "documentDeletion",
"canceledBy": null,
"details": { "details": {
"matchedDocuments": 1, "matchedDocuments": 1,
"deletedDocuments": 0 "deletedDocuments": 0
}, },
"error": null,
"duration": "[duration]", "duration": "[duration]",
"enqueuedAt": "[date]", "enqueuedAt": "[date]",
"startedAt": "[date]", "startedAt": "[date]",
@ -336,6 +343,7 @@ async fn test_summarized_delete_document() {
"indexUid": "test", "indexUid": "test",
"status": "failed", "status": "failed",
"type": "documentDeletion", "type": "documentDeletion",
"canceledBy": null,
"details": { "details": {
"matchedDocuments": 1, "matchedDocuments": 1,
"deletedDocuments": null "deletedDocuments": null
@ -365,10 +373,12 @@ async fn test_summarized_delete_document() {
"indexUid": "test", "indexUid": "test",
"status": "succeeded", "status": "succeeded",
"type": "documentDeletion", "type": "documentDeletion",
"canceledBy": null,
"details": { "details": {
"matchedDocuments": 1, "matchedDocuments": 1,
"deletedDocuments": 0 "deletedDocuments": 0
}, },
"error": null,
"duration": "[duration]", "duration": "[duration]",
"enqueuedAt": "[date]", "enqueuedAt": "[date]",
"startedAt": "[date]", "startedAt": "[date]",
@ -394,6 +404,7 @@ async fn test_summarized_settings_update() {
"indexUid": "test", "indexUid": "test",
"status": "failed", "status": "failed",
"type": "settingsUpdate", "type": "settingsUpdate",
"canceledBy": null,
"details": { "details": {
"rankingRules": [ "rankingRules": [
"custom" "custom"
@ -423,6 +434,7 @@ async fn test_summarized_settings_update() {
"indexUid": "test", "indexUid": "test",
"status": "succeeded", "status": "succeeded",
"type": "settingsUpdate", "type": "settingsUpdate",
"canceledBy": null,
"details": { "details": {
"displayedAttributes": [ "displayedAttributes": [
"doggos", "doggos",
@ -436,6 +448,7 @@ async fn test_summarized_settings_update() {
"iq" "iq"
] ]
}, },
"error": null,
"duration": "[duration]", "duration": "[duration]",
"enqueuedAt": "[date]", "enqueuedAt": "[date]",
"startedAt": "[date]", "startedAt": "[date]",
@ -459,9 +472,11 @@ async fn test_summarized_index_creation() {
"indexUid": "test", "indexUid": "test",
"status": "succeeded", "status": "succeeded",
"type": "indexCreation", "type": "indexCreation",
"canceledBy": null,
"details": { "details": {
"primaryKey": null "primaryKey": null
}, },
"error": null,
"duration": "[duration]", "duration": "[duration]",
"enqueuedAt": "[date]", "enqueuedAt": "[date]",
"startedAt": "[date]", "startedAt": "[date]",
@ -480,6 +495,7 @@ async fn test_summarized_index_creation() {
"indexUid": "test", "indexUid": "test",
"status": "failed", "status": "failed",
"type": "indexCreation", "type": "indexCreation",
"canceledBy": null,
"details": { "details": {
"primaryKey": "doggos" "primaryKey": "doggos"
}, },
@ -512,6 +528,7 @@ async fn test_summarized_index_deletion() {
"indexUid": "test", "indexUid": "test",
"status": "failed", "status": "failed",
"type": "indexDeletion", "type": "indexDeletion",
"canceledBy": null,
"error": { "error": {
"message": "Index `test` not found.", "message": "Index `test` not found.",
"code": "index_not_found", "code": "index_not_found",
@ -538,9 +555,11 @@ async fn test_summarized_index_deletion() {
"indexUid": "test", "indexUid": "test",
"status": "succeeded", "status": "succeeded",
"type": "indexDeletion", "type": "indexDeletion",
"canceledBy": null,
"details": { "details": {
"deletedDocuments": 1 "deletedDocuments": 1
}, },
"error": null,
"duration": "[duration]", "duration": "[duration]",
"enqueuedAt": "[date]", "enqueuedAt": "[date]",
"startedAt": "[date]", "startedAt": "[date]",
@ -560,9 +579,11 @@ async fn test_summarized_index_deletion() {
"indexUid": "test", "indexUid": "test",
"status": "succeeded", "status": "succeeded",
"type": "indexDeletion", "type": "indexDeletion",
"canceledBy": null,
"details": { "details": {
"deletedDocuments": 1 "deletedDocuments": 1
}, },
"error": null,
"duration": "[duration]", "duration": "[duration]",
"enqueuedAt": "[date]", "enqueuedAt": "[date]",
"startedAt": "[date]", "startedAt": "[date]",
@ -587,6 +608,7 @@ async fn test_summarized_index_update() {
"indexUid": "test", "indexUid": "test",
"status": "failed", "status": "failed",
"type": "indexUpdate", "type": "indexUpdate",
"canceledBy": null,
"details": { "details": {
"primaryKey": null "primaryKey": null
}, },
@ -614,6 +636,7 @@ async fn test_summarized_index_update() {
"indexUid": "test", "indexUid": "test",
"status": "failed", "status": "failed",
"type": "indexUpdate", "type": "indexUpdate",
"canceledBy": null,
"details": { "details": {
"primaryKey": "bones" "primaryKey": "bones"
}, },
@ -644,9 +667,11 @@ async fn test_summarized_index_update() {
"indexUid": "test", "indexUid": "test",
"status": "succeeded", "status": "succeeded",
"type": "indexUpdate", "type": "indexUpdate",
"canceledBy": null,
"details": { "details": {
"primaryKey": null "primaryKey": null
}, },
"error": null,
"duration": "[duration]", "duration": "[duration]",
"enqueuedAt": "[date]", "enqueuedAt": "[date]",
"startedAt": "[date]", "startedAt": "[date]",
@ -665,9 +690,11 @@ async fn test_summarized_index_update() {
"indexUid": "test", "indexUid": "test",
"status": "succeeded", "status": "succeeded",
"type": "indexUpdate", "type": "indexUpdate",
"canceledBy": null,
"details": { "details": {
"primaryKey": "bones" "primaryKey": "bones"
}, },
"error": null,
"duration": "[duration]", "duration": "[duration]",
"enqueuedAt": "[date]", "enqueuedAt": "[date]",
"startedAt": "[date]", "startedAt": "[date]",
@ -694,6 +721,7 @@ async fn test_summarized_index_swap() {
"indexUid": null, "indexUid": null,
"status": "failed", "status": "failed",
"type": "indexSwap", "type": "indexSwap",
"canceledBy": null,
"details": { "details": {
"swaps": [ "swaps": [
{ {
@ -734,6 +762,7 @@ async fn test_summarized_index_swap() {
"indexUid": null, "indexUid": null,
"status": "succeeded", "status": "succeeded",
"type": "indexSwap", "type": "indexSwap",
"canceledBy": null,
"details": { "details": {
"swaps": [ "swaps": [
{ {
@ -744,6 +773,7 @@ async fn test_summarized_index_swap() {
} }
] ]
}, },
"error": null,
"duration": "[duration]", "duration": "[duration]",
"enqueuedAt": "[date]", "enqueuedAt": "[date]",
"startedAt": "[date]", "startedAt": "[date]",
@ -759,7 +789,7 @@ async fn test_summarized_task_cancelation() {
// to avoid being flaky we're only going to cancel an already finished task :( // to avoid being flaky we're only going to cancel an already finished task :(
index.create(None).await; index.create(None).await;
index.wait_task(0).await; index.wait_task(0).await;
server.cancel_task(json!({ "uid": [0] })).await; server.cancel_task(json!({ "uids": [0] })).await;
index.wait_task(1).await; index.wait_task(1).await;
let (task, _) = index.get_task(1).await; let (task, _) = index.get_task(1).await;
assert_json_snapshot!(task, assert_json_snapshot!(task,
@ -770,11 +800,13 @@ async fn test_summarized_task_cancelation() {
"indexUid": null, "indexUid": null,
"status": "succeeded", "status": "succeeded",
"type": "taskCancelation", "type": "taskCancelation",
"canceledBy": null,
"details": { "details": {
"matchedTasks": 1, "matchedTasks": 1,
"canceledTasks": 0, "canceledTasks": 0,
"originalQuery": "uid=0" "originalFilters": "uids=0"
}, },
"error": null,
"duration": "[duration]", "duration": "[duration]",
"enqueuedAt": "[date]", "enqueuedAt": "[date]",
"startedAt": "[date]", "startedAt": "[date]",
@ -790,7 +822,7 @@ async fn test_summarized_task_deletion() {
// to avoid being flaky we're only going to delete an already finished task :( // to avoid being flaky we're only going to delete an already finished task :(
index.create(None).await; index.create(None).await;
index.wait_task(0).await; index.wait_task(0).await;
server.delete_task(json!({ "uid": [0] })).await; server.delete_task(json!({ "uids": [0] })).await;
index.wait_task(1).await; index.wait_task(1).await;
let (task, _) = index.get_task(1).await; let (task, _) = index.get_task(1).await;
assert_json_snapshot!(task, assert_json_snapshot!(task,
@ -801,11 +833,13 @@ async fn test_summarized_task_deletion() {
"indexUid": null, "indexUid": null,
"status": "succeeded", "status": "succeeded",
"type": "taskDeletion", "type": "taskDeletion",
"canceledBy": null,
"details": { "details": {
"matchedTasks": 1, "matchedTasks": 1,
"deletedTasks": 1, "deletedTasks": 1,
"originalQuery": "uid=0" "originalFilters": "uids=0"
}, },
"error": null,
"duration": "[duration]", "duration": "[duration]",
"enqueuedAt": "[date]", "enqueuedAt": "[date]",
"startedAt": "[date]", "startedAt": "[date]",
@ -828,6 +862,8 @@ async fn test_summarized_dump_creation() {
"indexUid": null, "indexUid": null,
"status": "succeeded", "status": "succeeded",
"type": "dumpCreation", "type": "dumpCreation",
"canceledBy": null,
"error": null,
"duration": "[duration]", "duration": "[duration]",
"enqueuedAt": "[date]", "enqueuedAt": "[date]",
"startedAt": "[date]", "startedAt": "[date]",

View File

@ -147,6 +147,11 @@ pub enum Code {
MissingMasterKey, MissingMasterKey,
NoSpaceLeftOnDevice, NoSpaceLeftOnDevice,
DumpNotFound, DumpNotFound,
InvalidTaskDate,
InvalidTaskStatuses,
InvalidTaskTypes,
InvalidTaskCanceledBy,
InvalidTaskUids,
TaskNotFound, TaskNotFound,
TaskDeletionWithEmptyQuery, TaskDeletionWithEmptyQuery,
TaskCancelationWithEmptyQuery, TaskCancelationWithEmptyQuery,
@ -238,12 +243,27 @@ impl Code {
MissingMasterKey => { MissingMasterKey => {
ErrCode::authentication("missing_master_key", StatusCode::UNAUTHORIZED) ErrCode::authentication("missing_master_key", StatusCode::UNAUTHORIZED)
} }
InvalidTaskDate => {
ErrCode::invalid("invalid_task_date_filter", StatusCode::BAD_REQUEST)
}
InvalidTaskUids => {
ErrCode::invalid("invalid_task_uids_filter", StatusCode::BAD_REQUEST)
}
InvalidTaskStatuses => {
ErrCode::invalid("invalid_task_statuses_filter", StatusCode::BAD_REQUEST)
}
InvalidTaskTypes => {
ErrCode::invalid("invalid_task_types_filter", StatusCode::BAD_REQUEST)
}
InvalidTaskCanceledBy => {
ErrCode::invalid("invalid_task_canceled_by_filter", StatusCode::BAD_REQUEST)
}
TaskNotFound => ErrCode::invalid("task_not_found", StatusCode::NOT_FOUND), TaskNotFound => ErrCode::invalid("task_not_found", StatusCode::NOT_FOUND),
TaskDeletionWithEmptyQuery => { TaskDeletionWithEmptyQuery => {
ErrCode::invalid("missing_filters", StatusCode::BAD_REQUEST) ErrCode::invalid("missing_task_filters", StatusCode::BAD_REQUEST)
} }
TaskCancelationWithEmptyQuery => { TaskCancelationWithEmptyQuery => {
ErrCode::invalid("missing_filters", StatusCode::BAD_REQUEST) ErrCode::invalid("missing_task_filters", StatusCode::BAD_REQUEST)
} }
DumpNotFound => ErrCode::invalid("dump_not_found", StatusCode::NOT_FOUND), DumpNotFound => ErrCode::invalid("dump_not_found", StatusCode::NOT_FOUND),
NoSpaceLeftOnDevice => { NoSpaceLeftOnDevice => {

View File

@ -217,12 +217,12 @@ impl KindWithContent {
KindWithContent::TaskCancelation { query, tasks } => Some(Details::TaskCancelation { KindWithContent::TaskCancelation { query, tasks } => Some(Details::TaskCancelation {
matched_tasks: tasks.len(), matched_tasks: tasks.len(),
canceled_tasks: None, canceled_tasks: None,
original_query: query.clone(), original_filters: query.clone(),
}), }),
KindWithContent::TaskDeletion { query, tasks } => Some(Details::TaskDeletion { KindWithContent::TaskDeletion { query, tasks } => Some(Details::TaskDeletion {
matched_tasks: tasks.len(), matched_tasks: tasks.len(),
deleted_tasks: None, deleted_tasks: None,
original_query: query.clone(), original_filters: query.clone(),
}), }),
KindWithContent::DumpCreation { .. } => None, KindWithContent::DumpCreation { .. } => None,
KindWithContent::SnapshotCreation => None, KindWithContent::SnapshotCreation => None,
@ -260,12 +260,12 @@ impl KindWithContent {
KindWithContent::TaskCancelation { query, tasks } => Some(Details::TaskCancelation { KindWithContent::TaskCancelation { query, tasks } => Some(Details::TaskCancelation {
matched_tasks: tasks.len(), matched_tasks: tasks.len(),
canceled_tasks: Some(0), canceled_tasks: Some(0),
original_query: query.clone(), original_filters: query.clone(),
}), }),
KindWithContent::TaskDeletion { query, tasks } => Some(Details::TaskDeletion { KindWithContent::TaskDeletion { query, tasks } => Some(Details::TaskDeletion {
matched_tasks: tasks.len(), matched_tasks: tasks.len(),
deleted_tasks: Some(0), deleted_tasks: Some(0),
original_query: query.clone(), original_filters: query.clone(),
}), }),
KindWithContent::DumpCreation { .. } => None, KindWithContent::DumpCreation { .. } => None,
KindWithContent::SnapshotCreation => None, KindWithContent::SnapshotCreation => None,
@ -298,12 +298,12 @@ impl From<&KindWithContent> for Option<Details> {
KindWithContent::TaskCancelation { query, tasks } => Some(Details::TaskCancelation { KindWithContent::TaskCancelation { query, tasks } => Some(Details::TaskCancelation {
matched_tasks: tasks.len(), matched_tasks: tasks.len(),
canceled_tasks: None, canceled_tasks: None,
original_query: query.clone(), original_filters: query.clone(),
}), }),
KindWithContent::TaskDeletion { query, tasks } => Some(Details::TaskDeletion { KindWithContent::TaskDeletion { query, tasks } => Some(Details::TaskDeletion {
matched_tasks: tasks.len(), matched_tasks: tasks.len(),
deleted_tasks: None, deleted_tasks: None,
original_query: query.clone(), original_filters: query.clone(),
}), }),
KindWithContent::DumpCreation { dump_uid, .. } => { KindWithContent::DumpCreation { dump_uid, .. } => {
Some(Details::Dump { dump_uid: dump_uid.clone() }) Some(Details::Dump { dump_uid: dump_uid.clone() })
@ -398,7 +398,23 @@ impl Kind {
} }
} }
} }
impl Display for Kind {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Kind::DocumentAdditionOrUpdate => write!(f, "documentAdditionOrUpdate"),
Kind::DocumentDeletion => write!(f, "documentDeletion"),
Kind::SettingsUpdate => write!(f, "settingsUpdate"),
Kind::IndexCreation => write!(f, "indexCreation"),
Kind::IndexDeletion => write!(f, "indexDeletion"),
Kind::IndexUpdate => write!(f, "indexUpdate"),
Kind::IndexSwap => write!(f, "indexSwap"),
Kind::TaskCancelation => write!(f, "taskCancelation"),
Kind::TaskDeletion => write!(f, "taskDeletion"),
Kind::DumpCreation => write!(f, "dumpCreation"),
Kind::SnapshotCreation => write!(f, "snapshotCreation"),
}
}
}
impl FromStr for Kind { impl FromStr for Kind {
type Err = ResponseError; type Err = ResponseError;
@ -452,8 +468,8 @@ pub enum Details {
IndexInfo { primary_key: Option<String> }, IndexInfo { primary_key: Option<String> },
DocumentDeletion { matched_documents: usize, deleted_documents: Option<u64> }, DocumentDeletion { matched_documents: usize, deleted_documents: Option<u64> },
ClearAll { deleted_documents: Option<u64> }, ClearAll { deleted_documents: Option<u64> },
TaskCancelation { matched_tasks: u64, canceled_tasks: Option<u64>, original_query: String }, TaskCancelation { matched_tasks: u64, canceled_tasks: Option<u64>, original_filters: String },
TaskDeletion { matched_tasks: u64, deleted_tasks: Option<u64>, original_query: String }, TaskDeletion { matched_tasks: u64, deleted_tasks: Option<u64>, original_filters: String },
Dump { dump_uid: String }, Dump { dump_uid: String },
IndexSwap { swaps: Vec<IndexSwap> }, IndexSwap { swaps: Vec<IndexSwap> },
} }
@ -520,11 +536,11 @@ mod tests {
let details = Details::TaskDeletion { let details = Details::TaskDeletion {
matched_tasks: 1, matched_tasks: 1,
deleted_tasks: None, deleted_tasks: None,
original_query: "hello".to_owned(), original_filters: "hello".to_owned(),
}; };
let serialised = SerdeJson::<Details>::bytes_encode(&details).unwrap(); let serialised = SerdeJson::<Details>::bytes_encode(&details).unwrap();
let deserialised = SerdeJson::<Details>::bytes_decode(&serialised).unwrap(); let deserialised = SerdeJson::<Details>::bytes_decode(&serialised).unwrap();
meili_snap::snapshot!(format!("{:?}", details), @r###"TaskDeletion { matched_tasks: 1, deleted_tasks: None, original_query: "hello" }"###); meili_snap::snapshot!(format!("{:?}", details), @r###"TaskDeletion { matched_tasks: 1, deleted_tasks: None, original_filters: "hello" }"###);
meili_snap::snapshot!(format!("{:?}", deserialised), @r###"TaskDeletion { matched_tasks: 1, deleted_tasks: None, original_query: "hello" }"###); meili_snap::snapshot!(format!("{:?}", deserialised), @r###"TaskDeletion { matched_tasks: 1, deleted_tasks: None, original_filters: "hello" }"###);
} }
} }