Index: src/java/org/apache/lucene/index/CheckIndex.java =================================================================== --- src/java/org/apache/lucene/index/CheckIndex.java (revision 747327) +++ src/java/org/apache/lucene/index/CheckIndex.java (working copy) @@ -394,13 +394,19 @@ final int numDocs = reader.numDocs(); toLoseDocCount = numDocs; if (reader.hasDeletions()) { + if (reader.deletedDocs.count() != info.getDelCount()) { + throw new RuntimeException("delete count mismatch: info=" + info.getDelCount() + " vs deletedDocs.count()=" + reader.deletedDocs.count()); + } + if (reader.deletedDocs.count() > reader.maxDoc()) { + throw new RuntimeException("too many deleted docs: maxDoc()=" + reader.maxDoc() + " vs deletedDocs.count()=" + reader.deletedDocs.count()); + } if (info.docCount - numDocs != info.getDelCount()){ throw new RuntimeException("delete count mismatch: info=" + info.getDelCount() + " vs reader=" + (info.docCount - numDocs)); } segInfoStat.numDeleted = info.docCount - numDocs; msg("OK [" + (segInfoStat.numDeleted) + " deleted docs]"); } else { - if (info.getDelCount() != 0){ + if (info.getDelCount() != 0) { throw new RuntimeException("delete count mismatch: info=" + info.getDelCount() + " vs reader=" + (info.docCount - numDocs)); } msg("OK"); @@ -431,6 +437,8 @@ long termCount = 0; long totFreq = 0; long totPos = 0; + final int maxDoc = reader.maxDoc(); + while(termEnum.next()) { termCount++; final Term term = termEnum.term(); @@ -445,6 +453,9 @@ final int freq = termPositions.freq(); if (doc <= lastDoc) throw new RuntimeException("term " + term + ": doc " + doc + " <= lastDoc " + lastDoc); + if (doc >= maxDoc) + throw new RuntimeException("term " + term + ": doc " + doc + " >= maxDoc " + maxDoc); + lastDoc = doc; if (freq <= 0) throw new RuntimeException("term " + term + ": doc " + doc + ": freq " + freq + " is out of bounds");