Repository navigation
Commit ef88e02
authored
[MINOR] Persist the Maven build cache between CI runs (#882)
* [MINOR] Persist the Maven build cache between CI runs
.mvn/extensions.xml enables maven-build-cache-extension, but the cache
never survives a CI run: actions/setup-java's `cache: maven` persists
~/.m2/repository only, while the extension writes to ~/.m2/build-cache.
The effect is visible in any recent build log - ten modules, ten
"Local build was not found by checksum" lines, zero restores - so every
run rebuilds and retests all ten modules from scratch, including for
pull requests that touch only the website or a single module.
Restore ~/.m2/build-cache before the build and save it afterwards. Only
main writes an entry; pull requests restore from main's rather than each
branch consuming the repository-wide 10 GB cache budget.
Source Build Check is deliberately left alone - it passes
-Dmaven.build.cache.enabled=false and skips `cache: maven` on purpose,
to prove the source release builds without prebuilt artifacts.
* Keep the bundled jars out of the persisted build cache
Persisting ~/.m2/build-cache as the previous commit does is only useful
if the entry is small enough to live alongside the ~/.m2/repository
caches in the repository-wide 10 GB budget. Measured, it is not: one
generation is 1.2 GB, and 1.17 GB of that is three bundled jars -
xtable-utilities (1.0 GB), xtable-hive-metastore (125 MB) and
xtable-aws (42 MB).
Those three modules are worth about 3 minutes of a 27 minute build.
xtable-core and xtable-service are 84% of the time and about 1 MB of
cache between them. Caching is worth it in inverse proportion to
artifact size here, so opt the bundle producers out with the
extension's per-project property, which disables both restore and save
for that module. A cold build then writes 12 MB instead of 1.2 GB while
still caching everything expensive; measured locally, a fully warm run
restores 7 of 7 remaining modules.
Also in this commit:
- Add .mvn/maven-build-cache-config.xml pinning maxBuildsCached to 1,
disabling the remote cache explicitly, and reconciling the surefire
skip flags. Command line flags are not part of a module's checksum,
so without reconciliation a build that skipped tests and one that ran
them are indistinguishable to the cache. The flags are tracked
without a skipValue attribute deliberately: skipValue relaxes the
comparison rather than tightening it.
- Bump maven-build-cache-extension 1.1.0 -> 1.2.3. Two invalidation
fixes land in 1.2.1: MBUILDCACHE-87, plugin dependencies missing from
the checksum, and MBUILDCACHE-99, moved files not always detected.
Both affect whether a restore is correct, so they matter more once
the cache actually persists.
- Guard the save step on the cache directory staying under 100 MB, and
warn when it does not, so a future module that starts caching large
artifacts is visible rather than silently churning the budget.
- Pass -Dmaven.build.cache.enabled=false when publishing a release.
versions:set rewrites the version immediately beforehand, while cache
restoration is version-agnostic. That runner keeps no cache directory
today, so this is a guard against it gaining one, and it matches what
source-build-check.yml already does deliberately.
- Add the JDK to the Actions cache key, since the extension does not
hash the JDK, and raise the job timeout from 30 to 40 minutes - a
cold build is already 27 minutes against it, independent of caching.
- Teach the spotless license-header delimiter about <cache, the root
element of the new config file, alongside the <extensions entry that
is already there for .mvn/extensions.xml.
* Drop this project's own artifacts before the m2 repository cache is saved
`mvn install` puts xtable's own artifacts into ~/.m2/repository, and that
includes the bundled jars - about 1.2 GB, of which xtable-utilities alone
is roughly 1 GB. actions/setup-java caches that directory wholesale and
offers no way to exclude a path, so remove them in a final step, which
runs before its post-save hook.
They are rebuilt from source on every run, so they can never produce a
useful cache hit, and a stale SNAPSHOT sitting in the local repository
can shadow a reactor build.
This is a guard rather than a fix. License Check currently reserves the
shared cache key first - it downloads the whole dependency tree to
inspect each jar's license, which is the useful half - and because it
only runs `package`, the saved entry has never contained this project's
artifacts. That is why this job logs "Unable to reserve cache with key"
at the end of every run. The arrangement is the one we want, but it
holds by ordering rather than by construction: if License Check ever
fails or is cancelled before its post step, this job would win the key
and save roughly 2.15 GB into a repository-wide 10 GB budget.
* Manage the Maven repository cache explicitly, with one writer
Both jobs used setup-java's `cache: maven`, which has two problems here.
It restores on an exact key match only. setup-java sets no restore-keys
deliberately, "to start with a clear cache after dependency update"
(actions/setup-java#269), so any change to a pom or to extensions.xml
made every job re-download the entire dependency tree from Central.
Keying the same way but adding a prefix fallback warms from the previous
entry and downloads only the delta. This commit changes both files, so
it pays that cost once itself.
It also gave the two jobs the same key, and cache entries are immutable,
so whichever finished first reserved it and the other's save failed.
License Check finishes in about two minutes and the full build takes 27,
so in practice License Check always won and Maven CI Build logged
"Unable to reserve cache with key" on every run.
That outcome was the right one, which is why this makes it explicit
rather than trying to win the race. License Check has to resolve every
dependency in order to inspect each jar's license, so it populates
exactly what the other jobs need, and it stops at `package`, so its
entry never contains this project's own artifacts. It is now the sole
writer; Maven CI Build restores the same key read-only and no longer
attempts a save.
The wrapper distribution was cached separately by setup-java, keyed on
the wrapper properties so it survives pom changes. That is reproduced
here rather than lost.
Both jobs also clear ~/.m2/repository/org/apache/xtable before the
post-job save, as Source Build Check already does. On the writer that
guards the invariant above; on the reader it is belt and braces.
* Write the Maven repository cache only from main
The entry measures 981 MB against a repository-wide 10 GB budget, so a
handful of concurrent pull requests with differing pom hashes would
crowd out the entry they all restore from. Split restore and save so
only main writes, matching what this branch already does for the build
cache. Pull requests warm from main through the prefix fallback and
re-download only their own delta.
Saving is also conditional on the exact key having missed. Cache entries
are immutable, so writing over an existing key just fails; that check is
what actions/cache performs internally when restore and save are not
split.
The wrapper cache is left unsplit. At ~9 MB it is not worth gating, and
it is keyed on the wrapper properties, which rarely change.
* Reconcile the flags that skip tests without changing the checksum
Failsafe is bound in the parent POM to integration-test and verify, and
CI runs `install`, so integration tests run on every build and a
restored module skips them exactly as it skips unit tests. Reconciles
are matched per goal, and the two goals expose different parameters:
testFailureIgnore is on verify only, and naming a parameter a goal does
not have earns a warning on every build.
The compiler entry closes a hole the surefire block does not reach.
-Dmaven.test.skip=true never gets to surefire here, because the parent
POM pins <skip>${skipUTs}</skip> and explicit plugin configuration wins
over the user property, so surefire's skip parameter reads identically
either way and the module checksum is byte-identical across the two.
What the flag actually suppresses is test compilation.
Verified on xtable-api, Temurin 11: seeding the cache with
-Dmaven.test.skip=true and then running a plain `clean install`
restored the untested build before this commit, and after it logs
"Plugin parameter mismatch found. Parameter: skip, expected: true,
actual: false" and runs the tests. A plain build still restores a plain
build, and buildinfo.xml records all nine failsafe parameters as
tracked="true" with no "Cannot find a Mojo parameter" warnings.
* Derive the JDK in the cache keys from one place
The JDK is in these keys because the build cache extension does not hash
it, and the two workflows have to agree on the key or the reader stops
finding what the writer saved. Four literal "jdk11" strings across two
files could not express that; bumping actions/setup-java's java-version
would have left them asserting a JDK that is no longer in use.
* Resolve the whole reactor in the job that writes the repository cache
"License Check has to resolve every dependency in order to inspect each
jar's license" is not true, and the previous commit made it load-
bearing. apache-rat:check declares no dependency resolution;
dependency:tree collects poms rather than jars; and the shaded-bundle
step names three modules and reaches only their -am closure. -am makes
dependencies, not dependents, so the two leaves are outside it: nothing
in the job resolves xtable-service's Quarkus stack, xtable-utilities'
bundled dependencies, or maven-install-plugin, which only an `install`
pulls.
Maven CI Build is restore-only by construction, so it cannot fill that
gap itself - it would re-download the delta from Central on every run,
permanently. dependency:go-offline over the full reactor covers what the
license steps do not. It runs only on main, where the save happens, and
its failure must not fail a license check: an incomplete entry costs
download time on the next run and nothing else.
Verified: `./mvnw -B -ntp -q dependency:go-offline
-Dmaven.build.cache.enabled=false` exits 0 across the reactor.
* Bound the build cache save on both sides
The save gated on `size_mb < 100` while the warning fired above 100, so
a directory of exactly 100 MB - reachable, du -sm rounds up - was
skipped silently, the one outcome the guard exists to make visible. It
also treated the `${size_mb:-0}` fallback for a missing directory as a
pass, handing actions/cache/save a path that is not there.
Saving is now also conditional on the exact key having missed on
restore. Cache entries are immutable, so a re-run of a main commit would
try to write over its own entry and log "Unable to reserve cache with
key" - the message the earlier commits removed by giving the two jobs
separate keys. The repository cache save already carries this check.1 parent 9b7883c commit ef88e02
9 files changed
Lines changed: 339 additions & 10 deletions
File tree
- .github/workflows
- .mvn
- xtable-aws
- xtable-hive-metastore
- xtable-utilities
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
32 | 38 | | |
33 | 39 | | |
34 | 40 | | |
35 | | - | |
| 41 | + | |
| 42 | + | |
36 | 43 | | |
37 | 44 | | |
38 | 45 | | |
39 | | - | |
| 46 | + | |
40 | 47 | | |
41 | 48 | | |
42 | | - | |
| 49 | + | |
43 | 50 | | |
44 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
45 | 101 | | |
46 | 102 | | |
47 | 103 | | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
32 | 37 | | |
33 | 38 | | |
34 | 39 | | |
35 | 40 | | |
36 | 41 | | |
37 | 42 | | |
38 | | - | |
| 43 | + | |
39 | 44 | | |
40 | 45 | | |
41 | | - | |
| 46 | + | |
42 | 47 | | |
43 | | - | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
44 | 88 | | |
45 | 89 | | |
46 | 90 | | |
| |||
61 | 105 | | |
62 | 106 | | |
63 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
39 | 45 | | |
40 | 46 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
25 | 25 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
946 | 946 | | |
947 | 947 | | |
948 | 948 | | |
949 | | - | |
| 949 | + | |
| 950 | + | |
950 | 951 | | |
951 | 952 | | |
952 | 953 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
30 | 41 | | |
31 | 42 | | |
32 | 43 | | |
| |||
0 commit comments