mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-10-30 23:46:28 +00:00 
			
		
		
		
	improve the details and stats of the current batch processing
This commit is contained in:
		| @@ -69,9 +69,13 @@ pub fn snapshot_index_scheduler(scheduler: &IndexScheduler) -> String { | ||||
|     snap.push_str(&format!("### Autobatching Enabled = {autobatching_enabled}\n")); | ||||
|     snap.push_str(&format!( | ||||
|         "### Processing batch {:?}:\n", | ||||
|         processing.batch.map(|batch| batch.uid) | ||||
|         processing.batch.as_ref().map(|batch| batch.uid) | ||||
|     )); | ||||
|     snap.push_str(&snapshot_bitmap(&processing.processing)); | ||||
|     if let Some(ref batch) = processing.batch { | ||||
|         snap.push_str("\n"); | ||||
|         snap.push_str(&snapshot_batch(&batch.to_batch())); | ||||
|     } | ||||
|     snap.push_str("\n----------------------------------------------------------------------\n"); | ||||
|  | ||||
|     snap.push_str("### All Tasks:\n"); | ||||
|   | ||||
| @@ -5,6 +5,7 @@ snapshot_kind: text | ||||
| ### Autobatching Enabled = true | ||||
| ### Processing batch Some(1): | ||||
| [1,] | ||||
| {uid: 1, details: {"receivedDocuments":2,"indexedDocuments":null}, stats: {"totalNbTasks":2,"status":{"enqueued":2},"types":{"documentAdditionOrUpdate":2},"indexUids":{"beavero":2}}, } | ||||
| ---------------------------------------------------------------------- | ||||
| ### All Tasks: | ||||
| 0 {uid: 0, batch_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 }} | ||||
|   | ||||
| @@ -5,6 +5,7 @@ snapshot_kind: text | ||||
| ### Autobatching Enabled = true | ||||
| ### Processing batch Some(1): | ||||
| [1,] | ||||
| {uid: 1, details: {"receivedDocuments":2,"indexedDocuments":null}, stats: {"totalNbTasks":2,"status":{"enqueued":2},"types":{"documentAdditionOrUpdate":2},"indexUids":{"beavero":2}}, } | ||||
| ---------------------------------------------------------------------- | ||||
| ### All Tasks: | ||||
| 0 {uid: 0, batch_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 }} | ||||
|   | ||||
| @@ -5,6 +5,7 @@ snapshot_kind: text | ||||
| ### Autobatching Enabled = true | ||||
| ### Processing batch Some(0): | ||||
| [0,] | ||||
| {uid: 0, details: {"dumpUid":null}, stats: {"totalNbTasks":1,"status":{"enqueued":1},"types":{"dumpCreation":1},"indexUids":{}}, } | ||||
| ---------------------------------------------------------------------- | ||||
| ### All Tasks: | ||||
| 0 {uid: 0, status: enqueued, details: { dump_uid: None }, kind: DumpCreation { keys: [], instance_uid: None }} | ||||
|   | ||||
| @@ -5,6 +5,7 @@ snapshot_kind: text | ||||
| ### Autobatching Enabled = true | ||||
| ### Processing batch Some(0): | ||||
| [0,] | ||||
| {uid: 0, details: {"receivedDocuments":2,"indexedDocuments":null}, stats: {"totalNbTasks":2,"status":{"enqueued":2},"types":{"documentAdditionOrUpdate":2},"indexUids":{"catto":2}}, } | ||||
| ---------------------------------------------------------------------- | ||||
| ### 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 }} | ||||
|   | ||||
| @@ -5,6 +5,7 @@ snapshot_kind: text | ||||
| ### Autobatching Enabled = true | ||||
| ### Processing batch Some(0): | ||||
| [0,] | ||||
| {uid: 0, details: {"receivedDocuments":2,"indexedDocuments":null}, stats: {"totalNbTasks":2,"status":{"enqueued":2},"types":{"documentAdditionOrUpdate":2},"indexUids":{"catto":2}}, } | ||||
| ---------------------------------------------------------------------- | ||||
| ### 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 }} | ||||
|   | ||||
| @@ -5,6 +5,7 @@ snapshot_kind: text | ||||
| ### Autobatching Enabled = true | ||||
| ### Processing batch Some(0): | ||||
| [0,] | ||||
| {uid: 0, details: {"receivedDocuments":2,"indexedDocuments":null}, stats: {"totalNbTasks":2,"status":{"enqueued":2},"types":{"documentAdditionOrUpdate":2},"indexUids":{"catto":2}}, } | ||||
| ---------------------------------------------------------------------- | ||||
| ### 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 }} | ||||
|   | ||||
| @@ -5,6 +5,7 @@ snapshot_kind: text | ||||
| ### Autobatching Enabled = true | ||||
| ### Processing batch Some(0): | ||||
| [0,] | ||||
| {uid: 0, details: {"receivedDocuments":2,"indexedDocuments":null}, stats: {"totalNbTasks":2,"status":{"enqueued":2},"types":{"documentAdditionOrUpdate":2},"indexUids":{"doggos":2}}, } | ||||
| ---------------------------------------------------------------------- | ||||
| ### All Tasks: | ||||
| 0 {uid: 0, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "doggos", primary_key: Some("id"), method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }} | ||||
|   | ||||
| @@ -5,6 +5,7 @@ snapshot_kind: text | ||||
| ### Autobatching Enabled = true | ||||
| ### Processing batch Some(0): | ||||
| [0,] | ||||
| {uid: 0, details: {"receivedDocuments":2,"indexedDocuments":null}, stats: {"totalNbTasks":2,"status":{"enqueued":2},"types":{"documentAdditionOrUpdate":2},"indexUids":{"doggos":2}}, } | ||||
| ---------------------------------------------------------------------- | ||||
| ### All Tasks: | ||||
| 0 {uid: 0, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "doggos", primary_key: Some("id"), method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }} | ||||
|   | ||||
| @@ -5,6 +5,7 @@ snapshot_kind: text | ||||
| ### Autobatching Enabled = true | ||||
| ### Processing batch Some(0): | ||||
| [0,] | ||||
| {uid: 0, details: {"receivedDocuments":2,"indexedDocuments":null}, stats: {"totalNbTasks":2,"status":{"enqueued":2},"types":{"documentAdditionOrUpdate":2},"indexUids":{"doggos":2}}, } | ||||
| ---------------------------------------------------------------------- | ||||
| ### All Tasks: | ||||
| 0 {uid: 0, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "doggos", primary_key: Some("id"), method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }} | ||||
|   | ||||
| @@ -5,6 +5,7 @@ snapshot_kind: text | ||||
| ### Autobatching Enabled = true | ||||
| ### Processing batch Some(0): | ||||
| [0,] | ||||
| {uid: 0, details: {"receivedDocuments":2,"indexedDocuments":null}, stats: {"totalNbTasks":2,"status":{"enqueued":2},"types":{"documentAdditionOrUpdate":2},"indexUids":{"doggos":2}}, } | ||||
| ---------------------------------------------------------------------- | ||||
| ### All Tasks: | ||||
| 0 {uid: 0, status: enqueued, details: { received_documents: 1, indexed_documents: None }, kind: DocumentAdditionOrUpdate { index_uid: "doggos", primary_key: Some("id"), method: ReplaceDocuments, content_file: 00000000-0000-0000-0000-000000000000, documents_count: 1, allow_index_creation: true }} | ||||
|   | ||||
| @@ -5,6 +5,7 @@ snapshot_kind: text | ||||
| ### Autobatching Enabled = true | ||||
| ### Processing batch Some(0): | ||||
| [0,] | ||||
| {uid: 0, details: {"primaryKey":"id"}, stats: {"totalNbTasks":2,"status":{"enqueued":2},"types":{"indexCreation":2},"indexUids":{"index_a":2}}, } | ||||
| ---------------------------------------------------------------------- | ||||
| ### All Tasks: | ||||
| 0 {uid: 0, status: enqueued, details: { primary_key: Some("id") }, kind: IndexCreation { index_uid: "index_a", primary_key: Some("id") }} | ||||
|   | ||||
| @@ -5,6 +5,7 @@ snapshot_kind: text | ||||
| ### Autobatching Enabled = true | ||||
| ### Processing batch Some(0): | ||||
| [0,] | ||||
| {uid: 0, details: {"primaryKey":"id"}, stats: {"totalNbTasks":2,"status":{"enqueued":2},"types":{"indexCreation":2},"indexUids":{"index_a":2}}, } | ||||
| ---------------------------------------------------------------------- | ||||
| ### All Tasks: | ||||
| 0 {uid: 0, status: enqueued, details: { primary_key: Some("id") }, kind: IndexCreation { index_uid: "index_a", primary_key: Some("id") }} | ||||
|   | ||||
| @@ -5,6 +5,7 @@ snapshot_kind: text | ||||
| ### Autobatching Enabled = true | ||||
| ### Processing batch Some(0): | ||||
| [0,] | ||||
| {uid: 0, details: {"primaryKey":"id"}, stats: {"totalNbTasks":2,"status":{"enqueued":2},"types":{"indexCreation":2},"indexUids":{"index_a":2}}, } | ||||
| ---------------------------------------------------------------------- | ||||
| ### All Tasks: | ||||
| 0 {uid: 0, status: enqueued, details: { primary_key: Some("id") }, kind: IndexCreation { index_uid: "index_a", primary_key: Some("id") }} | ||||
|   | ||||
| @@ -5,6 +5,7 @@ snapshot_kind: text | ||||
| ### Autobatching Enabled = true | ||||
| ### Processing batch Some(1): | ||||
| [1,] | ||||
| {uid: 1, details: {"primaryKey":"sheep"}, stats: {"totalNbTasks":2,"status":{"enqueued":2},"types":{"indexCreation":2},"indexUids":{"doggo":2}}, } | ||||
| ---------------------------------------------------------------------- | ||||
| ### All Tasks: | ||||
| 0 {uid: 0, batch_uid: 0, status: succeeded, details: { primary_key: Some("mouse") }, kind: IndexCreation { index_uid: "catto", primary_key: Some("mouse") }} | ||||
|   | ||||
| @@ -5,6 +5,7 @@ snapshot_kind: text | ||||
| ### Autobatching Enabled = true | ||||
| ### Processing batch Some(0): | ||||
| [3,] | ||||
| {uid: 0, details: {"matchedTasks":2,"deletedTasks":null,"originalFilter":"test_query"}, stats: {"totalNbTasks":1,"status":{"enqueued":1},"types":{"taskDeletion":1},"indexUids":{}}, } | ||||
| ---------------------------------------------------------------------- | ||||
| ### All Tasks: | ||||
| 0 {uid: 0, status: enqueued, details: { primary_key: Some("mouse") }, kind: IndexCreation { index_uid: "catto", primary_key: Some("mouse") }} | ||||
|   | ||||
| @@ -61,11 +61,23 @@ impl ProcessingBatch { | ||||
|  | ||||
|     /// Update itself with the content of the task and update the batch id in the task. | ||||
|     pub fn processing<'a>(&mut self, tasks: impl IntoIterator<Item = &'a mut Task>) { | ||||
|         self.stats.total_nb_tasks += 1; | ||||
|  | ||||
|         for task in tasks.into_iter() { | ||||
|             task.batch_uid = Some(self.uid); | ||||
|             // We don't store the statuses since they're all enqueued. | ||||
|             // We don't store the statuses in the map since they're all enqueued but we must | ||||
|             // still store them in the stats since that can be displayed. | ||||
|             *self.stats.status.entry(task.status).or_default() += 1; | ||||
|  | ||||
|             self.kinds.insert(task.kind.as_kind()); | ||||
|             *self.stats.types.entry(task.kind.as_kind()).or_default() += 1; | ||||
|             self.indexes.extend(task.indexes().iter().map(|s| s.to_string())); | ||||
|             if let Some(index_uid) = task.index_uid() { | ||||
|                 *self.stats.index_uids.entry(index_uid.to_string()).or_default() += 1; | ||||
|             } | ||||
|             if let Some(ref details) = task.details { | ||||
|                 self.details.accumulate(&DetailsView::from(details.clone())); | ||||
|             } | ||||
|             if let Some(canceled_by) = task.canceled_by { | ||||
|                 self.canceled_by.insert(canceled_by); | ||||
|             } | ||||
| @@ -82,6 +94,8 @@ impl ProcessingBatch { | ||||
|  | ||||
|     /// Must be called once the batch has finished processing. | ||||
|     pub fn finished(&mut self) { | ||||
|         self.details = DetailsView::default(); | ||||
|         self.stats = BatchStats::default(); | ||||
|         self.finished_at = Some(OffsetDateTime::now_utc()); | ||||
|  | ||||
|         // Initially we inserted ourselves as a processing batch, that's not the case anymore. | ||||
|   | ||||
		Reference in New Issue
	
	Block a user