-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Track queued merges in ElasticsearchMergeScheduler and InternalEngine #121794
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -41,6 +41,9 @@ public class MergeTracking { | |||||||||||||||||
private final Set<OnGoingMerge> onGoingMerges = ConcurrentCollections.newConcurrentSet(); | ||||||||||||||||||
private final Set<OnGoingMerge> readOnlyOnGoingMerges = Collections.unmodifiableSet(onGoingMerges); | ||||||||||||||||||
|
||||||||||||||||||
private final Set<OnGoingMerge> queuedMerges = ConcurrentCollections.newConcurrentSet(); | ||||||||||||||||||
private final Set<OnGoingMerge> readOnlyQueuedMerges = Collections.unmodifiableSet(queuedMerges); | ||||||||||||||||||
|
||||||||||||||||||
public MergeTracking(Logger logger, DoubleSupplier mbPerSecAutoThrottle) { | ||||||||||||||||||
this.logger = logger; | ||||||||||||||||||
this.mbPerSecAutoThrottle = mbPerSecAutoThrottle; | ||||||||||||||||||
|
@@ -50,13 +53,26 @@ public Set<OnGoingMerge> onGoingMerges() { | |||||||||||||||||
return readOnlyOnGoingMerges; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
public Set<OnGoingMerge> queuedMerges() { | ||||||||||||||||||
return readOnlyQueuedMerges; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
public void markMergeQueued(OnGoingMerge merge) { | ||||||||||||||||||
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. I do see MergeTracking being used in stateless but also in stateful (InternalEngine). So I wonder why we do not call this function also for the stateful merges? An oversight? Or is it because merges cannot be queued in stateful and they just immediately execute? If we do not mark queued merges in core ES, at least we should document it in the javadoc of 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.
In stateful merges get executed immediately in their own new thread ( Lines 136 to 143 in a8de554
Sure, I'll add a javadoc and mention that it's implementation dependant 👍 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. Oh OK thanks for explaining! Yea javadoc to maybe explain what you just said would be nice so that people know in stateful there are no queued merges. |
||||||||||||||||||
queuedMerges.add(merge); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
public void unmarkMergeQueued(OnGoingMerge merge) { | ||||||||||||||||||
queuedMerges.remove(merge); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
public void mergeStarted(OnGoingMerge onGoingMerge) { | ||||||||||||||||||
MergePolicy.OneMerge merge = onGoingMerge.getMerge(); | ||||||||||||||||||
int totalNumDocs = merge.totalNumDocs(); | ||||||||||||||||||
long totalSizeInBytes = merge.totalBytesSize(); | ||||||||||||||||||
currentMerges.inc(); | ||||||||||||||||||
currentMergesNumDocs.inc(totalNumDocs); | ||||||||||||||||||
currentMergesSizeInBytes.inc(totalSizeInBytes); | ||||||||||||||||||
unmarkMergeQueued(onGoingMerge); | ||||||||||||||||||
onGoingMerges.add(onGoingMerge); | ||||||||||||||||||
|
||||||||||||||||||
if (logger.isTraceEnabled()) { | ||||||||||||||||||
|
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.
That's an interesting idea! I guess we can piggy back on the fact that
UnmodifiableCollection
is just a shell and the changes toqueuedMerges
are guaranteed to be visible via thereadOnlyQueuedMerges
reference.