Skip to content
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

TEZ-4061: InputAttemptIdentifier and CompositeInputAttemptIdentifier cannot be compared for equality #326

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ public InputAttemptIdentifier expand(int inputIdentifierOffset) {
return new InputAttemptIdentifier(getInputIdentifier() + inputIdentifierOffset, getAttemptNumber(), getPathComponent(), isShared(), getFetchTypeInfo(), getSpillEventId());
}

public boolean include(int thatInputIdentifier, int thatAttemptNumber) {
return
super.getInputIdentifier() <= thatInputIdentifier && thatInputIdentifier < (super.getInputIdentifier() + inputIdentifierCount) &&
super.getAttemptNumber() == thatAttemptNumber;
}

// PathComponent & shared does not need to be part of the hashCode and equals computation.
@Override
public int hashCode() {
Expand All @@ -63,6 +69,6 @@ public boolean equals(Object obj) {

@Override
public String toString() {
return super.toString();
return super.toString() + ", count=" + inputIdentifierCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ public boolean canRetrieveInputInChunks() {
(fetchTypeInfo == SPILL_INFO.FINAL_UPDATE.ordinal());
}

public boolean include(int thatInputIdentifier, int thatAttemptNumber) {
return this.inputIdentifier == thatInputIdentifier && this.attemptNumber == thatAttemptNumber;
}

// PathComponent & shared does not need to be part of the hashCode and equals computation.
@Override
public int hashCode() {
Expand Down Expand Up @@ -139,6 +143,6 @@ public boolean equals(Object obj) {
public String toString() {
return "InputAttemptIdentifier [inputIdentifier=" + inputIdentifier
+ ", attemptNumber=" + attemptNumber + ", pathComponent="
+ pathComponent + ", spillType=" + fetchTypeInfo + ", spillId=" + spillEventId +"]";
+ pathComponent + ", spillType=" + fetchTypeInfo + ", spillId=" + spillEventId + "]";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ private void processShufflePayload(DataMovementEventPayloadProto shufflePayload,

private void processInputFailedEvent(InputFailedEvent ife) {
InputAttemptIdentifier srcAttemptIdentifier = new InputAttemptIdentifier(ife.getTargetIndex(), ife.getVersion());
LOG.info("Marking obsolete input: " + inputContext.getSourceVertexName() + " " + srcAttemptIdentifier);
shuffleManager.obsoleteKnownInput(srcAttemptIdentifier);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -583,8 +583,15 @@ Fetcher constructFetcherForHost(InputHost inputHost, Configuration conf) {
} else {
alreadyCompleted = completedInputSet.get(input.getInputIdentifier());
}
// Avoid adding attempts which have already completed or have been marked as OBSOLETE
if (alreadyCompleted || obsoletedInputs.contains(input)) {

// Avoid adding attempts which have already completed
if (alreadyCompleted) {
inputIter.remove();
continue;
}
// Avoid adding attempts which have been marked as OBSOLETE
if (isObsoleteInputAttemptIdentifier(input)) {
LOG.info("Skipping obsolete input: " + input);
inputIter.remove();
continue;
}
Expand Down Expand Up @@ -949,10 +956,14 @@ public void fetchFailed(String host,
// TODO NEWTEZ. Implement logic to report fetch failures after a threshold.
// For now, reporting immediately.
InputAttemptIdentifier srcAttemptIdentifier = inputAttemptFetchFailure.getInputAttemptIdentifier();
if (isObsoleteInputAttemptIdentifier(srcAttemptIdentifier)) {
LOG.info("Do not report obsolete input: " + srcAttemptIdentifier);
return;
}
LOG.info(
"{}: Fetch failed for src: {} InputIdentifier: {}, connectFailed: {}, "
"{}: Fetch failed for InputIdentifier: {}, connectFailed: {}, "
+ "local fetch: {}, remote fetch failure reported as local failure: {})",
sourceDestNameTrimmed, srcAttemptIdentifier, srcAttemptIdentifier, connectFailed,
sourceDestNameTrimmed, srcAttemptIdentifier, connectFailed,
inputAttemptFetchFailure.isLocalFetch(), inputAttemptFetchFailure.isDiskErrorAtSource());
failedShufflesCounter.increment(1);
inputContext.notifyProgress();
Expand Down Expand Up @@ -984,6 +995,22 @@ public void fetchFailed(String host,
}
}
}

private boolean isObsoleteInputAttemptIdentifier(InputAttemptIdentifier input) {
if (input == null) {
return false;
}
InputAttemptIdentifier obsoleteInput;
Iterator<InputAttemptIdentifier> obsoleteInputsIter = obsoletedInputs.iterator();
while (obsoleteInputsIter.hasNext()) {
obsoleteInput = obsoleteInputsIter.next();
if (input.include(obsoleteInput.getInputIdentifier(), obsoleteInput.getAttemptNumber())) {
return true;
}
}
return false;
}

/////////////////// End of Methods from FetcherCallbackHandler

public void shutdown() throws InterruptedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,19 @@ private synchronized boolean inputShouldBeConsumed(InputAttemptIdentifier id) {
} else {
isInputFinished = isInputFinished(id.getInputIdentifier());
}
return !obsoleteInputs.contains(id) && !isInputFinished;
return !isObsoleteInputAttemptIdentifier(id) && !isInputFinished;
}

private boolean isObsoleteInputAttemptIdentifier(InputAttemptIdentifier input) {
InputAttemptIdentifier obsoleteInput;
Iterator<InputAttemptIdentifier> obsoleteInputsIter = obsoleteInputs.iterator();
while (obsoleteInputsIter.hasNext()) {
obsoleteInput = obsoleteInputsIter.next();
if (input.include(obsoleteInput.getInputIdentifier(), obsoleteInput.getAttemptNumber())) {
return true;
}
}
return false;
}

public synchronized List<InputAttemptIdentifier> getMapsForHost(MapHost host) {
Expand Down