Skip to content

[SPARK-57949][PYTHON][TESTS] Use shortest temp base for direct-worker UDS path to fix macOS AF_UNIX path too long#57028

Closed
HyukjinKwon wants to merge 1 commit into
apache:masterfrom
HyukjinKwon:ci-fix/agent4-macos-uds-path-pr
Closed

[SPARK-57949][PYTHON][TESTS] Use shortest temp base for direct-worker UDS path to fix macOS AF_UNIX path too long#57028
HyukjinKwon wants to merge 1 commit into
apache:masterfrom
HyukjinKwon:ci-fix/agent4-macos-uds-path-pr

Conversation

@HyukjinKwon

Copy link
Copy Markdown
Member

What changes were proposed in this pull request?

TestDirectWorkerDispatcher.shortTempBase (in TestDirectWorkerHelpers.scala) chooses a
base directory for the direct-worker Unix-domain socket by taking the first writable
entry among $TMPDIR, $TEMP, $TMP, /tmp. This PR changes it to pick the shortest
usable base, measured by its real (symlink-resolved) path.

Why are the changes needed?

On macOS, $TMPDIR is a long per-user path like
/var/folders/k8/j7r3p6cx43xdqhzy2rmp6tqr0000gn/T/ (~49 chars). Combined with the
createTempDirectory random suffix and the w-<id>.sock leaf, the bound socket path
exceeds the 104-byte macOS sun_path limit, so PythonUDFWorkerSpecificationSuite
fails with:

OSError: AF_UNIX path too long
  at ...TestDirectWorkerDispatcher.throwWorkerExitedBeforeSocket(TestDirectWorkerHelpers.scala:207)

This keeps the scheduled Build / Maven (Scala 2.13, JDK 21, MacOS-26) lane red. Picking the
shortest base makes macOS use /tmp (which resolves to the short /private/tmp) instead of
the long $TMPDIR, keeping the socket path well within the limit. Linux is unaffected — its
per-user temp dirs are already short — and the choice is now deterministic (shortest wins)
rather than order-dependent.

Does this PR introduce any user-facing change?

No. Test-only.

How was this patch tested?

Ran the affected suites on both macos-14 and macos-15 GitHub Actions runners (arm64, the
same short-$TMPDIR layout as macos-26), where $TMPDIR was confirmed to be the long
/var/folders/... path (len=49):

  • udf-worker-core: DirectWorkerDispatcherSuite + WorkerSessionSuite48 tests, 0 failures
  • sql/core: PythonUDFWorkerSpecificationSuite1 test, 0 failures (previously
    AF_UNIX path too long)

Both runners green: https://github.com/HyukjinKwon/spark/actions/runs/28765870386

Before this change the same suite fails on macos-26:
https://github.com/apache/spark/actions/runs/28753698265

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code

… UDS path (fix macOS AF_UNIX path too long)

TestDirectWorkerDispatcher.shortTempBase picked the first writable base among
TMPDIR/TEMP/TMP/tmp. On macOS $TMPDIR is a long /var/folders/<...>/T path, so
the resulting Unix-domain socket path (base + createTempDirectory random suffix +
w-<id>.sock leaf) exceeded the 104-byte macOS sun_path limit and failed
PythonUDFWorkerSpecificationSuite with 'OSError: AF_UNIX path too long', turning
the Build / Maven (JDK 21, MacOS-26) lane red.

Pick the shortest usable base by its real (symlink-resolved) path instead, so on
macOS /tmp (-> /private/tmp) is chosen over the long $TMPDIR. Linux is unaffected
(its per-user temp dirs are already short). Test-only.

Generated-by: Claude Code
HyukjinKwon added a commit that referenced this pull request Jul 6, 2026
…UDS path to fix macOS AF_UNIX path too long

### What changes were proposed in this pull request?

`TestDirectWorkerDispatcher.shortTempBase` (in `TestDirectWorkerHelpers.scala`) chooses a
base directory for the direct-worker Unix-domain socket by taking the **first** writable
entry among `$TMPDIR`, `$TEMP`, `$TMP`, `/tmp`. This PR changes it to pick the **shortest**
usable base, measured by its real (symlink-resolved) path.

### Why are the changes needed?

On macOS, `$TMPDIR` is a long per-user path like
`/var/folders/k8/j7r3p6cx43xdqhzy2rmp6tqr0000gn/T/` (~49 chars). Combined with the
`createTempDirectory` random suffix and the `w-<id>.sock` leaf, the bound socket path
exceeds the **104-byte macOS `sun_path` limit**, so `PythonUDFWorkerSpecificationSuite`
fails with:

```
OSError: AF_UNIX path too long
  at ...TestDirectWorkerDispatcher.throwWorkerExitedBeforeSocket(TestDirectWorkerHelpers.scala:207)
```

This keeps the scheduled `Build / Maven (Scala 2.13, JDK 21, MacOS-26)` lane red. Picking the
shortest base makes macOS use `/tmp` (which resolves to the short `/private/tmp`) instead of
the long `$TMPDIR`, keeping the socket path well within the limit. Linux is unaffected — its
per-user temp dirs are already short — and the choice is now deterministic (shortest wins)
rather than order-dependent.

### Does this PR introduce _any_ user-facing change?

No. Test-only.

### How was this patch tested?

Ran the affected suites on both `macos-14` and `macos-15` GitHub Actions runners (arm64, the
same short-`$TMPDIR` layout as `macos-26`), where `$TMPDIR` was confirmed to be the long
`/var/folders/...` path (`len=49`):

- `udf-worker-core`: `DirectWorkerDispatcherSuite` + `WorkerSessionSuite` — **48 tests, 0 failures**
- `sql/core`: `PythonUDFWorkerSpecificationSuite` — **1 test, 0 failures** (previously
  `AF_UNIX path too long`)

Both runners green: https://github.com/HyukjinKwon/spark/actions/runs/28765870386

Before this change the same suite fails on `macos-26`:
https://github.com/apache/spark/actions/runs/28753698265

### Was this patch authored or co-authored using generative AI tooling?

Generated-by: Claude Code

Closes #57028 from HyukjinKwon/ci-fix/agent4-macos-uds-path-pr.

Authored-by: Hyukjin Kwon <gurwls223@apache.org>
Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
(cherry picked from commit 226ea56)
Signed-off-by: Hyukjin Kwon <hyukjin.kwon@databricks.com>
@HyukjinKwon

Copy link
Copy Markdown
Member Author

Merge Summary:

Posted by merge_spark_pr.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants