# Build cache from the default branch is not reused; "The job exceeded the maximum log length" but the log is short

**URL:** https://travis-ci.community/t/build-cache-from-the-default-branch-is-not-reused-the-job-exceeded-the-maximum-log-length-but-the-log-is-short/6206
**Category:** Java
**Tags:** caching, travis-build
**Created:** [November 29, 2019, 4:43pm UTC](https://travis-ci.community/t/build-cache-from-the-default-branch-is-not-reused-the-job-exceeded-the-maximum-log-length-but-the-log-is-short/6206 "2019-11-29T16:43:11Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![fborriello](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/fborriello/32/2109_2.png) [@fborriello](https://travis-ci.community/u/fborriello)
#### Post date: [November 29, 2019, 4:43pm UTC](https://travis-ci.community/t/build-cache-from-the-default-branch-is-not-reused-the-job-exceeded-the-maximum-log-length-but-the-log-is-short/6206/1 "2019-11-29T16:43:11Z")

</div>

Travis build is not always able to download the cached maven dependencies due to the following error:

```auto
Setting up build cache
$ export CASHER_DIR=${TRAVIS_HOME}/.casher
0.29s$ Installing caching utilities
0.00s2.54sattempting to download cache archive
fetching 1.6.2-jdk8/cache--linux-xenial-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855--jdk-openjdk8.tgz
fetching 1.6.2-jdk8/cache-linux-xenial-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855--jdk-openjdk8.tgz
fetching 1.6.2-jdk8/cache--jdk-openjdk8.tgz
fetching master/cache--linux-xenial-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855--jdk-openjdk8.tgz
fetching master/cache-linux-xenial-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855--jdk-openjdk8.tgz
fetching master/cache--jdk-openjdk8.tgz
could not download cache
0.00s1.19sadding /home/travis/.m2 to cache

```

The effect of this error is that all maven dependencies are downloaded from scratch at each job, producing an extremely long log that breaks the build as it exceeds the maximum size.  
Please refer to those builds for having more details about the issue:

- [https://travis-ci.org/HotelsDotCom/bull/jobs/617815288](https://travis-ci.org/HotelsDotCom/bull/jobs/617815288)
- [https://travis-ci.org/HotelsDotCom/bull/jobs/617730584](https://travis-ci.org/HotelsDotCom/bull/jobs/617730584)

The build configuration is available at [https://travis-ci.org/HotelsDotCom/bull/builds/617815279/config](https://travis-ci.org/HotelsDotCom/bull/builds/617815279/config)

Could you kindly help?  
thanks

---

<div class="post-metadata">

### Author: ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)
#### Post date: [November 29, 2019, 6:26pm UTC](https://travis-ci.community/t/build-cache-from-the-default-branch-is-not-reused-the-job-exceeded-the-maximum-log-length-but-the-log-is-short/6206/2 "2019-11-29T18:26:41Z")

</div>

The cache is not downloaded for the `1.6.2-jdk8` branch from the `master` branch [because it has a different configuration, so its cache cannot be reused.](https://docs.travis-ci.com/user/caching/#fetching-and-storing-caches) Note the different cache IDs:

- [https://travis-ci.org/HotelsDotCom/bull/builds/617813454#L303:](https://travis-ci.org/HotelsDotCom/bull/builds/617813454#L303:)

- [https://travis-ci.org/HotelsDotCom/bull/jobs/617815288#L207:](https://travis-ci.org/HotelsDotCom/bull/jobs/617815288#L207:)

The hash ([which is a hash of an amalgam of all configuration-defined envvars (as of this writing)](https://github.com/travis-ci/travis-build/blob/8cbe6ab2593f5ec3099c03009c125a654763804e/lib/travis/build/script.rb#L168)) is the same – but the JDK version is different – resulting in a different cache ID.

* * *

Your build needs be able to finish when there’s no cache – since a cache is generally treated as volatile.  
If e.g. a build is taking too long, it can be split into stages.  
But in your case, the problem is `The job exceeded the maximum log length, and has been terminated.` – despite a seemmingly short log of only 3282 lines in the job window.

If you look at [the raw log](https://api.travis-ci.org/v3/job/617815288/log.txt) for [https://travis-ci.org/HotelsDotCom/bull/jobs/617815288](https://travis-ci.org/HotelsDotCom/bull/jobs/617815288), the most of the log is taken up by download progress messages – which you don’t see in the job window because of terminal control characters they use (this is by design, Maven specifically arranges it so that they become invisible once a download is finished). So

> <https://stackoverflow.com/questions/21638697/disable-maven-download-progress-indication/21638827#21638827>

---

<div class="post-metadata">

### Author: ![fborriello](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/fborriello/32/2109_2.png) [@fborriello](https://travis-ci.community/u/fborriello)
#### Post date: [November 30, 2019, 4:59am UTC](https://travis-ci.community/t/build-cache-from-the-default-branch-is-not-reused-the-job-exceeded-the-maximum-log-length-but-the-log-is-short/6206/4 "2019-11-30T04:59:05Z")

</div>

Sounds great!! Thank you!!
