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

Set min replicate to 0 and unpin file i...; Port [#17865] to branch-2.10 #17867

Merged
Merged
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 @@ -20,6 +20,7 @@
import alluxio.conf.Configuration;
import alluxio.exception.status.NotFoundException;
import alluxio.grpc.RemoveBlockRequest;
import alluxio.grpc.SetAttributePOptions;
import alluxio.job.RunTaskContext;
import alluxio.job.SelectExecutorsContext;
import alluxio.job.plan.AbstractVoidPlanDefinition;
Expand All @@ -37,6 +38,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.Collections;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -168,8 +170,25 @@ private void replicate(SetReplicaConfig config, RunTaskContext context) throws E
// to avoid the the race between "replicate" and "rename", so that even a file to replicate is
// renamed, the job is still working on the correct file.
URIStatus status = context.getFileSystem().getStatus(new AlluxioURI(config.getPath()));

JobUtils.loadBlock(status, context.getFsContext(), config.getBlockId(), null, false);
try {
JobUtils.loadBlock(status, context.getFsContext(), config.getBlockId(), null, false);
} catch (IOException e) {
// This will remove the file from the pinlist if it fails to replicate, there can be false
// positives because replication can fail transiently and this would unpin it. However,
// compared to repeatedly replicating, this is a more acceptable result.
LOG.warn("Replication of {} failed, reduce min replication to 0 and unpin. Reason: {} ",
status.getPath(), e.getMessage());
SetAttributePOptions.Builder optionsBuilder =
SetAttributePOptions.newBuilder();
try {
context.getFileSystem().setAttribute(new AlluxioURI(config.getPath()),
optionsBuilder.setReplicationMin(0).setPinned(false).build());
} catch (Throwable e2) {
e.addSuppressed(e2);
LOG.warn("Attempt to set min replication to 0 and unpin failed due to ", e2);
}
throw e;
}
LOG.info("Replicated file " + config.getPath() + " block " + config.getBlockId());
}
}
Loading