New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Shards with heavy indexing should get more of the indexing buffer #14121
Merged
Merged
Changes from 6 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
b3357f0
a start
mikemccand 6ae8ca9
put back active/inactive logic, for sync'd flush
mikemccand 1b9e9ed
fix failing test
mikemccand 77c2445
don't call IMC.forceCheck when going active; remove nocommit/sops
mikemccand 4639657
Merge branch 'master' into fair_indexing_buffers
mikemccand 0a2a7f2
set active to true on indexing ops
mikemccand c66b05d
force check after X bytes indexed
mikemccand 99e328c
remove 'white lie' and tracking refreshing bytes explicitly
mikemccand 27d8509
merged master
mikemccand 86a0dd0
use IW.flush to move bytes to disk
mikemccand 330bc5b
trigger index throttling if writing indexing buffers to disk can't ke…
mikemccand 52c092e
pull out constant for default 5 minute idle setting
mikemccand ed5c0e7
factor out exception handling cases
mikemccand 319dc8c
remove dead code; get one test working again; fix docs; remove nocommits
mikemccand cbb6463
add throttling test case
mikemccand 485f417
a few cleanups
mikemccand 99d6ec5
fold in feedback
mikemccand 1d46a00
move async-ness upwards
mikemccand 5f4afe8
remove nocommits; fix test case
mikemccand 3744fb9
merge master
mikemccand db832cc
improve logging messages a bit
mikemccand f3de778
merge master
mikemccand 5e7144f
IMC is now just another IndexingOperationListener
mikemccand 07e8370
feedback
mikemccand File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,6 +102,8 @@ public class InternalEngine extends Engine { | |
|
||
private volatile SegmentInfos lastCommittedSegmentInfos; | ||
|
||
private volatile boolean refreshing; | ||
|
||
private final IndexThrottle throttle; | ||
|
||
public InternalEngine(EngineConfig engineConfig, boolean skipInitialTranslogRecovery) throws EngineException { | ||
|
@@ -296,7 +298,6 @@ private SearcherManager createSearcherManager() throws EngineException { | |
private void updateIndexWriterSettings() { | ||
try { | ||
final LiveIndexWriterConfig iwc = indexWriter.getConfig(); | ||
iwc.setRAMBufferSizeMB(engineConfig.getIndexingBufferSize().mbFrac()); | ||
iwc.setUseCompoundFile(engineConfig.isCompoundOnFlush()); | ||
} catch (AlreadyClosedException ex) { | ||
// ignore | ||
|
@@ -347,7 +348,6 @@ public boolean index(Index index) { | |
maybeFailEngine("index", t); | ||
throw new IndexFailedEngineException(shardId, index.type(), index.id(), t); | ||
} | ||
checkVersionMapRefresh(); | ||
return created; | ||
} | ||
|
||
|
@@ -412,33 +412,6 @@ private boolean innerIndex(Index index) throws IOException { | |
} | ||
} | ||
|
||
/** | ||
* Forces a refresh if the versionMap is using too much RAM | ||
*/ | ||
private void checkVersionMapRefresh() { | ||
if (versionMap.ramBytesUsedForRefresh() > config().getVersionMapSize().bytes() && versionMapRefreshPending.getAndSet(true) == false) { | ||
try { | ||
if (isClosed.get()) { | ||
// no point... | ||
return; | ||
} | ||
// Now refresh to clear versionMap: | ||
engineConfig.getThreadPool().executor(ThreadPool.Names.REFRESH).execute(new Runnable() { | ||
@Override | ||
public void run() { | ||
try { | ||
refresh("version_table_full"); | ||
} catch (EngineClosedException ex) { | ||
// ignore | ||
} | ||
} | ||
}); | ||
} catch (EsRejectedExecutionException ex) { | ||
// that is fine too.. we might be shutting down | ||
} | ||
} | ||
} | ||
|
||
@Override | ||
public void delete(Delete delete) throws EngineException { | ||
try (ReleasableLock lock = readLock.acquire()) { | ||
|
@@ -451,7 +424,6 @@ public void delete(Delete delete) throws EngineException { | |
} | ||
|
||
maybePruneDeletedTombstones(); | ||
checkVersionMapRefresh(); | ||
} | ||
|
||
private void maybePruneDeletedTombstones() { | ||
|
@@ -517,6 +489,7 @@ public void refresh(String source) throws EngineException { | |
// since it flushes the index as well (though, in terms of concurrency, we are allowed to do it) | ||
try (ReleasableLock lock = readLock.acquire()) { | ||
ensureOpen(); | ||
refreshing = true; | ||
searcherManager.maybeRefreshBlocking(); | ||
} catch (AlreadyClosedException e) { | ||
ensureOpen(); | ||
|
@@ -526,6 +499,8 @@ public void refresh(String source) throws EngineException { | |
} catch (Throwable t) { | ||
failEngine("refresh failed", t); | ||
throw new RefreshFailedEngineException(shardId, t); | ||
} finally { | ||
refreshing = false; | ||
} | ||
|
||
// TODO: maybe we should just put a scheduled job in threadPool? | ||
|
@@ -783,8 +758,12 @@ protected final void writerSegmentStats(SegmentsStats stats) { | |
} | ||
|
||
@Override | ||
public long indexWriterRAMBytesUsed() { | ||
return indexWriter.ramBytesUsed(); | ||
public long indexBufferRAMBytesUsed() { | ||
if (refreshing) { | ||
return 0; | ||
} else { | ||
return indexWriter.ramBytesUsed() + versionMap.ramBytesUsedForRefresh(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. watch out this can throw a |
||
} | ||
} | ||
|
||
@Override | ||
|
@@ -1107,8 +1086,6 @@ private void commitIndexWriter(IndexWriter writer, Translog translog) throws IOE | |
public void onSettingsChanged() { | ||
mergeScheduler.refreshConfig(); | ||
updateIndexWriterSettings(); | ||
// config().getVersionMapSize() may have changed: | ||
checkVersionMapRefresh(); | ||
// config().isEnableGcDeletes() or config.getGcDeletesInMillis() may have changed: | ||
maybePruneDeletedTombstones(); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good! :)