mirror of https://github.com/apache/lucene.git
Fix potential race condition in DocumentsWriter & DocumentsWriterDeleteQueue (#13169)
* Fix potential race condition in DocumentsWriter & DocumentsWriterDeleteQueue * add changes
This commit is contained in:
parent
44fa35b65f
commit
b527e101e7
|
@ -232,6 +232,8 @@ Bug Fixes
|
|||
|
||||
* GITHUB#13162: Fix NPE when LeafReader return null VectorValues (Pan Guixin)
|
||||
|
||||
* GITHUB#13169: Fix potential race condition in DocumentsWriter & DocumentsWriterDeleteQueue (Ben Trent)
|
||||
|
||||
Other
|
||||
---------------------
|
||||
|
||||
|
|
|
@ -540,13 +540,16 @@ final class DocumentsWriter implements Closeable, Accountable {
|
|||
return deleteQueue.getNextSequenceNumber();
|
||||
}
|
||||
|
||||
synchronized void resetDeleteQueue(DocumentsWriterDeleteQueue newQueue) {
|
||||
synchronized long resetDeleteQueue(int maxNumPendingOps) {
|
||||
final DocumentsWriterDeleteQueue newQueue = deleteQueue.advanceQueue(maxNumPendingOps);
|
||||
assert deleteQueue.isAdvanced();
|
||||
assert newQueue.isAdvanced() == false;
|
||||
assert deleteQueue.getLastSequenceNumber() <= newQueue.getLastSequenceNumber();
|
||||
assert deleteQueue.getMaxSeqNo() <= newQueue.getLastSequenceNumber()
|
||||
: "maxSeqNo: " + deleteQueue.getMaxSeqNo() + " vs. " + newQueue.getLastSequenceNumber();
|
||||
long oldMaxSeqNo = deleteQueue.getMaxSeqNo();
|
||||
deleteQueue = newQueue;
|
||||
return oldMaxSeqNo;
|
||||
}
|
||||
|
||||
interface FlushNotifications { // TODO maybe we find a better name for this?
|
||||
|
|
|
@ -570,10 +570,7 @@ final class DocumentsWriterFlushControl implements Accountable, Closeable {
|
|||
// Insert a gap in seqNo of current active thread count, in the worst case each of those
|
||||
// threads now have one operation in flight. It's fine
|
||||
// if we have some sequence numbers that were never assigned:
|
||||
DocumentsWriterDeleteQueue newQueue =
|
||||
documentsWriter.deleteQueue.advanceQueue(perThreadPool.size());
|
||||
seqNo = documentsWriter.deleteQueue.getMaxSeqNo();
|
||||
documentsWriter.resetDeleteQueue(newQueue);
|
||||
seqNo = documentsWriter.resetDeleteQueue(perThreadPool.size());
|
||||
} finally {
|
||||
perThreadPool.unlockNewWriters();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue