spark-test commented on code in PR #58619:
URL: https://github.com/apache/spark/pull/58619#discussion_r4583558061
##########
core/src/main/scala/org/apache/spark/deploy/worker/Worker.scala:
##########
@@ -767,6 +751,38 @@ private[deploy] class Worker(
registerWithMaster()
}
+ private[deploy] def createExecutorLocalDirs(appId: String): Seq[String] = {
+ val localRootDirs = Utils.getOrCreateLocalRootDirs(conf)
+ val dirs = localRootDirs.flatMap { dir =>
+ try {
+ // Keep the random root and executor directories (and their
shutdown-hook cleanup),
+ // adding a URL-encoded app id leaf for the shuffle service's
app-scope check.
+ val executorDir = Utils.createDirectory(dir, namePrefix = "executor")
+ try {
+ val appDir = new File(executorDir, URLEncoder.encode(appId,
StandardCharsets.UTF_8))
Review Comment:
**Non-blocking (P2):** `URLEncoder` leaves `.` unchanged and
`spark.deploy.appIdPattern` is only checked for whitespace, so an application
ID of exactly `..` (application number 46 under the pattern `.%2$c`, for
example) turns this leaf into `<root>/spark-x/executor-y/..`, which is the
Worker's shared `spark-*` root. `Utils.createDirectory` accepts it because the
directory already exists, and the executors then create their `blockmgr-*` dirs
directly in `spark-x`. When the application finishes, `rm -rf` refuses the `..`
path, so `JavaUtils.deleteRecursively` falls back to deleting each child of
`spark-x`. Every child the listing returns before this application's own
`executor-*` directory is removed, including other applications' `executor-*`
directories with their shuffle files and cached blocks, so those applications
hit fetch and task failures and have to recompute. Replaying these system calls
in a scratch directory (no JDK was available for a Java repro) deleted another
appli
cation's `executor-a` directory this way, while the base branch's layout and
an ordinary leaf left it intact.
An ID of exactly `.` makes the leaf the executor directory itself. Cleanup
empties it but cannot remove a path that ends in `.`, so it fails with `Failed
to delete`, leaves the executor directory behind, and skips the application's
directories on the Worker's remaining local roots. Both cases happen whether or
not `spark.shuffle.service.requireAppScopedLocalDirs` is enabled. No realistic
pattern produces these IDs, but nothing rejects them.
Escaping the two dot segments after URL-encoding, here and where
`LocalDirValidator` computes the expected leaf (`.` becomes `%2E` and `..`
becomes `%2E%2E`), keeps every leaf a new child of the executor directory.
`URLEncoder` never emits `%2E`: it leaves `.` as is and encodes a literal `%`
as `%25`, so the escaped names can't collide with another ID's leaf, and every
other ID keeps its current name.
This extends an [existing
discussion](https://github.com/apache/spark/pull/58619#discussion_r4109073686).
**Verification:**
- **Regression:** With an application ID of exactly `..`, the Worker's
local-dir helper returns a new child of a fresh `executor-*` directory rather
than the `spark-*` root, and finishing that application removes that directory
and its empty executor directory while another application's directory under
the same `spark-*` root survives.
- **Regression:** With an application ID of exactly `.` and two local roots,
the helper returns a new child of a fresh `executor-*` directory on each root,
and finishing the application removes every such child and its executor
directory, leaving no empty executor directory behind on either root.
- **Compatibility:** With app scoping on, a `blockmgr-*` directory created
below the Worker's leaf for `..` is accepted by the shuffle service's local-dir
check for `..` and rejected for another application ID, so the Worker and the
check agree on the escaped name.
- **Compatibility:** The Worker's leaf name and the check's expected name
stay unchanged for the default application ID form, for an ID containing `:`
and `/`, and for an ID that contains dots but is not exactly `.` or `..`, such
as `...` or `app.1`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]