danmuzi commented on a change in pull request #688: LUCENE-8813: Ensure we
never apply deletes from a closed DWPTDeleteQueue
URL: https://github.com/apache/lucene-solr/pull/688#discussion_r288669562
##########
File path: lucene/core/src/java/org/apache/lucene/index/DocumentsWriter.java
##########
@@ -168,27 +168,28 @@ long updateDocValues(DocValuesUpdate... updates) throws
IOException {
}
private synchronized long
applyDeleteOrUpdate(ToLongFunction<DocumentsWriterDeleteQueue> function) throws
IOException {
- // TODO why is this synchronized?
+ // This method is synchronized to make sure we don't replace the
deleteQueue while applying this update / delete
+ // otherwise we might loose an update / delete if this happens
concurrently to a full flush.
final DocumentsWriterDeleteQueue deleteQueue = this.deleteQueue;
long seqNo = function.applyAsLong(deleteQueue);
flushControl.doOnDelete();
lastSeqNo = Math.max(lastSeqNo, seqNo);
- if (applyAllDeletes(deleteQueue)) {
+ if (applyAllDeletes()) {
seqNo = -seqNo;
}
return seqNo;
}
/** If buffered deletes are using too much heap, resolve them and write disk
and return true. */
- private boolean applyAllDeletes(DocumentsWriterDeleteQueue deleteQueue)
throws IOException {
+ private boolean applyAllDeletes() throws IOException {
+ final DocumentsWriterDeleteQueue deleteQueue = this.deleteQueue;
if (flushControl.isFullFlush() == false // never apply deletes during full
flush this breaks happens before relationship
+ && deleteQueue.isOpen() // if it's closed then it's already fully
applied and we have a new delete queue
&& flushControl.getAndResetApplyAllDeletes()) {
- if (deleteQueue != null) {
Review comment:
It seems to be guaranteed that it is not null.
Because it is first created in the constructor and is not initialized to
null.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]