[GRADLE-1166] Corrupted cache exception Created: 07/Oct/10  Updated: 04/Jan/13  Resolved: 16/Aug/11

Status: Resolved
Project: Gradle
Affects Version/s: 0.9
Fix Version/s: 1.0-milestone-5

Type: Bug
Reporter: Vince Rosso Assignee: Adam Murdoch
Resolution: Fixed Votes: 25

Issue Links:
Duplicate
Duplicates GRADLE-1472 java.lang.ClassCastException FileColl... Resolved
Duplicates GRADLE-1561 FileSnapshotter class cast exception Resolved

 Description   

I'm occassionally getting errors of this kind when building:

org.gradle.api.UncheckedIOException: Could not remove entry '/var/tmp/build/foo/ubuntu-10.04-64/foo/dependency-cache' from cache '/ext/home/build/.gradle/caches/0.9-preview-3/outputFileStates/cache.bin'.
Caused by: org.gradle.cache.btree.CorruptedCacheException: Corrupted IndexBlock 649964 found in cache '/ext/home/build/.gradle/caches/0.9-preview-3/outputFileStates/cache.bin'.
at org.gradle.cache.btree.FileBackedBlockStore$BlockImpl.blockCorruptedException(FileBackedBlockStore.java:239)

Sometimes its an issue with outputFileStates/cache.bin and other times its an issue with fileHashes/cache.bin.

A little background: we have an automated build system where a "build" user checks if there have been recent svn checkins into a project. If so, it checks out the code and builds it to a central repository. This can happen for many projects at the same time and so multiple gradle processes would access the gradle caches simultaneously.

This was with 0.9-preview-3



 Comments   
Comment by Vince Rosso [ 07/Dec/10 ]

A quick update on this:
Originally the .gradle directory was stored on an NFS volume. Since NFS is notoriously bad at handling concurrent file accesses, I tried moving the .gradle directory to a local disk (using the -g option).
Since doing that I have not seen this problem reproduced.

So, I'm guessing this is likely due to NFS, but it probably still warrants some more examination.

Another note: before moving it off NFS, I was still seeing this issue as of 0.9-rc-2.

Comment by Vince Rosso [ 25/Jan/11 ]

Another update:

Switching to a local disk has reduced the frequency of the issue, but it does still happen:
org.gradle.api.UncheckedIOException: Could not remove entry '/var/tmp/build/finder_tmobile/1.1/tinderbuilds/2011.01.25-10.03/ubuntu-10.04-64/round/dependency-cache' from cache '/var/tmp/build/gradle/caches/0.9.1/outputFileStates/cache.bin'.
Caused by: org.gradle.cache.btree.CorruptedCacheException: Corrupted IndexBlock 1243206 found in cache '/var/tmp/build/gradle/caches/0.9.1/outputFileStates/cache.bin'.
at org.gradle.cache.btree.FileBackedBlockStore$BlockImpl.blockCorruptedException(FileBackedBlockStore.java:239)

Using 0.9.1

Comment by Ashton Hepburn [ 08/Jun/11 ]

Using: Gradle 1.0-milestone-1, simple Jetty/Ubuntu setup for Hudson.

We sporadically get errors like this in our automated Hudson setup:

– Note: we suspect that this issues relates to concurrent builds (we have a number of related builds, and this project is itself a multi-project build with components shared with another multi-project build). Manually forcing a build usually executes it cleanly.

lease/workspace/someproject/build/classes/test/com/icosystem/someclass.class' to cache '/srv/opt/jetty-hightide-7.1.6.v20100715/.gradle/caches/1.0-milestone-1/fileHashes/cache.bin'.
at org.gradle.cache.btree.BTreePersistentIndexedCache.put(BTreePersistentIndexedCache.java:149)
at org.gradle.api.internal.changedetection.CachingHasher.hash(CachingHasher.java:44)
at org.gradle.api.internal.changedetection.DefaultFileSnapshotter.snapshot(DefaultFileSnapshotter.java:44)
at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateRepository$HistoricExecution.calcCurrentState(DefaultTaskArtifactStateRepository.java:143)
at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateRepository$HistoricExecution.isUpToDate(DefaultTaskArtifactStateRepository.java:153)
at org.gradle.api.internal.changedetection.DefaultTaskArtifactStateRepository$TaskArtifactStateImpl.isUpToDate(DefaultTaskArtifactStateRepository.java:292)
at org.gradle.api.internal.changedetection.ShortCircuitTaskArtifactStateRepository$1.isUpToDate(ShortCircuitTaskArtifactStateRepository.java:35)
at org.gradle.api.internal.project.taskfactory.ExecutionShortCircuitTaskExecuter.execute(ExecutionShortCircuitTaskExecuter.java:40)
at org.gradle.api.internal.tasks.SkipTaskExecuter.doExecute(SkipTaskExecuter.java:57)
at org.gradle.api.internal.tasks.SkipTaskExecuter.execute(SkipTaskExecuter.java:35)
at org.gradle.api.internal.tasks.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:32)
at org.gradle.api.internal.AbstractTask.execute(AbstractTask.java:231)
at org.gradle.execution.DefaultTaskGraphExecuter.executeTask(DefaultTaskGraphExecuter.java:167)
at org.gradle.execution.DefaultTaskGraphExecuter.doExecute(DefaultTaskGraphExecuter.java:160)
at org.gradle.execution.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:78)
at org.gradle.execution.TaskNameResolvingBuildExecuter.execute(TaskNameResolvingBuildExecuter.java:113)
at org.gradle.execution.DelegatingBuildExecuter.execute(DelegatingBuildExecuter.java:54)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:153)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:107)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:75)
at org.gradle.launcher.RunBuildAction.execute(RunBuildAction.java:41)
at org.gradle.launcher.RunBuildAction.execute(RunBuildAction.java:27)
at org.gradle.launcher.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:209)
at org.gradle.launcher.CommandLineActionFactory$WithLoggingAction.execute(CommandLineActionFactory.java:193)
at org.gradle.launcher.Main.execute(Main.java:55)
at org.gradle.launcher.Main.main(Main.java:40)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.gradle.launcher.ProcessBootstrap.runNoExit(ProcessBootstrap.java:46)
at org.gradle.launcher.ProcessBootstrap.run(ProcessBootstrap.java:28)
at org.gradle.launcher.GradleMain.main(GradleMain.java:24)
Caused by: org.gradle.cache.btree.CorruptedCacheException: Corrupted DataBlock 97254 found in cache '/srv/opt/jetty-hightide-7.1.6.v20100715/.gradle/caches/1.0-milestone-1/fileHashes/cache.bin'.
at org.gradle.cache.btree.FileBackedBlockStore$BlockImpl.blockCorruptedException(FileBackedBlockStore.java:239)
at org.gradle.cache.btree.FileBackedBlockStore$BlockImpl.read(FileBackedBlockStore.java:202)
at org.gradle.cache.btree.FileBackedBlockStore.read(FileBackedBlockStore.java:91)
at org.gradle.cache.btree.CachingBlockStore.read(CachingBlockStore.java:84)
at org.gradle.cache.btree.FreeListBlockStore.read(FreeListBlockStore.java:78)
at org.gradle.cache.btree.StateCheckBlockStore.read(StateCheckBlockStore.java:61)
at org.gradle.cache.btree.BTreePersistentIndexedCache.put(BTreePersistentIndexedCache.java:136)
... 32 more

Comment by Craig White [ 13/Jul/11 ]

We're getting hit with this one too.

Using Gradle 1.0-milestone-3 on Windows XP with Hudson.

Cause: Could not remove entry '6863' from cache 'C:\Documents and Settings\build\.gradle\caches\1.0-milestone-3\fileSnapshots\cache.bin'.
Cause: Corrupted IndexBlock 2819882 found in cache 'C:\Documents and Settings\build\.gradle\caches\1.0-milestone-3\fileSnapshots\cache.bin'.

Comment by Kelly Robinson [ 26/Jul/11 ]

I've been bitten by something similar while running concurrent builds on Hudson/Jenkins:
org.gradle.cache.btree.CorruptedCacheException: Corrupted FreeListBlock 0 found in cache '/root/.gradle/caches/1.0-milestone-3/fileHashes/cache.bin

Comment by Pivotal Tracker Integration [ 01/Aug/11 ]

A Pivotal Tracker story has been created for this Issue: http://www.pivotaltracker.com/story/show/16488859

Generated at Wed Jun 30 11:48:39 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.