From fd583501d7ad34258a81f35aa7b8f0c827293188 Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Thu, 13 Apr 2023 17:07:44 +0200 Subject: [PATCH 1/4] Use non_free_pages_size instead of real_disk_size to check task db space taken --- index-scheduler/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index-scheduler/src/lib.rs b/index-scheduler/src/lib.rs index 3bde39040..b0ecef0f3 100644 --- a/index-scheduler/src/lib.rs +++ b/index-scheduler/src/lib.rs @@ -822,7 +822,7 @@ impl IndexScheduler { // if the task doesn't delete anything and 50% of the task queue is full, we must refuse to enqueue the incomming task if !matches!(&kind, KindWithContent::TaskDeletion { tasks, .. } if !tasks.is_empty()) - && (self.env.real_disk_size()? * 100) / self.env.map_size()? as u64 > 50 + && (self.env.non_free_pages_size()? * 100) / self.env.map_size()? as u64 > 50 { return Err(Error::NoSpaceLeftInTaskQueue); } From 066c6bd87582c2eb89cade3e6f9487acfe975d6b Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Thu, 13 Apr 2023 17:20:06 +0200 Subject: [PATCH 2/4] test task db full now checks that a task can be successfully added after deleting tasks --- meilisearch/tests/tasks/mod.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/meilisearch/tests/tasks/mod.rs b/meilisearch/tests/tasks/mod.rs index 88f83bb70..723c628bb 100644 --- a/meilisearch/tests/tasks/mod.rs +++ b/meilisearch/tests/tasks/mod.rs @@ -1050,7 +1050,7 @@ async fn test_task_queue_is_full() { "###); // But we should still be able to register tasks deletion IF they delete something - let (result, code) = server.delete_tasks("uids=0").await; + let (result, code) = server.delete_tasks("uids=*").await; snapshot!(code, @"200 OK"); snapshot!(json_string!(result, { ".enqueuedAt" => "[date]", ".taskUid" => "uid" }), @r###" { @@ -1062,6 +1062,19 @@ async fn test_task_queue_is_full() { } "###); + // But we should still be able to register tasks deletion IF they delete something + let (result, code) = server.create_index(json!({ "uid": "doggo" })).await; + snapshot!(code, @"202 Accepted"); + snapshot!(json_string!(result, { ".enqueuedAt" => "[date]", ".taskUid" => "uid" }), @r###" + { + "taskUid": "uid", + "indexUid": "doggo", + "status": "enqueued", + "type": "indexCreation", + "enqueuedAt": "[date]" + } + "###); + // we're going to fill up the queue once again loop { let (res, code) = server.delete_tasks("uids=0").await; From 1e6cbcaf12a4f39be46b6b65f98c994574044bba Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Thu, 13 Apr 2023 17:27:12 +0200 Subject: [PATCH 3/4] Update test comment Co-authored-by: Tamo --- meilisearch/tests/tasks/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meilisearch/tests/tasks/mod.rs b/meilisearch/tests/tasks/mod.rs index 723c628bb..b608040da 100644 --- a/meilisearch/tests/tasks/mod.rs +++ b/meilisearch/tests/tasks/mod.rs @@ -1062,7 +1062,7 @@ async fn test_task_queue_is_full() { } "###); - // But we should still be able to register tasks deletion IF they delete something + // Now we should be able to register tasks again let (result, code) = server.create_index(json!({ "uid": "doggo" })).await; snapshot!(code, @"202 Accepted"); snapshot!(json_string!(result, { ".enqueuedAt" => "[date]", ".taskUid" => "uid" }), @r###" From c2f4b6ced09530ec969fec256a864c635a93f760 Mon Sep 17 00:00:00 2001 From: Louis Dureuil Date: Thu, 13 Apr 2023 18:22:42 +0200 Subject: [PATCH 4/4] Test: await for the deletion task to complete before trying to add another task --- meilisearch/tests/tasks/mod.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/meilisearch/tests/tasks/mod.rs b/meilisearch/tests/tasks/mod.rs index b608040da..40093dc41 100644 --- a/meilisearch/tests/tasks/mod.rs +++ b/meilisearch/tests/tasks/mod.rs @@ -1062,6 +1062,9 @@ async fn test_task_queue_is_full() { } "###); + let result = server.wait_task(result["taskUid"].as_u64().unwrap()).await; + snapshot!(json_string!(result["status"]), @r###""succeeded""###); + // Now we should be able to register tasks again let (result, code) = server.create_index(json!({ "uid": "doggo" })).await; snapshot!(code, @"202 Accepted");