You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by si...@apache.org on 2020/09/18 15:59:23 UTC
[lucene-solr] branch master updated: LUCENE-9534: Ensure
DWPT#ramBytesUsed is only called unter lock (#1889)
This is an automated email from the ASF dual-hosted git repository.
simonw pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/master by this push:
new 208a1c0 LUCENE-9534: Ensure DWPT#ramBytesUsed is only called unter lock (#1889)
208a1c0 is described below
commit 208a1c07b06a4b7c30b093e3f54bf91cccfc74d1
Author: Simon Willnauer <si...@apache.org>
AuthorDate: Fri Sep 18 17:59:05 2020 +0200
LUCENE-9534: Ensure DWPT#ramBytesUsed is only called unter lock (#1889)
Consumers of the used RAM of a DWPT should use it's committed bytesUsed
value that's threadsafe.
---
.../java/org/apache/lucene/index/DocumentsWriterFlushControl.java | 2 +-
.../src/java/org/apache/lucene/index/DocumentsWriterPerThread.java | 6 ++++--
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java
index c35cae4..d368e88 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterFlushControl.java
@@ -673,7 +673,7 @@ final class DocumentsWriterFlushControl implements Accountable, Closeable {
int count = 0;
for (DocumentsWriterPerThread next : perThreadPool) {
if (next.isFlushPending() == false && next.getNumDocsInRAM() > 0) {
- final long nextRam = next.ramBytesUsed();
+ final long nextRam = next.getLastCommittedBytesUsed();
if (infoStream.isEnabled("FP")) {
infoStream.message("FP", "thread state has " + nextRam + " bytes; docInRAM=" + next.getNumDocsInRAM());
}
diff --git a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java
index d772a9d..d8ae375 100644
--- a/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java
+++ b/lucene/core/src/java/org/apache/lucene/index/DocumentsWriterPerThread.java
@@ -289,8 +289,8 @@ final class DocumentsWriterPerThread implements Accountable {
assert deleteSlice.isEmpty() : "all deletes must be applied in prepareFlush";
segmentInfo.setMaxDoc(numDocsInRAM);
final SegmentWriteState flushState = new SegmentWriteState(infoStream, directory, segmentInfo, fieldInfos.finish(),
- pendingUpdates, new IOContext(new FlushInfo(numDocsInRAM, ramBytesUsed())));
- final double startMBUsed = ramBytesUsed() / 1024. / 1024.;
+ pendingUpdates, new IOContext(new FlushInfo(numDocsInRAM, lastCommittedBytesUsed)));
+ final double startMBUsed = lastCommittedBytesUsed / 1024. / 1024.;
// Apply delete-by-docID now (delete-byDocID only
// happens when an exception is hit processing that
@@ -496,11 +496,13 @@ final class DocumentsWriterPerThread implements Accountable {
@Override
public long ramBytesUsed() {
+ assert lock.isHeldByCurrentThread();
return (deleteDocIDs.length * Integer.BYTES)+ pendingUpdates.ramBytesUsed() + indexingChain.ramBytesUsed();
}
@Override
public Collection<Accountable> getChildResources() {
+ assert lock.isHeldByCurrentThread();
return List.of(pendingUpdates, indexingChain);
}