[GRADLE-2216] Occasion failures because 'registry.bin' corrupted? Created: 05/Apr/12  Updated: 04/Jan/13  Resolved: 08/May/12

Status: Resolved
Project: Gradle
Affects Version/s: None
Fix Version/s: 1.1-rc-1

Type: Bug
Reporter: Kris De Volder Assignee: Luke Daley
Resolution: Fixed Votes: 0

Issue Links:
Duplicate
Duplicates GRADLE-1988 Daemon crash can leave daemon registr... Resolved

 Description   

One particular run of my STS regression suite with recent RC1 snapshot candidate I got 28 test failures. Many of them seemed to have this in type of error in common (see stacktrace at end).

I suppose it could have something to do with the fact that my tests is killing all Gradle daemons using unix type command "kill -9" at the end of each test that I run (I have to do this or by the end of my test suite run there will be +10 daemons running on the build server).

In any case, whatever the cause of the corruption. Gradle should be able to handle the situation and repair or reinitialize the registry.bin file if it is corrupted, rather keep failing repeatedly for the same reason.

Caused by: org.gradle.tooling.GradleConnectionException: Could not fetch model of type 'HierarchicalEclipseProject' using Gradle distribution 'http://services.gradle.org/distributions-snapshots/gradle-1.0-rc-1-20120403220941+0200-bin.zip'.
	at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:55)
	at org.gradle.tooling.internal.consumer.async.DefaultAsyncConnection$3.run(DefaultAsyncConnection.java:81)
	at org.gradle.messaging.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:66)
	at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)
Caused by: org.gradle.api.GradleException: Could not read cache value from '/opt/bamboo-home/xml-data/build-dir/STS-GRADLE37-JOB1/com.springsource.sts.gradle.core.test/target/.gradle/daemon/1.0-rc-1-20120403220941+0200/registry.bin'.
	at org.gradle.cache.internal.SimpleStateCache.deserialize(SimpleStateCache.java:88)
	at org.gradle.cache.internal.SimpleStateCache.access$000(SimpleStateCache.java:26)
	at org.gradle.cache.internal.SimpleStateCache$1.create(SimpleStateCache.java:40)
	at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.readFromFile(DefaultFileLockManager.java:130)
	at org.gradle.cache.internal.OnDemandFileAccess.readFromFile(OnDemandFileAccess.java:36)
	at org.gradle.cache.internal.SimpleStateCache.get(SimpleStateCache.java:38)
	at org.gradle.launcher.daemon.registry.PersistentDaemonRegistry.getAll(PersistentDaemonRegistry.java:57)
	at org.gradle.launcher.daemon.registry.PersistentDaemonRegistry.getIdle(PersistentDaemonRegistry.java:72)
	at org.gradle.launcher.daemon.client.DefaultDaemonConnector.connect(DefaultDaemonConnector.java:65)
	at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:104)
	at org.gradle.tooling.internal.provider.DaemonGradleLauncherActionExecuter.execute(DaemonGradleLauncherActionExecuter.java:44)
	at org.gradle.tooling.internal.provider.DaemonGradleLauncherActionExecuter.execute(DaemonGradleLauncherActionExecuter.java:31)
	at org.gradle.tooling.internal.provider.LoggingBridgingGradleLauncherActionExecuter.execute(LoggingBridgingGradleLauncherActionExecuter.java:53)
	at org.gradle.tooling.internal.provider.LoggingBridgingGradleLauncherActionExecuter.execute(LoggingBridgingGradleLauncherActionExecuter.java:30)
	at org.gradle.tooling.internal.provider.DefaultConnection.run(DefaultConnection.java:113)
	at org.gradle.tooling.internal.provider.DefaultConnection.getTheModel(DefaultConnection.java:107)
	at org.gradle.tooling.internal.consumer.connection.AdaptedConnection.getModel(AdaptedConnection.java:53)
	at org.gradle.tooling.internal.consumer.ModelProvider.provide(ModelProvider.java:57)
	at org.gradle.tooling.internal.consumer.connection.LazyConnection$2.run(LazyConnection.java:111)
	at org.gradle.tooling.internal.consumer.connection.LazyConnection.withConnection(LazyConnection.java:119)
	at org.gradle.tooling.internal.consumer.connection.LazyConnection.getModel(LazyConnection.java:108)
	at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConnection$2.run(ProgressLoggingConnection.java:67)
	at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConnection.run(ProgressLoggingConnection.java:81)
	at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConnection.getModel(ProgressLoggingConnection.java:65)
	at org.gradle.tooling.internal.consumer.connection.LoggingInitializerConnection.getModel(LoggingInitializerConnection.java:53)
	at org.gradle.tooling.internal.consumer.async.DefaultAsyncConnection$2.run(DefaultAsyncConnection.java:61)
	at org.gradle.tooling.internal.consumer.async.DefaultAsyncConnection$3.run(DefaultAsyncConnection.java:79)
	... 4 more
Caused by: java.io.EOFException
	at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2280)
	at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2749)
	at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:779)
	at java.io.ObjectInputStream.<init>(ObjectInputStream.java:279)
	at org.gradle.util.ClassLoaderObjectInputStream.<init>(ClassLoaderObjectInputStream.java:27)
	at org.gradle.cache.DefaultSerializer.read(DefaultSerializer.java:43)
	at org.gradle.cache.internal.SimpleStateCache.deserialize(SimpleStateCache.java:83)
	... 30 more


 Comments   
Comment by Luke Daley [ 10/Apr/12 ]

Proposed solution:

1. Amend the FileAccess interface so include something like FileIntegrityViolationException that implementations can throw if they detect that the integrity of the file being accessed may be compromised.
2. Update OnDemandFileAccess to use lock.getUnlockedCleanly() and throw FileIntegrityViolationException if that returns false
3. Add a FileAccess decorator that catches FileIntegrityViolationException and silently deletes the underlying File when this occurs
4. Use this decorator in PersistentDaemonRegistry

Comment by Luke Daley [ 10/Apr/12 ]

This would also involve adding a method on FileLock that deletes the file and the lock.

Comment by Adam Murdoch [ 10/Apr/12 ]

I wouldn't bother with 3, above. Sometimes the 'file' is a directory, sometimes it is a file. Sometimes the caller can recover, sometimes not. I think for now, we let the caller take care of recovering from the corruption.

Comment by Kris De Volder [ 25/Apr/12 ]

Fixed? This morning I found another STS/Gradle nightly integration build that had 32 test failures most of them with this or similar looking exception in it:

Caused by: org.gradle.api.GradleException: Could not read cache value from '/opt/bamboo-home/xml-data/build-dir/STS-STSGRADLEINTEGRATIONTESTS-JOB1/com.springsource.sts.gradle.core.test/target/.gradle/daemon/1.0-rc-2/registry.bin'.
	at org.gradle.cache.internal.SimpleStateCache.deserialize(SimpleStateCache.java:88)
	at org.gradle.cache.internal.SimpleStateCache.access$000(SimpleStateCache.java:26)
	at org.gradle.cache.internal.SimpleStateCache$1.create(SimpleStateCache.java:40)
	at org.gradle.cache.internal.DefaultFileLockManager$DefaultFileLock.readFromFile(DefaultFileLockManager.java:130)
	at org.gradle.cache.internal.OnDemandFileAccess.readFromFile(OnDemandFileAccess.java:36)
	at org.gradle.cache.internal.SimpleStateCache.get(SimpleStateCache.java:38)
	at org.gradle.launcher.daemon.registry.PersistentDaemonRegistry.getAll(PersistentDaemonRegistry.java:57)
	at org.gradle.launcher.daemon.registry.PersistentDaemonRegistry.getIdle(PersistentDaemonRegistry.java:72)
	at org.gradle.launcher.daemon.client.DefaultDaemonConnector.connect(DefaultDaemonConnector.java:65)
	at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:104)
	at org.gradle.tooling.internal.provider.DaemonGradleLauncherActionExecuter.execute(DaemonGradleLauncherActionExecuter.java:44)
	at org.gradle.tooling.internal.provider.DaemonGradleLauncherActionExecuter.execute(DaemonGradleLauncherActionExecuter.java:31)
	at org.gradle.tooling.internal.provider.LoggingBridgingGradleLauncherActionExecuter.execute(LoggingBridgingGradleLauncherActionExecuter.java:53)
	at org.gradle.tooling.internal.provider.LoggingBridgingGradleLauncherActionExecuter.execute(LoggingBridgingGradleLauncherActionExecuter.java:30)
	at org.gradle.tooling.internal.provider.DefaultConnection.run(DefaultConnection.java:113)
	at org.gradle.tooling.internal.provider.DefaultConnection.getTheModel(DefaultConnection.java:107)
	at org.gradle.tooling.internal.consumer.connection.AdaptedConnection.getModel(AdaptedConnection.java:53)
	at org.gradle.tooling.internal.consumer.ModelProvider.provide(ModelProvider.java:57)
	at org.gradle.tooling.internal.consumer.connection.LazyConnection$2.run(LazyConnection.java:111)
	at org.gradle.tooling.internal.consumer.connection.LazyConnection.withConnection(LazyConnection.java:119)
	at org.gradle.tooling.internal.consumer.connection.LazyConnection.getModel(LazyConnection.java:108)
	at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConnection$2.run(ProgressLoggingConnection.java:67)
	at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConnection.run(ProgressLoggingConnection.java:81)
	at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConnection.getModel(ProgressLoggingConnection.java:65)
	at org.gradle.tooling.internal.consumer.connection.LoggingInitializerConnection.getModel(LoggingInitializerConnection.java:53)
	at org.gradle.tooling.internal.consumer.async.DefaultAsyncConnection$2.run(DefaultAsyncConnection.java:61)
	at org.gradle.tooling.internal.consumer.async.DefaultAsyncConnection$3.run(DefaultAsyncConnection.java:79)
	... 4 more
Caused by: java.io.EOFException
	at java.io.ObjectInputStream$PeekInputStream.readFully(ObjectInputStream.java:2280)
	at java.io.ObjectInputStream$BlockDataInputStream.readShort(ObjectInputStream.java:2749)
	at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:779)
	at java.io.ObjectInputStream.<init>(ObjectInputStream.java:279)
	at org.gradle.util.ClassLoaderObjectInputStream.<init>(ClassLoaderObjectInputStream.java:27)
	at org.gradle.cache.DefaultSerializer.read(DefaultSerializer.java:43)
	at org.gradle.cache.internal.SimpleStateCache.deserialize(SimpleStateCache.java:83)
	... 30 more 
Comment by Luke Daley [ 25/Apr/12 ]

Yes, in 1.1. You're using 1.0.

Comment by Kris De Volder [ 25/Apr/12 ]

Ah, that explains it then. I am running the integration tests against the version published here:

http://services.gradle.org/versions/release-candidate

If there's nothing there (which right now it seems there isn't).

This one:
http://services.gradle.org/versions/current

Should my integration test perhaps run against some other version instead?

Kris

Comment by Luke Daley [ 25/Apr/12 ]

Use /versions/nightly

Generated at Wed Jun 30 12:15:53 CDT 2021 using Jira 8.4.2#804003-sha1:d21414fc212e3af190e92c2d2ac41299b89402cf.