Skip to content

Commit

Permalink
Core: don't block shard stats when phase 3 of recovery is running
Browse files Browse the repository at this point in the history
Today, shard stats are blocked while phase 3 of recovery (replay xlog)
is running; this change removes the engine readLock from shard stats
so it's not blocked.

Closes #8910
  • Loading branch information
mikemccand committed Dec 12, 2014
1 parent 8a445fd commit 35e848d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
Expand Up @@ -340,7 +340,7 @@ public ShardId shardId() {

@Override
public TimeValue defaultRefreshInterval() {
return InternalEngineHolder.DEFAULT_REFRESH_ITERVAL;
return InternalEngineHolder.DEFAULT_REFRESH_INTERVAL;
}

/** return the current indexing buffer size setting * */
Expand Down Expand Up @@ -1239,9 +1239,12 @@ private static long getReaderRamBytesUsed(AtomicReaderContext reader) {

@Override
public SegmentsStats segmentsStats() {
try (InternalLock _ = readLock.acquire()) {
ensureOpen();
try (final Searcher searcher = acquireSearcher("segments_stats")) {

// Does ensureOpen for us:
final IndexWriter indexWriter = currentIndexWriter();
assert indexWriter != null;

try (final Searcher searcher = acquireSearcher("segments_stats")) {
SegmentsStats stats = new SegmentsStats();
for (AtomicReaderContext reader : searcher.reader().leaves()) {
stats.add(1, getReaderRamBytesUsed(reader));
Expand All @@ -1250,7 +1253,6 @@ public SegmentsStats segmentsStats() {
stats.addIndexWriterMemoryInBytes(indexWriter.ramBytesUsed());
stats.addIndexWriterMaxMemoryInBytes((long) (indexWriter.getConfig().getRAMBufferSizeMB() * 1024 * 1024));
return stats;
}
}
}

Expand Down
Expand Up @@ -103,7 +103,7 @@ public class InternalEngineHolder extends AbstractIndexShardComponent implements
public static final String INDEX_CHECKSUM_ON_MERGE = "index.checksum_on_merge";
public static final String INDEX_FAIL_ON_CORRUPTION = "index.fail_on_corruption";

public static final TimeValue DEFAULT_REFRESH_ITERVAL = new TimeValue(1, TimeUnit.SECONDS);
public static final TimeValue DEFAULT_REFRESH_INTERVAL = new TimeValue(1, TimeUnit.SECONDS);

private final CopyOnWriteArrayList<FailedEngineListener> failedEngineListeners = new CopyOnWriteArrayList<>();

Expand Down Expand Up @@ -152,7 +152,7 @@ public InternalEngineHolder(ShardId shardId, @IndexSettings Settings indexSettin

@Override
public TimeValue defaultRefreshInterval() {
return DEFAULT_REFRESH_ITERVAL;
return DEFAULT_REFRESH_INTERVAL;
}


Expand Down

0 comments on commit 35e848d

Please sign in to comment.