Fix TestIndexWriterOnDiskFull.testAddDocumentOnDiskFull to handle IllegalStateException from startCommit() (#11757)

If ConcurrentMergeScheduler is used, and the merge hits fatal exception (such as disk full) after prepareCommit()'s ensureOpen() check, then startCommit() will throw IllegalStateException instead of AlreadyClosedException.

The test is currently not prepared to handle this: the logic is only geared around exceptions coming from addDocument()

Closes #11755
This commit is contained in:
Robert Muir 2022-09-08 13:35:54 -04:00 committed by GitHub
parent f8285fd0fe
commit f4146a44e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 2 deletions

View File

@ -77,8 +77,20 @@ public class TestIndexWriterOnDiskFull extends LuceneTestCase {
if (VERBOSE) {
System.out.println("TEST: done adding docs; now commit");
}
try {
// when calling commit(), if the writer is asynchronously closed
// by a fatal tragedy (e.g. from disk-full-on-merge with CMS),
// then we may receive either AlreadyClosedException OR IllegalStateException,
// depending on when it happens.
writer.commit();
indexExists = true;
} catch (IOException | IllegalStateException e) {
if (VERBOSE) {
System.out.println("TEST: exception on commit");
e.printStackTrace(System.out);
}
hitError = true;
}
} catch (IOException e) {
if (VERBOSE) {
System.out.println("TEST: exception on addDoc");