manduinca opened a new pull request, #16643:
URL: https://github.com/apache/lucene/pull/16643
### Description
`rollbackInternalNoCommit` asks the deleter to remove unreferenced files
while the pooled readers are still open, so an uncommitted segment gets deleted
from under them. On a directory that checks for this the rollback fails
outright:
```
java.io.IOException: MockDirectoryWrapper: file "_2.cfs" is still open:
cannot delete
at org.apache.lucene.util.FileDeleter.delete(FileDeleter.java:234)
at
org.apache.lucene.index.IndexFileDeleter.decRef(IndexFileDeleter.java:620)
at
org.apache.lucene.index.IndexFileDeleter.checkpoint(IndexFileDeleter.java:578)
at
org.apache.lucene.index.IndexWriter.rollbackInternalNoCommit(IndexWriter.java:2628)
```
Moving `readerPool.close()` ahead of `deleter.checkpoint(...)` is the fix,
and as @LuXugang notes in the issue it isn't enough on its own: the
checkpoint's own diagnostic logging goes back to the pool through `segString` →
`numDeletedDocs` → `getPooledInstance(info, false)`, which throws
`AlreadyClosedException` once the pool is closed.
That second part turns out to be a lookup answering with an exception where
it could answer with the truth. `ReaderPool.get(info, create)` throws for a
closed pool even when `create == false`, but a closed pool holds no readers
(its own assert says the map is empty), so `null` is the accurate answer for a
lookup. Every `create == false` caller already handles `null`: `numDeletedDocs`
falls back to `info.getDelCount(...)`, and the two other call sites null-check
before use. So `get` now returns `null` in that case and keeps throwing when
asked to create.
### Tests
`TestIndexWriterRollbackReaderPool` is the reproducer from the issue. It
fails on `main` with the stack trace above and passes with this change.
The full `lucene/core` suite is green with the change: 8689 tests, 319
skipped, 0 failures — which is where the `AlreadyClosedException` mentioned in
the issue would show up.
Closes #16625
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]