Wrong Java version on Debian: a race condition

Lucid Software validates every pull request for its internal code base. Running over 1000 builds a day across 80 projects strains the robustness of our code, tests, and tools.

For example, several times a week, builds complained about the default Java version. It didn’t make much sense. Our servers are configured by Chef, which runs at boot and every 30 minutes thereafter. During each run, update-java-alternatives sets Java 8 as the default. But somehow, the build servers were occasionally using an older version.

Each time update-java-alternatives ran, it reset Java to the “automatic default”, which for Ubuntu 14.04 is Java 7. It then set Java back to the requested version. Any build that started a JVM in the intervening few milliseconds failed.

Try it yourself. Poll the symlink:
$ while :; do readlink /etc/alternatives/java; sleep 0.01; done
And then run update-java-alternativtes:
$ sudo update-java-alternatives -s java-1.8.0-openjdk-amd64
Watch the left terminal closely, and you can see the Java version regress.

A patch is available on the Debian bug tracker for the java-common package.

No Comments, Be The First!

Your email address will not be published.