@@ -2575,8 +2575,6 @@ private void doCheckIndex() throws IOException {
2575
2575
if (Lucene .indexExists (store .directory ()) == false ) {
2576
2576
return ;
2577
2577
}
2578
- BytesStreamOutput os = new BytesStreamOutput ();
2579
- PrintStream out = new PrintStream (os , false , StandardCharsets .UTF_8 .name ());
2580
2578
2581
2579
if ("checksum" .equals (checkIndexOnStartup )) {
2582
2580
// physical verification only: verify all checksums for the latest commit
@@ -2588,23 +2586,36 @@ private void doCheckIndex() throws IOException {
2588
2586
logger .warn ("check index [failure]" , e );
2589
2587
throw e ;
2590
2588
}
2589
+ final List <String > checkedFiles = new ArrayList <>(metadata .size ());
2591
2590
for (Map .Entry <String , StoreFileMetadata > entry : metadata .asMap ().entrySet ()) {
2592
2591
try {
2593
2592
Store .checkIntegrity (entry .getValue (), store .directory ());
2594
- out .println ("checksum passed: " + entry .getKey ());
2595
- } catch (IOException exc ) {
2596
- out .println ("checksum failed: " + entry .getKey ());
2597
- exc .printStackTrace (out );
2598
- corrupt = exc ;
2593
+ if (corrupt == null ) {
2594
+ checkedFiles .add (entry .getKey ());
2595
+ } else {
2596
+ logger .info ("check index [ok]: checksum check passed on [{}]" , entry .getKey ());
2597
+ }
2598
+ } catch (IOException ioException ) {
2599
+ for (final String checkedFile : checkedFiles ) {
2600
+ logger .info ("check index [ok]: checksum check passed on [{}]" , checkedFile );
2601
+ }
2602
+ checkedFiles .clear ();
2603
+ logger .warn (new ParameterizedMessage ("check index [failure]: checksum failed on [{}]" , entry .getKey ()), ioException );
2604
+ corrupt = ioException ;
2599
2605
}
2600
2606
}
2601
- out .flush ();
2602
2607
if (corrupt != null ) {
2603
- logger .warn ("check index [failure]\n {}" , os .bytes ().utf8ToString ());
2604
2608
throw corrupt ;
2605
2609
}
2610
+ if (logger .isDebugEnabled ()) {
2611
+ for (final String checkedFile : checkedFiles ) {
2612
+ logger .debug ("check index [ok]: checksum check passed on [{}]" , checkedFile );
2613
+ }
2614
+ }
2606
2615
} else {
2607
2616
// full checkindex
2617
+ final BytesStreamOutput os = new BytesStreamOutput ();
2618
+ final PrintStream out = new PrintStream (os , false , StandardCharsets .UTF_8 .name ());
2608
2619
final CheckIndex .Status status = store .checkIndex (out );
2609
2620
out .flush ();
2610
2621
if (status .clean == false ) {
@@ -2617,10 +2628,10 @@ private void doCheckIndex() throws IOException {
2617
2628
logger .warn ("{}" , os .bytes ().utf8ToString ());
2618
2629
throw new IOException ("index check failure" );
2619
2630
}
2620
- }
2621
2631
2622
- if (logger .isDebugEnabled ()) {
2623
- logger .debug ("check index [success]\n {}" , os .bytes ().utf8ToString ());
2632
+ if (logger .isDebugEnabled ()) {
2633
+ logger .debug ("check index [success]\n {}" , os .bytes ().utf8ToString ());
2634
+ }
2624
2635
}
2625
2636
2626
2637
recoveryState .getVerifyIndex ().checkIndexTime (Math .max (0 , TimeValue .nsecToMSec (System .nanoTime () - timeNS )));
0 commit comments