2

I keep getting an this error on a regular basis. It's very inconsistent, sometimes it's there and very often it is not. I'm using durable task plugin in my pipeline code to run a shell command. I included in the log previous command, which a chmod that adds execution flag to the java file.

    Running in /var/lib/jenkins/jobs/My_Jobs/jobs/ubuntuvm04/workspace/build/tools/java/jre/bin

    [Pipeline] {

    [Pipeline] sh

    [bin] Running shell script

    + chmod +x ./java

    [Pipeline] sh

    [bin] Running shell script

    + sync

    [Pipeline] sh

    [bin] Running shell script

    + sleep 5

    [Pipeline] }

    [Pipeline] // dir

    [Pipeline] }

    [Pipeline] // stage

    [Pipeline] stage

    [Pipeline] { (check java version)

    [Pipeline] sh

    [workspace] Running shell script

    + ./build/tools/java/jre/bin/java -version

    /var/lib/jenkins/jobs/My_Jobs/jobs/ubuntuvm04/workspace@tmp/durable-b87cfd9e/script.sh: line 2: ./build/tools/java/jre/bin/java: Text file busy

.

I'm almost giving up on this error and I'm afraid I'll end up writing code to keep retrying to execute the failed line, but based on that error, does the Text file busy problem concerns script.sh that the plugin made, or the java file? that I'm trying to run

ammoun
  • 157
  • 1
  • 10
  • This is not a Jenkins specific problem. Please see e.g. [here](https://stackoverflow.com/questions/16764946/what-generates-the-text-file-busy-message-in-unix), [here](https://stackoverflow.com/questions/1384398/usr-bin-perl-bad-interpreter-text-file-busy), or [there](https://stackoverflow.com/questions/10638283/can-text-file-busy-happen-when-two-processes-trying-to-execute-a-perl-file-in). – Stefan Hanke Jun 28 '17 at 19:35
  • I did look at those before posting, and I believe this is Jenkins Plugin related since the plugin is the one creating workspace@tmp/durable-b87cfd9e/script.sh. I'm not even sure if the error is on script.sh file or java file? – ammoun Jun 28 '17 at 20:17
  • Looks like the `java` executable. Why do you `chmod` it? I'd say this constitutes a write, and could lead to that problem. Do jobs run simultaneously? – Stefan Hanke Jun 28 '17 at 20:23
  • There are jobs that run simultaneously but every one has its own workspace with a copy of this java executable. I chmod as for some reason the executable does not have -x as unzipped from an archive in a previous step. But isn't sleep 5, sync... enough? – ammoun Jun 28 '17 at 20:40

1 Answers1

1

The issue here appears to be caused by a Java bug, https://bugs.openjdk.java.net/browse/JDK-8068370.

The issue is possible when multiple threads open a file for writing, close it, and then execute them (each thread using its own file). Even if all files are closed "properly", due to how file handles work around fork/exec, a child process in one thread may inherit the handle to anther thread's open file, and thus break that thread's later subprocess call.

See similar issues:

Philippe GRANET
  • 453
  • 4
  • 7