-
Notifications
You must be signed in to change notification settings - Fork 440
TEZ-4231: SimpleHistoryParser doesn't merge events correctly #123
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
Merged
Merged
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
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
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
132 changes: 132 additions & 0 deletions
132
...yzers/job-analyzer/src/main/java/org/apache/tez/analyzer/plugins/DagOverviewAnalyzer.java
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 |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * <p/> | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * <p/> | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package org.apache.tez.analyzer.plugins; | ||
|
|
||
| import java.text.SimpleDateFormat; | ||
| import java.util.Comparator; | ||
| import java.util.Date; | ||
|
|
||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.util.ToolRunner; | ||
| import org.apache.tez.analyzer.Analyzer; | ||
| import org.apache.tez.analyzer.CSVResult; | ||
| import org.apache.tez.analyzer.Result; | ||
| import org.apache.tez.dag.api.TezException; | ||
| import org.apache.tez.history.parser.datamodel.DagInfo; | ||
| import org.apache.tez.history.parser.datamodel.Event; | ||
| import org.apache.tez.history.parser.datamodel.TaskAttemptInfo; | ||
| import org.apache.tez.history.parser.datamodel.TaskInfo; | ||
| import org.apache.tez.history.parser.datamodel.VertexInfo; | ||
|
|
||
| public class DagOverviewAnalyzer extends TezAnalyzerBase implements Analyzer { | ||
| private final String[] headers = | ||
| { "name", "id", "event_type", "status", "event_time", "event_time_str", "vertex_task_stats", "diagnostics" }; | ||
| private final CSVResult csvResult; | ||
| private static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); | ||
|
|
||
| public DagOverviewAnalyzer(Configuration config) { | ||
| super(config); | ||
| csvResult = new CSVResult(headers); | ||
| } | ||
|
|
||
| @Override | ||
| public void analyze(DagInfo dagInfo) throws TezException { | ||
| for (Event event : dagInfo.getEvents()) { | ||
| csvResult.addRecord(new String[] { dagInfo.getDagId(), dagInfo.getDagId(), event.getType(), | ||
| dagInfo.getStatus(), Long.toString(event.getTime()), toDateStr(event.getTime()), "", "" }); | ||
| } | ||
| for (VertexInfo vertex : dagInfo.getVertices()) { | ||
| for (Event event : vertex.getEvents()) { | ||
| String vertexFailureInfoIfAny = ""; | ||
| for (TaskAttemptInfo attempt : vertex.getTaskAttempts()) { | ||
| if (attempt.getStatus().contains("FAILED")) { | ||
| vertexFailureInfoIfAny = attempt.getTaskAttemptId() + ": " | ||
| + attempt.getDiagnostics().replaceAll(",", " ").replaceAll("\n", " "); | ||
| break; | ||
| } | ||
| } | ||
| csvResult.addRecord(new String[] { vertex.getVertexName(), vertex.getVertexId(), | ||
| event.getType(), vertex.getStatus(), Long.toString(event.getTime()), | ||
| toDateStr(event.getTime()), getTaskStats(vertex), vertexFailureInfoIfAny }); | ||
| } | ||
|
|
||
| // a failed task can lead to dag failure, so hopefully holds valuable information | ||
| for (TaskInfo failedTask : vertex.getFailedTasks()) { | ||
| for (Event failedTaskEvent : failedTask.getEvents()) { | ||
| if (failedTaskEvent.getType().equalsIgnoreCase("TASK_FINISHED")) { | ||
| csvResult.addRecord(new String[] { vertex.getVertexName(), failedTask.getTaskId(), | ||
| failedTaskEvent.getType(), failedTask.getStatus(), Long.toString(failedTaskEvent.getTime()), | ||
| toDateStr(failedTaskEvent.getTime()), getTaskStats(vertex), | ||
| failedTask.getDiagnostics().replaceAll(",", " ").replaceAll("\n", " ") }); | ||
| } | ||
| } | ||
| // if we already found a failing task, let's scan the failing attempts as well | ||
| for (TaskAttemptInfo failedAttempt : failedTask.getFailedTaskAttempts()) { | ||
| for (Event failedTaskAttemptEvent : failedAttempt.getEvents()) { | ||
| if (failedTaskAttemptEvent.getType().equalsIgnoreCase("TASK_ATTEMPT_FINISHED")) { | ||
| csvResult.addRecord(new String[] { vertex.getVertexName(), | ||
| failedAttempt.getTaskAttemptId(), failedTaskAttemptEvent.getType(), | ||
| failedAttempt.getStatus(), Long.toString(failedTaskAttemptEvent.getTime()), | ||
| toDateStr(failedTaskAttemptEvent.getTime()), getTaskStats(vertex), | ||
| failedAttempt.getDiagnostics().replaceAll(",", " ").replaceAll("\n", " ") }); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| csvResult.sort(new Comparator<String[]>() { | ||
| public int compare(String[] first, String[] second) { | ||
| return (int) (Long.parseLong(first[4]) - Long.parseLong(second[4])); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| private String getTaskStats(VertexInfo vertex) { | ||
| return String.format("numTasks: %d failedTasks: %d completedTasks: %d", vertex.getNumTasks(), | ||
| vertex.getFailedTasksCount(), vertex.getCompletedTasksCount()); | ||
| } | ||
|
|
||
| private static synchronized String toDateStr(long time) { | ||
| return FORMAT.format(new Date(time)); | ||
| } | ||
|
|
||
| @Override | ||
| public Result getResult() throws TezException { | ||
| return csvResult; | ||
| } | ||
|
|
||
| @Override | ||
| public String getName() { | ||
| return "Dag overview analyzer"; | ||
| } | ||
|
|
||
| @Override | ||
| public String getDescription() { | ||
| return "High level dag events overview (dag, vertex event summary)." | ||
| + " Helps understand the overall progress of a dag by simply listing the dag/vertex related events"; | ||
| } | ||
|
|
||
| public static void main(String[] args) throws Exception { | ||
| Configuration config = new Configuration(); | ||
| DagOverviewAnalyzer analyzer = new DagOverviewAnalyzer(config); | ||
| int res = ToolRunner.run(config, analyzer, args); | ||
| analyzer.printResults(); | ||
| System.exit(res); | ||
| } | ||
| } |
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.
IIRC, there were corner cases where events will not be properly populated. May be in cases, where vertices were shutdown due to errors or so (need to check).
In such cases, this would have returned "-ve" value earlier.
Current patch seem to change the start_time, depending on getEventTime. This could give a perspective that the task/vertex was there for very short time.
Can you plz share more info on prev error? Were you getting -ve values earlier for which this is being modified?
Uh oh!
There was an error while loading. Please reload this page.
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.
actually, I saw this for all protobuf history files, that's why I'm not suspecting corner case
I found that in case of a TASK_FINISHED finished event, there is always an event time (which is the end time obviously) and timeTaken in event_data, but there is no startTime there
this string is what the debugger writes for a HistoryLoggerProtos$HistoryEventProto instance while doing this conversion:
the root cause of this behavior would be:
https://github.com/apache/tez/blob/master/tez-plugins/tez-protobuf-history-plugin/src/main/java/org/apache/tez/dag/history/logging/proto/HistoryEventProtoConverter.java#L392
here I can see the builder consumes only event.getFinishTime() for the "time" parameter, and startTime is shipped indirectly...according to blame, this code part is unchanged since the introduction of proto history logger (TEZ-3915)
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.
Thanks for the note. Earlier code didn't populate START_TIME (& had only timeTaken) causing the issue.