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

Add domain socket max path length check #18015

Open
wants to merge 1 commit into
base: master-2.x
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
11 changes: 11 additions & 0 deletions core/common/src/main/java/alluxio/util/OSUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ public final class OSUtils {
public static final String JAVA_VENDOR_NAME = System.getProperty("java.vendor");
/** Indicates the current java vendor is IBM java or not. */
public static final boolean IBM_JAVA = JAVA_VENDOR_NAME.contains("IBM");
/** The maximum path length supported by a domain socket on unix varies depending on the
* operating system. The conservative limit is returned here.
* */
public static final int UNIX_SOCKET_MAX_PATH_LENGTH = 100;

/**
* @return true if current processor is 64 bit
Expand Down Expand Up @@ -64,5 +68,12 @@ public static boolean isAIX() {
return OSUtils.OS_NAME.equals("AIX");
}

/***
* @return the maximum path length supported by a domain socket on unix
*/
public static int getDomainSocketMaxPathLength() {
return OSUtils.UNIX_SOCKET_MAX_PATH_LENGTH;
}

private OSUtils() {} // prevent instantiation
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import alluxio.underfs.WorkerUfsManager;
import alluxio.util.CommonUtils;
import alluxio.util.JvmPauseMonitor;
import alluxio.util.OSUtils;
import alluxio.util.WaitForOptions;
import alluxio.util.io.FileUtils;
import alluxio.util.io.PathUtils;
Expand All @@ -33,6 +34,7 @@
import alluxio.worker.block.BlockWorker;
import alluxio.worker.grpc.GrpcDataServer;

import com.google.common.base.Preconditions;
import io.netty.channel.unix.DomainSocketAddress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -144,6 +146,9 @@ public final class AlluxioWorkerProcess implements WorkerProcess {
domainSocketPath =
PathUtils.concatPath(domainSocketPath, UUID.randomUUID().toString());
}
Preconditions.checkState(domainSocketPath.length() < OSUtils.getDomainSocketMaxPathLength(),
"The longest domain socket path possible on this host is %d bytes.",
OSUtils.getDomainSocketMaxPathLength());
LOG.info("Domain socket data server is enabled at {}.", domainSocketPath);
mDomainSocketDataServer = new GrpcDataServer(mRpcConnectAddress.getHostName(),
new DomainSocketAddress(domainSocketPath), this);
Expand Down
Loading