From 85f62dccfcf4a58fddcdf52b6336ef3e7e8ca44a Mon Sep 17 00:00:00 2001 From: Aditya Vaish Date: Wed, 2 Dec 2026 08:32:03 -0800 Subject: [PATCH 1/2] ci: retry Maven downloads in the TPC-H and TPC-DS builds Wrap the `Build project` (`./mvnw -B -Prelease install -DskipTests`) steps in `verify-benchmark-results-tpch` and `verify-benchmark-results-tpcds` in `.github/workflows/pr_build_linux.yml` with the same bounded download-error retry loop used by `lint-java` (up to 4 attempts, exponential backoff 10s/20s/40s + 0-4s jitter, `-U` on retries, `shell: bash`), so transient Maven Central 429/403/404/transfer failures in cache-refresh-only mode do not abort the build and skip saving the Maven cache. Resolves apache/datafusion-comet#7759 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/pr_build_linux.yml | 57 +++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr_build_linux.yml b/.github/workflows/pr_build_linux.yml index 703cd770b4b..fa88eea34ed 100644 --- a/.github/workflows/pr_build_linux.yml +++ b/.github/workflows/pr_build_linux.yml @@ -786,9 +786,37 @@ jobs: path: ./tpch key: tpch-${{ hashFiles('.github/workflows/pr_build_linux.yml') }} + # Match the download-error retry in `lint-java`. In cache-refresh-only + # mode, the TPC-H and TPC-DS jobs are the only Maven builds, so a + # Maven Central hiccup here skips saving the Maven cache. Non-download + # failures (such as compile errors) still fail on the first attempt, and + # retries pass -U because Maven caches 404s in the local repository. - name: Build project + # Bash rather than the container default `sh`: the retry below needs + # pipefail, $RANDOM, and shell arithmetic. + shell: bash run: | - ./mvnw -B -Prelease install -DskipTests + set -o pipefail + log=$(mktemp) + trap 'rm -f "$log"' EXIT + update= + for attempt in 1 2 3 4; do + if ./mvnw -B $update -Prelease install -DskipTests 2>&1 | tee "$log"; then + exit 0 + fi + if ! grep -qE '^\[(ERROR|FATAL)\] .*(No plugin found for prefix|could not be resolved|Could not transfer|Could not find artifact|ClassNotFoundException: scala\.tools\.nsc\.Main)' "$log"; then + echo "::error::Maven failed for a reason other than a download, such as 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." + 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 - name: Generate TPC-H data (SF=1) if: steps.cache-tpch.outputs.cache-hit != 'true' @@ -861,9 +889,34 @@ jobs: path: ./tpcds-sf-1 key: tpcds-${{ hashFiles('.github/workflows/pr_build_linux.yml') }} + # Same download-error retry as `verify-benchmark-results-tpch` and + # `lint-java`; see the comment there. - name: Build project + # Bash rather than the container default `sh`: the retry below needs + # pipefail, $RANDOM, and shell arithmetic. + shell: bash run: | - ./mvnw -B -Prelease install -DskipTests + set -o pipefail + log=$(mktemp) + trap 'rm -f "$log"' EXIT + update= + for attempt in 1 2 3 4; do + if ./mvnw -B $update -Prelease install -DskipTests 2>&1 | tee "$log"; then + exit 0 + fi + if ! grep -qE '^\[(ERROR|FATAL)\] .*(No plugin found for prefix|could not be resolved|Could not transfer|Could not find artifact|ClassNotFoundException: scala\.tools\.nsc\.Main)' "$log"; then + echo "::error::Maven failed for a reason other than a download, such as 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." + 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 - name: Checkout tpcds-kit if: steps.cache-tpcds.outputs.cache-hit != 'true' From b6e54f869e5a438d8908780aa609824c599a3197 Mon Sep 17 00:00:00 2001 From: Aditya Vaish Date: Wed, 2 Dec 2026 17:29:11 -0800 Subject: [PATCH 2/2] ci: deduplicate Maven retry loop into dev/ci/mvn-retry.sh and wrap TPC data generation Address review feedback on apache/datafusion-comet#7828: - Extract the bounded Maven download-error retry loop into `dev/ci/mvn-retry.sh` so `lint-java` and the TPC-H/TPC-DS steps share one regex, backoff, `-U` retry flag injection, and temp-log cleanup without duplicating inline bash loops or `shell: bash` overrides in `.github/workflows/pr_build_linux.yml`. - Route `Generate TPC-H data (SF=1)` and `Generate TPC-DS data (SF=1)` (`exec:java`) through `../dev/ci/mvn-retry.sh` as well, since `exec-maven-plugin` is not resolved during `-Prelease install` and a download failure there also skips saving the Maven cache. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .github/workflows/pr_build_linux.yml | 107 ++++----------------------- dev/ci/mvn-retry.sh | 61 +++++++++++++++ 2 files changed, 74 insertions(+), 94 deletions(-) create mode 100755 dev/ci/mvn-retry.sh diff --git a/.github/workflows/pr_build_linux.yml b/.github/workflows/pr_build_linux.yml index fa88eea34ed..0e056efbee1 100644 --- a/.github/workflows/pr_build_linux.yml +++ b/.github/workflows/pr_build_linux.yml @@ -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 @@ -786,42 +755,17 @@ jobs: path: ./tpch key: tpch-${{ hashFiles('.github/workflows/pr_build_linux.yml') }} - # Match the download-error retry in `lint-java`. In cache-refresh-only - # mode, the TPC-H and TPC-DS jobs are the only Maven builds, so a - # Maven Central hiccup here skips saving the Maven cache. Non-download - # failures (such as compile errors) still fail on the first attempt, and - # retries pass -U because Maven caches 404s in the local repository. + # 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 - # Bash rather than the container default `sh`: the retry below needs - # pipefail, $RANDOM, and shell arithmetic. - shell: bash run: | - set -o pipefail - log=$(mktemp) - trap 'rm -f "$log"' EXIT - update= - for attempt in 1 2 3 4; do - if ./mvnw -B $update -Prelease install -DskipTests 2>&1 | tee "$log"; then - exit 0 - fi - if ! grep -qE '^\[(ERROR|FATAL)\] .*(No plugin found for prefix|could not be resolved|Could not transfer|Could not find artifact|ClassNotFoundException: scala\.tools\.nsc\.Main)' "$log"; then - echo "::error::Maven failed for a reason other than a download, such as 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." - 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 -Prelease install -DskipTests - name: Generate TPC-H data (SF=1) 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 }} @@ -889,34 +833,9 @@ jobs: path: ./tpcds-sf-1 key: tpcds-${{ hashFiles('.github/workflows/pr_build_linux.yml') }} - # Same download-error retry as `verify-benchmark-results-tpch` and - # `lint-java`; see the comment there. - name: Build project - # Bash rather than the container default `sh`: the retry below needs - # pipefail, $RANDOM, and shell arithmetic. - shell: bash run: | - set -o pipefail - log=$(mktemp) - trap 'rm -f "$log"' EXIT - update= - for attempt in 1 2 3 4; do - if ./mvnw -B $update -Prelease install -DskipTests 2>&1 | tee "$log"; then - exit 0 - fi - if ! grep -qE '^\[(ERROR|FATAL)\] .*(No plugin found for prefix|could not be resolved|Could not transfer|Could not find artifact|ClassNotFoundException: scala\.tools\.nsc\.Main)' "$log"; then - echo "::error::Maven failed for a reason other than a download, such as 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." - 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 -Prelease install -DskipTests - name: Checkout tpcds-kit if: steps.cache-tpcds.outputs.cache-hit != 'true' @@ -935,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 }} diff --git a/dev/ci/mvn-retry.sh b/dev/ci/mvn-retry.sh new file mode 100755 index 00000000000..2cdddd6e1f1 --- /dev/null +++ b/dev/ci/mvn-retry.sh @@ -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 [args...] + +set -euo pipefail + +mvn_cmd="${1:?usage: mvn-retry.sh [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