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

fix: fix bind port failed on spark yarn environment #2233

Open
wants to merge 3 commits 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 @@ -140,6 +140,13 @@ abstract class BasePartitionTask extends Serializable with Logging {

try {
if (taskCtx.shouldExecuteTraining) {
//close socket before lightgbm bind port
try {
taskCtx.networkTopologyInfo.localSocket.close()
} catch {
case e: Exception => log.warn("close local bind port socket failed ")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks like its a bit generic of a error, can we make it more specific so we dont catch other errors?

}

// If participating in training, initialize the network ring of communication
NetworkManager.initLightGBMNetwork(taskCtx, log)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ case class TaskMessageInfo(status: String,

case class NetworkTopologyInfo(lightgbmNetworkString: String,
executorPartitionIdList: Array[Int],
localListenPort: Int)
localListenPort: Int,
localSocket: Socket)

object NetworkManager {
/**
Expand Down Expand Up @@ -107,19 +108,21 @@ object NetworkManager {
measures: TaskInstrumentationMeasures): NetworkTopologyInfo = {
measures.markNetworkInitializationStart()
val networkParams = ctx.networkParams
val out = using(findOpenPort(ctx, log).get) {
openPort =>
val localListenPort = openPort.getLocalPort
log.info(s"LightGBM task $taskId connecting to host: ${networkParams.ipAddress}, port: ${networkParams.port}")
FaultToleranceUtils.retryWithTimeout() {
getNetworkTopologyInfoFromDriver(networkParams,
taskId,
partitionId,
localListenPort,
log,
shouldExecuteTraining)
}
}.get
val localSocket = findOpenPort(ctx, log).get
//hold socket until lightgbm bind port
val out = ((localSocket: Socket) => {
val localListenPort = localSocket.getLocalPort
log.info(s"LightGBM task $taskId connecting to host: ${networkParams.ipAddress}, port: ${networkParams.port}")
FaultToleranceUtils.retryWithTimeout() {
getNetworkTopologyInfoFromDriver(networkParams,
taskId,
partitionId,
localListenPort,
localSocket,
log,
shouldExecuteTraining)
}
})(localSocket)
measures.markNetworkInitializationStop()
out
}
Expand All @@ -128,6 +131,7 @@ object NetworkManager {
taskId: Long,
partitionId: Int,
localListenPort: Int,
localSocket: Socket,
log: Logger,
shouldExecuteTraining: Boolean): NetworkTopologyInfo = {
using(new Socket(networkParams.ipAddress, networkParams.port)) {
Expand Down Expand Up @@ -173,7 +177,7 @@ object NetworkManager {
log.info(s"task $taskId, partition $partitionId received nodes for network init: '$lightGbmMachineList'")
val executorPartitionIds: Array[Int] =
parseExecutorPartitionList(partitionsByExecutorStr, taskStatus.executorId, log)
NetworkTopologyInfo(lightGbmMachineList, executorPartitionIds, localListenPort)
NetworkTopologyInfo(lightGbmMachineList, executorPartitionIds, localListenPort,localSocket)
}.get
}.get
}
Expand Down
Loading