Moving `lockOutputFiles` outside of the retry loop in `LocalSpawnRunner`.
@@ -167,7 +167,16 @@ public class LocalSpawnRunner implements SpawnRunner {
// check for failures while taking the lock.
context.lockOutputFiles(0, "", context.getFileOutErr());
}
- return new SubprocessHandler(spawn, context, spawnMetrics, totalTimeStopwatch).run();
+ var result = new SubprocessHandler(spawn, context, spawnMetrics, totalTimeStopwatch).run();
+ if (result.exitCode() != 0
+ && localExecutionOptions.localLockfreeOutput
+ && context.speculating()) {
+ // We aren't going to write any output, but we should either abort the remote branch early
+ // or let it finish if this error can be ignored. If the latter, this call will throw
+ // DynamicInterruptedException.
+ context.lockOutputFiles(result.exitCode(), "", context.getFileOutErr());
+ }
+ return result;
}
}
}
@@ -472,12 +481,6 @@ public class LocalSpawnRunner implements SpawnRunner {
wasTimeout ? SpawnResult.POSIX_TIMEOUT_EXIT_CODE : terminationStatus.getRawExitCode();
Status status =
wasTimeout ? Status.TIMEOUT : (exitCode == 0 ? Status.SUCCESS : Status.NON_ZERO_EXIT);
- if (exitCode != 0 && localExecutionOptions.localLockfreeOutput && context.speculating()) {
- // We aren't going to write any output, but we should either abort the remote branch early
- // or let it finish if this error can be ignored. If the latter, this call will throw
- // DynamicInterruptedException.
- context.lockOutputFiles(exitCode, "", outErr);
- }
spawnResultBuilder.setStatus(status).setExitCode(exitCode).setWallTime(wallTime);
if (status != Status.SUCCESS) {
spawnResultBuilder.setFailureDetail(makeFailureDetail(exitCode, status, actionType));
