Skip to content
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
54 changes: 13 additions & 41 deletions .github/workflows/pr_build_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -202,45 +202,14 @@ jobs:
restore-keys: |
${{ runner.os }}-java-maven-

# Split a Maven Central hiccup from a real lint violation. When the
# scalafix plugin fails to download (Central has answered 403, 429 and
# 404), Maven stops with "No plugin found for prefix 'scalafix'" and the
# red lint looks exactly like a violation. A scala-compiler jar that did
# not download shows up as "ClassNotFoundException: scala.tools.nsc.Main".
# The scalafix-syntactic job above lints offline after a retried
# download. Maven has no equally safe offline mode here, because the
# build resolves plugin and compiler artifacts as it goes, so this step
# retries the whole build instead, and only when Maven's error names a
# download. A lint violation or a compile error still fails on the first
# attempt. Maven caches a 404 in the local repository and will not ask
# again on its own, so the retries pass -U. Backoff matches
# .github/actions/maven-bootstrap: 10s, 20s, 40s plus 0-4s of jitter.
# Split a Maven Central hiccup from a real lint violation. Maven has no
# offline mode here because the build resolves plugin and compiler
# artifacts as it goes, so retry only on download errors; lint violations
# and compile errors still fail on the first attempt.
- name: Run scalafix check
# Bash rather than the container default `sh`: the retry below needs
# pipefail, $RANDOM, and shell arithmetic.
shell: bash
run: |
set -o pipefail
log=$(mktemp)
update=
for attempt in 1 2 3 4; do
if ./mvnw -B $update package -DskipTests scalafix:scalafix -Dscalafix.mode=CHECK \
-Psemanticdb ${{ matrix.profile.maven_opts }} 2>&1 | tee "$log"; then
exit 0
fi
if ! grep -qE '^\[ERROR\] .*(No plugin found for prefix|could not be resolved|Could not transfer|ClassNotFoundException: scala\.tools\.nsc\.Main)' "$log"; then
echo "::error::Maven failed for a reason other than a download, such as a lint violation or a compile error; not retrying."
exit 1
fi
if [ "$attempt" -eq 4 ]; then
echo "::error::Maven could not download a plugin or dependency after $attempt attempts; this is not a lint violation."
exit 1
fi
delay=$((10 * (1 << (attempt - 1)) + RANDOM % 5))
echo "::warning::Maven failed to download a plugin or dependency (attempt $attempt of 4); retrying in ${delay}s with -U."
sleep "$delay"
update=-U
done
dev/ci/mvn-retry.sh ./mvnw -B package -DskipTests scalafix:scalafix -Dscalafix.mode=CHECK \
-Psemanticdb ${{ matrix.profile.maven_opts }}

- name: Setup Node.js
uses: actions/setup-node@v7
Expand Down Expand Up @@ -786,14 +755,17 @@ jobs:
path: ./tpch
key: tpch-${{ hashFiles('.github/workflows/pr_build_linux.yml') }}

# Retry Maven download errors in the build and data-generation steps. In
# cache-refresh-only mode these jobs are the only Maven builds, and a
# failure in either step skips saving the Maven cache.
- name: Build project
run: |
./mvnw -B -Prelease install -DskipTests
dev/ci/mvn-retry.sh ./mvnw -B -Prelease install -DskipTests

- name: Generate TPC-H data (SF=1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The step after the build, Generate TPC-H data, runs ../mvnw -B -Prelease exec:java ... (and Generate TPC-DS data does the same) with no retry. exec-maven-plugin is declared in spark/pom.xml only inside the generate-docs profile (line 638) and has no pluginManagement entry in the root pom.xml, so -Prelease install does not resolve it. I expect exec:java to do its own prefix lookup and plugin download, which is the No plugin found for prefix failure this PR retries one step earlier. A failure there also skips Save Maven dependencies, which is the problem the PR describes. Please either route these steps through the same retry or show that the build step already caches the plugin, for example from a cold-cache run.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good catch—wrapped both Generate TPC-H data (SF=1) and Generate TPC-DS data (SF=1) (../mvnw -B -Prelease exec:java ...) with ../dev/ci/mvn-retry.sh in b6e54f869 (preserving cd spark, MAVEN_OPTS='-Xmx20g', and quoted -Dexec.args), so a transient exec-maven-plugin lookup/download failure is also retried before Save Maven dependencies.

Auto-replied by the GitHub Copilot app

if: steps.cache-tpch.outputs.cache-hit != 'true'
run: |
cd spark && MAVEN_OPTS='-Xmx20g' ../mvnw -B -Prelease exec:java -Dexec.mainClass="org.apache.spark.sql.GenTPCHData" -Dexec.classpathScope="test" -Dexec.cleanupDaemonThreads="false" -Dexec.args="--location `pwd`/.. --scaleFactor 1 --numPartitions 1 --overwrite"
cd spark && MAVEN_OPTS='-Xmx20g' ../dev/ci/mvn-retry.sh ../mvnw -B -Prelease exec:java -Dexec.mainClass="org.apache.spark.sql.GenTPCHData" -Dexec.classpathScope="test" -Dexec.cleanupDaemonThreads="false" -Dexec.args="--location `pwd`/.. --scaleFactor 1 --numPartitions 1 --overwrite"

- name: Run TPC-H queries
if: ${{ !inputs.cache-refresh-only }}
Expand Down Expand Up @@ -863,7 +835,7 @@ jobs:

- name: Build project
run: |
./mvnw -B -Prelease install -DskipTests
dev/ci/mvn-retry.sh ./mvnw -B -Prelease install -DskipTests

- name: Checkout tpcds-kit
if: steps.cache-tpcds.outputs.cache-hit != 'true'
Expand All @@ -882,7 +854,7 @@ jobs:
- name: Generate TPC-DS data (SF=1)
if: steps.cache-tpcds.outputs.cache-hit != 'true'
run: |
cd spark && MAVEN_OPTS='-Xmx20g' ../mvnw -B -Prelease exec:java -Dexec.mainClass="org.apache.spark.sql.GenTPCDSData" -Dexec.classpathScope="test" -Dexec.cleanupDaemonThreads="false" -Dexec.args="--dsdgenDir `pwd`/../tpcds-kit/tools --location `pwd`/../tpcds-sf-1 --scaleFactor 1 --numPartitions 1"
cd spark && MAVEN_OPTS='-Xmx20g' ../dev/ci/mvn-retry.sh ../mvnw -B -Prelease exec:java -Dexec.mainClass="org.apache.spark.sql.GenTPCDSData" -Dexec.classpathScope="test" -Dexec.cleanupDaemonThreads="false" -Dexec.args="--dsdgenDir `pwd`/../tpcds-kit/tools --location `pwd`/../tpcds-sf-1 --scaleFactor 1 --numPartitions 1"

- name: Run TPC-DS queries (Sort merge join)
if: ${{ !inputs.cache-refresh-only }}
Expand Down
61 changes: 61 additions & 0 deletions dev/ci/mvn-retry.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# Runs a Maven invocation with bounded retries on Maven Central download
# failures (HTTP 403, 404, 429, transfer errors, missing plugin prefix, or a
# missing scala-compiler jar). Non-download failures such as compile errors or
# lint violations still fail on the first attempt.
#
# Maven caches a 404 in the local repository and will not re-query Central on
# its own, so retries pass -U right after the Maven command. Backoff matches
# .github/actions/maven-bootstrap: 10s, 20s, 40s plus 0-4s of jitter.
#
# The captured log lives in a mktemp file outside the checkout and is removed
# on exit so downstream clean-tree checks stay clean.
#
# Usage: dev/ci/mvn-retry.sh <mvnw> [args...]

set -euo pipefail

mvn_cmd="${1:?usage: mvn-retry.sh <mvnw> [args...]}"
shift

log=$(mktemp)
trap 'rm -f "$log"' EXIT

retry_pattern='^\[(ERROR|FATAL)\] .*(No plugin found for prefix|could not be resolved|Could not transfer|Could not find artifact|ClassNotFoundException: scala\.tools\.nsc\.Main)'
update=()

for attempt in 1 2 3 4; do
if "$mvn_cmd" ${update[@]+"${update[@]}"} "$@" 2>&1 | tee "$log"; then
exit 0
fi
if ! grep -qE "$retry_pattern" "$log"; then
echo "::error::Maven failed for a reason other than a download, such as a compile error or lint violation; not retrying."
exit 1
fi
if [ "$attempt" -eq 4 ]; then
echo "::error::Maven could not download a plugin or dependency after $attempt attempts."
exit 1
fi
delay=$((10 * (1 << (attempt - 1)) + RANDOM % 5))
echo "::warning::Maven failed to download a plugin or dependency (attempt $attempt of 4); retrying in ${delay}s with -U."
sleep "$delay"
update=(-U)
done