File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
astra/src/main/java/com/slack/astra/chunk Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change 3232import java .util .concurrent .ConcurrentHashMap ;
3333import java .util .concurrent .TimeUnit ;
3434import java .util .stream .Collectors ;
35+ import org .apache .lucene .index .CheckIndex ;
3536import org .apache .lucene .index .IndexCommit ;
37+ import org .apache .lucene .store .FSDirectory ;
3638import org .slf4j .Logger ;
3739
3840/**
@@ -249,6 +251,17 @@ public boolean snapshotToS3(BlobStore blobStore) {
249251 totalBytes += sizeOfFile ;
250252 logger .debug ("File name is {} ({} bytes)" , fileName , sizeOfFile );
251253 }
254+
255+ // check if lucene index is valid and not corrupted
256+ try (FSDirectory directory = FSDirectory .open (dirPath )) {
257+ CheckIndex checker = new CheckIndex (directory );
258+ CheckIndex .Status status = checker .checkIndex ();
259+
260+ if (!status .clean ) {
261+ logger .error ("Lucene index is not clean. Found issues: {}." , status );
262+ throw new IllegalStateException ("Lucene index is not clean. Found issues: " + status );
263+ }
264+ }
252265 this .fileUploadAttempts .increment (filesToUpload .size ());
253266 Timer .Sample snapshotTimer = Timer .start (meterRegistry );
254267
You can’t perform that action at this time.
0 commit comments