Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Propagate pet vector DB write failures to allow retry

Amrithesh Kakkoth Entef1322c4703ee
diff --git a/mobile/apps/photos/lib/db/ml/db.dart b/mobile/apps/photos/lib/db/ml/db.dart
index ca75c42db4..ab9771312f 100644
--- a/mobile/apps/photos/lib/db/ml/db.dart
+++ b/mobile/apps/photos/lib/db/ml/db.dart
@@ -313,7 +313,6 @@ class MLDataDB with SqlDbBase implements IMLDataDB<int> {
}
/// Store pet face embeddings into PetVectorDB after SQLite insert.
- /// Failure is logged but does not block indexing.
Future<void> storePetFaceEmbeddings(
List<DBPetFace> dbPetFaces,
List<PetFaceResult> petFaces,
@@ -374,11 +373,11 @@ class MLDataDB with SqlDbBase implements IMLDataDB<int> {
}
} catch (e, s) {
_logger.severe("Failed to store pet face embeddings in vector DB", e, s);
+ rethrow;
}
}
/// Store pet body embeddings into PetVectorDB after SQLite insert.
- /// Failure is logged but does not block indexing.
Future<void> storePetBodyEmbeddings(
List<DBPetBody> dbPetBodies,
List<PetBodyResult> petBodies,
@@ -443,6 +442,7 @@ class MLDataDB with SqlDbBase implements IMLDataDB<int> {
e,
s,
);
+ rethrow;
}
}
diff --git a/mobile/apps/photos/lib/services/machine_learning/ml_service.dart b/mobile/apps/photos/lib/services/machine_learning/ml_service.dart
index 4c0aef42f7..5ef45bce73 100644
--- a/mobile/apps/photos/lib/services/machine_learning/ml_service.dart
+++ b/mobile/apps/photos/lib/services/machine_learning/ml_service.dart
@@ -732,10 +732,15 @@ class MLService {
return true;
}
_logger.severe(
- "Failed to index file for fileID ${instruction.fileKey} (format $format, type $fileType, size $size). Not storing any results locally, which means it will be automatically retried later.",
+ "Failed to index file for fileID ${instruction.fileKey} (format $format, type $fileType, size $size). Cleaning up partial results so the file will be automatically retried later.",
e,
s,
);
+ // Clean up any pet rows that were already committed before the
+ // failure so the file is not treated as fully indexed.
+ if (instruction.shouldRunPets) {
+ await mlDataDB.deletePetDataForFiles([instruction.fileKey]);
+ }
return false;
}
}