-
Notifications
You must be signed in to change notification settings - Fork 479
Simplifies warn logging about inactive queues in the coordinator. #6236
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
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -117,6 +117,7 @@ | |
| import org.apache.accumulo.core.tabletserver.thrift.TCompactionKind; | ||
| import org.apache.accumulo.core.tabletserver.thrift.TCompactionStats; | ||
| import org.apache.accumulo.core.tabletserver.thrift.TExternalCompactionJob; | ||
| import org.apache.accumulo.core.util.Timer; | ||
| import org.apache.accumulo.core.util.cache.Caches.CacheName; | ||
| import org.apache.accumulo.core.util.compaction.CompactionPlannerInitParams; | ||
| import org.apache.accumulo.core.util.compaction.CompactionServicesConfig; | ||
|
|
@@ -207,9 +208,6 @@ static FailureCounts incrementSuccess(Object key, FailureCounts counts) { | |
| protected final Map<ExternalCompactionId,TExternalCompaction> RUNNING_CACHE = | ||
| new ConcurrentHashMap<>(); | ||
|
|
||
| /* Map of group name to last time compactor called to get a compaction job */ | ||
| private final Map<ResourceGroupId,Long> TIME_COMPACTOR_LAST_CHECKED = new ConcurrentHashMap<>(); | ||
|
|
||
| private final ServerContext ctx; | ||
| private final AuditedSecurityOperation security; | ||
| private final CompactionJobQueues jobQueues; | ||
|
|
@@ -382,30 +380,6 @@ public void run() { | |
| LOG.info("Shutting down"); | ||
| } | ||
|
|
||
| private Map<String,Set<HostAndPort>> getIdleCompactors(Set<ServerId> runningCompactors) { | ||
|
|
||
| final Map<String,Set<HostAndPort>> allCompactors = new HashMap<>(); | ||
| runningCompactors.forEach((csi) -> allCompactors | ||
| .computeIfAbsent(csi.getResourceGroup().canonical(), (k) -> new HashSet<>()) | ||
| .add(HostAndPort.fromParts(csi.getHost(), csi.getPort()))); | ||
|
|
||
| final Set<String> emptyQueues = new HashSet<>(); | ||
|
|
||
| // Remove all of the compactors that are running a compaction | ||
| RUNNING_CACHE.values().forEach(tec -> { | ||
| Set<HostAndPort> busyCompactors = allCompactors.get(tec.getGroupName()); | ||
| if (busyCompactors != null | ||
| && busyCompactors.remove(HostAndPort.fromString(tec.getCompactor()))) { | ||
| if (busyCompactors.isEmpty()) { | ||
| emptyQueues.add(tec.getGroupName()); | ||
| } | ||
| } | ||
| }); | ||
| // Remove entries with empty queues | ||
| emptyQueues.forEach(e -> allCompactors.remove(e)); | ||
| return allCompactors; | ||
| } | ||
|
|
||
| protected void startDeadCompactionDetector() { | ||
| deadCompactionDetector.start(); | ||
| } | ||
|
|
@@ -414,10 +388,6 @@ protected long getMissingCompactorWarningTime() { | |
| return this.ctx.getConfiguration().getTimeInMillis(Property.COMPACTOR_MAX_JOB_WAIT_TIME) * 3; | ||
| } | ||
|
|
||
| public long getNumRunningCompactions() { | ||
| return RUNNING_CACHE.size(); | ||
| } | ||
|
|
||
| /** | ||
| * Return the next compaction job from the queue to a Compactor | ||
| * | ||
|
|
@@ -438,7 +408,6 @@ public TNextCompactionJob getCompactionJob(TInfo tinfo, TCredentials credentials | |
| } | ||
| ResourceGroupId groupId = ResourceGroupId.of(groupName); | ||
| LOG.trace("getCompactionJob called for group {} by compactor {}", groupId, compactorAddress); | ||
| TIME_COMPACTOR_LAST_CHECKED.put(groupId, System.currentTimeMillis()); | ||
|
|
||
| TExternalCompactionJob result = null; | ||
|
|
||
|
|
@@ -1203,17 +1172,46 @@ private Set<ResourceGroupId> getCompactionServicesConfigurationGroups() | |
| return groups; | ||
| } | ||
|
|
||
| record DequeuedSample(Timer timer, long dequeuedCount) { | ||
| } | ||
|
|
||
| // Used to track how long a resource groups dequeued count is the same. | ||
| private final Map<ResourceGroupId,DequeuedSample> dequeuedCountTracker = | ||
| Collections.synchronizedMap(new HashMap<>()); | ||
|
|
||
| private void logNonEmptyQueuesThatAreInactive() { | ||
| dequeuedCountTracker.keySet().retainAll(jobQueues.getQueueIds()); | ||
|
|
||
| Duration warnDuration = Duration.ofMillis(getMissingCompactorWarningTime()); | ||
|
|
||
| for (var rgid : jobQueues.getQueueIds()) { | ||
| var last = dequeuedCountTracker.get(rgid); | ||
| long dequeued = jobQueues.getDequeuedJobs(rgid); | ||
| if (last == null || last.dequeuedCount != dequeued) { | ||
| dequeuedCountTracker.put(rgid, new DequeuedSample(Timer.startNew(), dequeued)); | ||
| continue; | ||
| } | ||
|
|
||
| Duration notEmptyDuration = jobQueues.getNotEmptyDuration(rgid); | ||
| if (last.timer.elapsed().compareTo(warnDuration) > 0 | ||
| && notEmptyDuration.compareTo(warnDuration) > 0) { | ||
| // This queue has been non empty and nothing has been dequeued from it for greater than the | ||
| // warn duration. | ||
| LOG.warn( | ||
| "Compactor group {} has {} queued jobs, has had queued jobs for {}ms, and nothing was dequeued for {}ms", | ||
| rgid, jobQueues.getQueuedJobs(rgid), notEmptyDuration.toMillis(), | ||
| last.timer.elapsed(TimeUnit.MILLISECONDS)); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public void cleanUpInternalState() { | ||
|
|
||
| // This method does the following: | ||
| // | ||
| // 1. Removes entries from RUNNING_CACHE and LONG_RUNNING_COMPACTIONS_BY_RG that are not really | ||
| // running | ||
| // 1. Removes entries from RUNNING_CACHE that are not really running | ||
| // 2. Cancels running compactions for groups that are not in the current configuration | ||
| // 3. Remove groups not in configuration from TIME_COMPACTOR_LAST_CHECKED | ||
| // 4. Log groups with no compactors | ||
|
Contributor
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 think this is useful. We might be able to add it to the Monitor as one of the suggestions / problems. |
||
| // 5. Log compactors with no groups | ||
| // 6. Log groups with compactors and queued jos that have not checked in | ||
|
|
||
| var config = ctx.getConfiguration(); | ||
| ThreadPools.resizePool(reservationPools.get(DataLevel.ROOT), config, | ||
|
|
@@ -1269,11 +1267,6 @@ public void cleanUpInternalState() { | |
| cancelCompactionOnCompactor(tec.getCompactor(), tec.getJob().getExternalCompactionId()); | ||
| } | ||
| }); | ||
|
|
||
| final Set<ResourceGroupId> trackedGroups = Set.copyOf(TIME_COMPACTOR_LAST_CHECKED.keySet()); | ||
| TIME_COMPACTOR_LAST_CHECKED.keySet().retainAll(groupsInConfiguration); | ||
| LOG.debug("No longer tracking compactor check-in times for groups: {}", | ||
| Sets.difference(trackedGroups, TIME_COMPACTOR_LAST_CHECKED.keySet())); | ||
| } | ||
|
|
||
| final Set<ServerId> runningCompactors = getRunningCompactors(); | ||
|
|
@@ -1282,18 +1275,6 @@ public void cleanUpInternalState() { | |
| runningCompactors.forEach( | ||
| c -> runningCompactorGroups.add(ResourceGroupId.of(c.getResourceGroup().canonical()))); | ||
|
|
||
| final Set<ResourceGroupId> groupsWithNoCompactors = | ||
| Sets.difference(groupsInConfiguration, runningCompactorGroups); | ||
| if (groupsWithNoCompactors != null && !groupsWithNoCompactors.isEmpty()) { | ||
| for (ResourceGroupId group : groupsWithNoCompactors) { | ||
| long queuedJobCount = jobQueues.getQueuedJobs(group); | ||
| if (queuedJobCount > 0) { | ||
| LOG.warn("Compactor group {} has {} queued compactions but no running compactors", group, | ||
| queuedJobCount); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| final Set<ResourceGroupId> compactorsWithNoGroups = | ||
| Sets.difference(runningCompactorGroups, groupsInConfiguration); | ||
| if (compactorsWithNoGroups != null && !compactorsWithNoGroups.isEmpty()) { | ||
|
|
@@ -1302,19 +1283,6 @@ public void cleanUpInternalState() { | |
| compactorsWithNoGroups); | ||
| } | ||
|
|
||
| final long now = System.currentTimeMillis(); | ||
| final long warningTime = getMissingCompactorWarningTime(); | ||
| Map<String,Set<HostAndPort>> idleCompactors = getIdleCompactors(runningCompactors); | ||
| for (ResourceGroupId groupName : groupsInConfiguration) { | ||
| long lastCheckTime = | ||
| TIME_COMPACTOR_LAST_CHECKED.getOrDefault(groupName, coordinatorStartTime); | ||
| if ((now - lastCheckTime) > warningTime && jobQueues.getQueuedJobs(groupName) > 0 | ||
| && idleCompactors.containsKey(groupName.canonical())) { | ||
| LOG.warn( | ||
| "The group {} has queued jobs and {} idle compactors, however none have checked in " | ||
| + "with coordinator for {}ms", | ||
| groupName, idleCompactors.get(groupName.canonical()).size(), warningTime); | ||
| } | ||
| } | ||
| logNonEmptyQueuesThatAreInactive(); | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
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.
I think this message is a little different than the one it's replacing. This just says that nothing has been dequeued for some amount of time, but says nothing about the compactors. This could be normal if all of the compactors are busy running long compactions. The message this is replacing indicates that something is wrong because there are idle compactors in the group.
I wonder if this should move to the Monitor as well.
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.
Oh yeah, do not want to warn for the case when the queue is inactive because of lots of long running compactions. Moving it to the monitor sounds good to me. Can close this PR out.