diff --git a/crates/index-scheduler/src/insta_snapshot.rs b/crates/index-scheduler/src/insta_snapshot.rs index 3ddcdfcc2..4bc2beb05 100644 --- a/crates/index-scheduler/src/insta_snapshot.rs +++ b/crates/index-scheduler/src/insta_snapshot.rs @@ -291,8 +291,8 @@ fn snapshot_details(d: &Details) -> String { Details::IndexSwap { swaps } => { format!("{{ swaps: {swaps:?} }}") } - Details::UpgradeDatabase { from } => { - format!("{{ from: v{}.{}.{} }}", from.0, from.1, from.2) + Details::UpgradeDatabase { from, to } => { + format!("{{ from: {from:?}, to: {to:?} }}") } } } diff --git a/crates/index-scheduler/src/scheduler/snapshots/test_failure.rs/upgrade_failure/registered_a_task_and_upgrade_task.snap b/crates/index-scheduler/src/scheduler/snapshots/test_failure.rs/upgrade_failure/registered_a_task_and_upgrade_task.snap index ca4892f85..afad39e32 100644 --- a/crates/index-scheduler/src/scheduler/snapshots/test_failure.rs/upgrade_failure/registered_a_task_and_upgrade_task.snap +++ b/crates/index-scheduler/src/scheduler/snapshots/test_failure.rs/upgrade_failure/registered_a_task_and_upgrade_task.snap @@ -8,7 +8,7 @@ snapshot_kind: text ---------------------------------------------------------------------- ### All Tasks: 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: { from: v1.12.0 }, kind: UpgradeDatabase { from: (1, 12, 0) }} +1 {uid: 1, status: enqueued, details: { from: (1, 12, 0), to: (1, 13, 0) }, kind: UpgradeDatabase { from: (1, 12, 0) }} ---------------------------------------------------------------------- ### Status: enqueued [0,1,] diff --git a/crates/index-scheduler/src/upgrade/mod.rs b/crates/index-scheduler/src/upgrade/mod.rs index ebedb13cf..4e850aa32 100644 --- a/crates/index-scheduler/src/upgrade/mod.rs +++ b/crates/index-scheduler/src/upgrade/mod.rs @@ -75,7 +75,7 @@ pub fn upgrade_index_scheduler( finished_at: None, error: None, canceled_by: None, - details: Some(Details::UpgradeDatabase { from }), + details: Some(Details::UpgradeDatabase { from, to }), status: Status::Enqueued, kind: KindWithContent::UpgradeDatabase { from }, }, diff --git a/crates/index-scheduler/src/utils.rs b/crates/index-scheduler/src/utils.rs index 9b77c478e..80a0bb5ff 100644 --- a/crates/index-scheduler/src/utils.rs +++ b/crates/index-scheduler/src/utils.rs @@ -548,7 +548,7 @@ impl crate::IndexScheduler { Details::Dump { dump_uid: _ } => { assert_eq!(kind.as_kind(), Kind::DumpCreation); } - Details::UpgradeDatabase { from: _ } => { + Details::UpgradeDatabase { from: _, to: _ } => { assert_eq!(kind.as_kind(), Kind::UpgradeDatabase); } } diff --git a/crates/meilisearch-types/src/task_view.rs b/crates/meilisearch-types/src/task_view.rs index 6224b326c..7a6faee39 100644 --- a/crates/meilisearch-types/src/task_view.rs +++ b/crates/meilisearch-types/src/task_view.rs @@ -116,6 +116,8 @@ pub struct DetailsView { pub swaps: Option>, #[serde(skip_serializing_if = "Option::is_none")] pub upgrade_from: Option, + #[serde(skip_serializing_if = "Option::is_none")] + pub upgrade_to: Option, } impl DetailsView { @@ -236,10 +238,17 @@ impl DetailsView { Some(left) } }, + // We want the earliest version upgrade_from: match (self.upgrade_from.clone(), other.upgrade_from.clone()) { (None, None) => None, (None, Some(from)) | (Some(from), None) => Some(from), - (Some(_), Some(from)) => Some(from), + (Some(from), Some(_)) => Some(from), + }, + // And the latest + upgrade_to: match (self.upgrade_to.clone(), other.upgrade_to.clone()) { + (None, None) => None, + (None, Some(to)) | (Some(to), None) => Some(to), + (Some(_), Some(to)) => Some(to), }, } } @@ -318,8 +327,9 @@ impl From
for DetailsView { Details::IndexSwap { swaps } => { DetailsView { swaps: Some(swaps), ..Default::default() } } - Details::UpgradeDatabase { from } => DetailsView { + Details::UpgradeDatabase { from, to } => DetailsView { upgrade_from: Some(format!("v{}.{}.{}", from.0, from.1, from.2)), + upgrade_to: Some(format!("v{}.{}.{}", to.0, to.1, to.2)), ..Default::default() }, } diff --git a/crates/meilisearch-types/src/tasks.rs b/crates/meilisearch-types/src/tasks.rs index b798cacdb..6b237ee1f 100644 --- a/crates/meilisearch-types/src/tasks.rs +++ b/crates/meilisearch-types/src/tasks.rs @@ -16,7 +16,7 @@ use crate::batches::BatchId; use crate::error::ResponseError; use crate::keys::Key; use crate::settings::{Settings, Unchecked}; -use crate::InstanceUid; +use crate::{versioning, InstanceUid}; pub type TaskId = u32; @@ -269,9 +269,14 @@ impl KindWithContent { }), KindWithContent::DumpCreation { .. } => Some(Details::Dump { dump_uid: None }), KindWithContent::SnapshotCreation => None, - KindWithContent::UpgradeDatabase { from } => { - Some(Details::UpgradeDatabase { from: (from.0, from.1, from.2) }) - } + KindWithContent::UpgradeDatabase { from } => Some(Details::UpgradeDatabase { + from: (from.0, from.1, from.2), + to: ( + versioning::VERSION_MAJOR.parse().unwrap(), + versioning::VERSION_MINOR.parse().unwrap(), + versioning::VERSION_PATCH.parse().unwrap(), + ), + }), } } @@ -330,9 +335,14 @@ impl KindWithContent { }), KindWithContent::DumpCreation { .. } => Some(Details::Dump { dump_uid: None }), KindWithContent::SnapshotCreation => None, - KindWithContent::UpgradeDatabase { from } => { - Some(Details::UpgradeDatabase { from: *from }) - } + KindWithContent::UpgradeDatabase { from } => Some(Details::UpgradeDatabase { + from: *from, + to: ( + versioning::VERSION_MAJOR.parse().unwrap(), + versioning::VERSION_MINOR.parse().unwrap(), + versioning::VERSION_PATCH.parse().unwrap(), + ), + }), } } } @@ -373,9 +383,14 @@ impl From<&KindWithContent> for Option
{ }), KindWithContent::DumpCreation { .. } => Some(Details::Dump { dump_uid: None }), KindWithContent::SnapshotCreation => None, - KindWithContent::UpgradeDatabase { from } => { - Some(Details::UpgradeDatabase { from: *from }) - } + KindWithContent::UpgradeDatabase { from } => Some(Details::UpgradeDatabase { + from: *from, + to: ( + versioning::VERSION_MAJOR.parse().unwrap(), + versioning::VERSION_MINOR.parse().unwrap(), + versioning::VERSION_PATCH.parse().unwrap(), + ), + }), } } } @@ -630,6 +645,7 @@ pub enum Details { }, UpgradeDatabase { from: (u32, u32, u32), + to: (u32, u32, u32), }, } diff --git a/crates/meilisearch/db.snapshot b/crates/meilisearch/db.snapshot index 0f7356080..73a3f0f8e 100644 Binary files a/crates/meilisearch/db.snapshot and b/crates/meilisearch/db.snapshot differ diff --git a/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/batches_filter_afterEnqueuedAt_equal_2025-01-16T16:47:41.snap b/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/batches_filter_afterEnqueuedAt_equal_2025-01-16T16:47:41.snap index 873d616c4..397be0317 100644 --- a/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/batches_filter_afterEnqueuedAt_equal_2025-01-16T16:47:41.snap +++ b/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/batches_filter_afterEnqueuedAt_equal_2025-01-16T16:47:41.snap @@ -8,7 +8,8 @@ snapshot_kind: text "uid": 20, "progress": null, "details": { - "upgradeFrom": "v1.12.0" + "upgradeFrom": "v1.12.0", + "upgradeTo": "v1.13.0" }, "stats": { "totalNbTasks": 1, diff --git a/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/batches_filter_afterFinishedAt_equal_2025-01-16T16:47:41.snap b/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/batches_filter_afterFinishedAt_equal_2025-01-16T16:47:41.snap index 873d616c4..397be0317 100644 --- a/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/batches_filter_afterFinishedAt_equal_2025-01-16T16:47:41.snap +++ b/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/batches_filter_afterFinishedAt_equal_2025-01-16T16:47:41.snap @@ -8,7 +8,8 @@ snapshot_kind: text "uid": 20, "progress": null, "details": { - "upgradeFrom": "v1.12.0" + "upgradeFrom": "v1.12.0", + "upgradeTo": "v1.13.0" }, "stats": { "totalNbTasks": 1, diff --git a/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/batches_filter_afterStartedAt_equal_2025-01-16T16:47:41.snap b/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/batches_filter_afterStartedAt_equal_2025-01-16T16:47:41.snap index 873d616c4..397be0317 100644 --- a/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/batches_filter_afterStartedAt_equal_2025-01-16T16:47:41.snap +++ b/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/batches_filter_afterStartedAt_equal_2025-01-16T16:47:41.snap @@ -8,7 +8,8 @@ snapshot_kind: text "uid": 20, "progress": null, "details": { - "upgradeFrom": "v1.12.0" + "upgradeFrom": "v1.12.0", + "upgradeTo": "v1.13.0" }, "stats": { "totalNbTasks": 1, diff --git a/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/tasks_filter_afterEnqueuedAt_equal_2025-01-16T16:47:41.snap b/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/tasks_filter_afterEnqueuedAt_equal_2025-01-16T16:47:41.snap index f7f4cdb1a..9eaabc8d2 100644 --- a/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/tasks_filter_afterEnqueuedAt_equal_2025-01-16T16:47:41.snap +++ b/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/tasks_filter_afterEnqueuedAt_equal_2025-01-16T16:47:41.snap @@ -12,7 +12,8 @@ snapshot_kind: text "type": "upgradeDatabase", "canceledBy": null, "details": { - "upgradeFrom": "v1.12.0" + "upgradeFrom": "v1.12.0", + "upgradeTo": "v1.13.0" }, "error": null, "duration": "[duration]", diff --git a/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/tasks_filter_afterFinishedAt_equal_2025-01-16T16:47:41.snap b/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/tasks_filter_afterFinishedAt_equal_2025-01-16T16:47:41.snap index f7f4cdb1a..9eaabc8d2 100644 --- a/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/tasks_filter_afterFinishedAt_equal_2025-01-16T16:47:41.snap +++ b/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/tasks_filter_afterFinishedAt_equal_2025-01-16T16:47:41.snap @@ -12,7 +12,8 @@ snapshot_kind: text "type": "upgradeDatabase", "canceledBy": null, "details": { - "upgradeFrom": "v1.12.0" + "upgradeFrom": "v1.12.0", + "upgradeTo": "v1.13.0" }, "error": null, "duration": "[duration]", diff --git a/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/tasks_filter_afterStartedAt_equal_2025-01-16T16:47:41.snap b/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/tasks_filter_afterStartedAt_equal_2025-01-16T16:47:41.snap index f7f4cdb1a..9eaabc8d2 100644 --- a/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/tasks_filter_afterStartedAt_equal_2025-01-16T16:47:41.snap +++ b/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/tasks_filter_afterStartedAt_equal_2025-01-16T16:47:41.snap @@ -12,7 +12,8 @@ snapshot_kind: text "type": "upgradeDatabase", "canceledBy": null, "details": { - "upgradeFrom": "v1.12.0" + "upgradeFrom": "v1.12.0", + "upgradeTo": "v1.13.0" }, "error": null, "duration": "[duration]", diff --git a/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/the_whole_batch_queue_once_everything_has_been_processed.snap b/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/the_whole_batch_queue_once_everything_has_been_processed.snap index 762cb377a..9319a51cb 100644 --- a/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/the_whole_batch_queue_once_everything_has_been_processed.snap +++ b/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/the_whole_batch_queue_once_everything_has_been_processed.snap @@ -8,7 +8,8 @@ snapshot_kind: text "uid": 20, "progress": null, "details": { - "upgradeFrom": "v1.12.0" + "upgradeFrom": "v1.12.0", + "upgradeTo": "v1.13.0" }, "stats": { "totalNbTasks": 1, diff --git a/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/the_whole_task_queue_once_everything_has_been_processed.snap b/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/the_whole_task_queue_once_everything_has_been_processed.snap index f0f1784a1..f681a1b62 100644 --- a/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/the_whole_task_queue_once_everything_has_been_processed.snap +++ b/crates/meilisearch/tests/upgrade/v1_12/snapshots/v1_12_0.rs/check_the_index_scheduler/the_whole_task_queue_once_everything_has_been_processed.snap @@ -12,7 +12,8 @@ snapshot_kind: text "type": "upgradeDatabase", "canceledBy": null, "details": { - "upgradeFrom": "v1.12.0" + "upgradeFrom": "v1.12.0", + "upgradeTo": "v1.13.0" }, "error": null, "duration": "[duration]",