Impala Public Jenkins has submitted this change and it was merged. ( 
https://gerrit.cloudera.org/25365 )

Change subject: IMPALA-15747: Fix flaky llvm-codegen-test caused by junitxml 
wrapper
......................................................................

IMPALA-15747: Fix flaky llvm-codegen-test caused by junitxml wrapper

junitxml_command_wrapper.sh captured the output of the wrapped command
with:

  "${COMMAND[@]}" > >(tee "${STDOUT_TMP_FILE}") \
      2> >(tee "${STDERR_TMP_FILE}" >&2)

Bash does not wait for process substitutions, so the wrapper could
exit as soon as the command itself had finished, while the tee
processes were still copying the command's stdout to the real stdout.
For a build step of the form 'command > file' this means that the step
was reported as done while 'file' could still be empty or only partly
written, and the next build step could read an incomplete file. 'wait'
cannot be used to fix this, because bash 4.4 (RHEL 8) only tracks the
most recently created process substitution.

This made llvm-codegen-test flaky:
-be/src/codegen/CMakeLists.txt generates llvm-ir/test-opt-inline.ll with
 'sed ... test-opt.ll > test-opt-inline.ll'.
-Then assembles it into llvm-ir/test-opt.bc with llvm-as.
-If the wrapper returned before the tee had written the whole file,
 llvm-as saw an empty or truncated .ll file,
-An empty file is valid input and results in a valid module without any
 functions, so the build succeeded and nothing was reported.
-LlvmOptTest then failed in LoadTestOpt() because
 GetFunction("_Z9loop_nullPii") returned null, and the test crashed when
 dereferencing the null function pointer.
-It depends on timing, so it only happens on loaded build machines.

The wrapper now redirects stdout and stderr of the command directly to
the temporary files, and replays them to stdout and stderr once the
command has finished. The data is fully written before the wrapper
exits, and stdout and stderr are still kept on separate streams. The
output of a wrapped command is now printed when the command finishes
instead of while it runs.

Testing:
-Reproduced the race locally by running the sed command above through
 the wrapper while all CPUs were busy and comparing the output size to
 the expected one. After the change, this doesn't reproduce.
-Verified that stdout and stderr remain separate, exit codes are
 propagated and the JUnitXML file is still generated when a wrapped
 command fails.
-Ran llvm-codegen-test, which passes.

Change-Id: I892735ddaca3e12c6381db15db3915e663bc1d8b
Assisted-by: Claude Sonnet 5.5 (GitHub Copilot)
Reviewed-on: https://gerrit.cloudera.org/25365
Reviewed-by: Impala Public Jenkins <[email protected]>
Tested-by: Impala Public Jenkins <[email protected]>
---
M bin/junitxml_command_wrapper.sh
1 file changed, 12 insertions(+), 6 deletions(-)

Approvals:
  Impala Public Jenkins: Looks good to me, approved; Verified

--
To view, visit https://gerrit.cloudera.org/25365
To unsubscribe, visit https://gerrit.cloudera.org/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I892735ddaca3e12c6381db15db3915e663bc1d8b
Gerrit-Change-Number: 25365
Gerrit-PatchSet: 3
Gerrit-Owner: Balazs Hevele <[email protected]>
Gerrit-Reviewer: Impala Public Jenkins <[email protected]>
Gerrit-Reviewer: Joe McDonnell <[email protected]>
Gerrit-Reviewer: Michael Smith <[email protected]>

Reply via email to