Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-10785

failure to terminate logcat reading for android emulator

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Labels:
      None
    • Environment:
      Jenkins 1.426 with Android emulator plugin 1.16-SNAPSHOT.
      Slave/emulator running on Windows 7 with android SDK 11
      Jenkins master running on Ubuntu 10.04.
    • Similar Issues:

      Description

      Whilst investigating occasional failure to shutdown the android emulator processes during a jenkins build (see JENKINS-10639) I noticed that the logcat copier threads were not shutdown from a previous build.

      My slave Thread Dump included the following about 30 minutes after the associated job had completed.

      C:\Android\android-sdk11/platform-tools/adb.exe -s emulator-57045 logcat -v time: stderr copier
      "C:\Android\android-sdk11/platform-tools/adb.exe -s emulator-57045 logcat -v time: stderr copier" Id=1588 Group=main RUNNABLE (in native)
      at java.io.FileInputStream.readBytes(Native Method)
      at java.io.FileInputStream.read(Unknown Source)
      at hudson.util.StreamCopyThread.run(StreamCopyThread.java:60)
      
      C:\Android\android-sdk11/platform-tools/adb.exe -s emulator-57045 logcat -v time: stdout copier
      "C:\Android\android-sdk11/platform-tools/adb.exe -s emulator-57045 logcat -v time: stdout copier" Id=1587 Group=main RUNNABLE (in native)
      at java.io.FileInputStream.readBytes(Native Method)
      at java.io.FileInputStream.read(Unknown Source)
      at java.io.BufferedInputStream.read1(Unknown Source)
      at java.io.BufferedInputStream.read(Unknown Source)
      - locked java.io.BufferedInputStream@17502df
      at java.io.FilterInputStream.read(Unknown Source)
      at hudson.util.StreamCopyThread.run(StreamCopyThread.java:60)
      

      In this case the debug information that I had added to the emulator shutdown told me that the call to "sendEmulatorCommand" failed because the emulator telnet interface did not respond. Hence killed was false and the {{logcatProcess.kill() }} call was never made.

          if (logcatProcess != null) {
              logcatStream.close();
              if (killed && logcatProcess.isAlive()) {
                  // This should have stopped when the emulator was,
                  // but if not attempt to kill the process manually
                  logcatProcess.kill();
              }
      
              // Archive the logs
              if (logcatFile.length() != 0) {
                  log(logger, Messages.ARCHIVING_LOG());
                  logcatFile.copyTo(new FilePath(artifactsDir).child("logcat.txt"));
              }
              logcatFile.delete();
          }
      

      I think that the cleanup routine should always kill the logcat process if it is still alive. Maybe it should give a little grace period where it just polls to give the process a chance to shut down normally.

      I will see if I can find some time to put a patch together.

        Attachments

          Activity

          Hide
          oldelvet Richard Mortimer added a comment -
          Show
          oldelvet Richard Mortimer added a comment - Pull request submitted. https://github.com/jenkinsci/android-emulator-plugin/pull/4
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Richard Mortimer
          Path:
          src/main/java/hudson/plugins/android_emulator/AndroidEmulator.java
          http://jenkins-ci.org/commit/android-emulator-plugin/3890aa7c656abaf25e9457227bb31b9e6b263905
          Log:
          JENKINS-10785 failure to terminate logcat reading for android emulator

          safely close logcatStream after killing the logcatProcess.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Richard Mortimer Path: src/main/java/hudson/plugins/android_emulator/AndroidEmulator.java http://jenkins-ci.org/commit/android-emulator-plugin/3890aa7c656abaf25e9457227bb31b9e6b263905 Log: JENKINS-10785 failure to terminate logcat reading for android emulator safely close logcatStream after killing the logcatProcess.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Richard Mortimer
          Path:
          src/main/java/hudson/plugins/android_emulator/AndroidEmulator.java
          http://jenkins-ci.org/commit/android-emulator-plugin/7dd83c174c95933ea222919f517e15585d3d6168
          Log:
          JENKINS-10785 failure to terminate logcat reading for android emulator

          Always try to terminate the logcat reader if it has not closed itself.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Richard Mortimer Path: src/main/java/hudson/plugins/android_emulator/AndroidEmulator.java http://jenkins-ci.org/commit/android-emulator-plugin/7dd83c174c95933ea222919f517e15585d3d6168 Log: JENKINS-10785 failure to terminate logcat reading for android emulator Always try to terminate the logcat reader if it has not closed itself.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Christopher Orr
          Path:
          src/main/java/hudson/plugins/android_emulator/AndroidEmulator.java
          http://jenkins-ci.org/commit/android-emulator-plugin/0515f6c6a123b8749b610b8d4ee6d95974de675a
          Log:
          Merge pull request #4 from oldelvet/110819-logcat-cleanup

          [FIXED JENKINS-10785] Ensure logcat process is properly terminated.

          Compare: https://github.com/jenkinsci/android-emulator-plugin/compare/aaa15e3...0515f6c

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Christopher Orr Path: src/main/java/hudson/plugins/android_emulator/AndroidEmulator.java http://jenkins-ci.org/commit/android-emulator-plugin/0515f6c6a123b8749b610b8d4ee6d95974de675a Log: Merge pull request #4 from oldelvet/110819-logcat-cleanup [FIXED JENKINS-10785] Ensure logcat process is properly terminated. Compare: https://github.com/jenkinsci/android-emulator-plugin/compare/aaa15e3...0515f6c
          Hide
          orrc Christopher Orr added a comment -

          Version 1.18 has now been released, which includes this update.

          Show
          orrc Christopher Orr added a comment - Version 1.18 has now been released, which includes this update.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Richard Mortimer
          Path:
          src/main/java/hudson/plugins/android_emulator/AndroidEmulator.java
          http://jenkins-ci.org/commit/android-emulator-plugin/3890aa7c656abaf25e9457227bb31b9e6b263905
          Log:
          JENKINS-10785 failure to terminate logcat reading for android emulator

          safely close logcatStream after killing the logcatProcess.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Richard Mortimer Path: src/main/java/hudson/plugins/android_emulator/AndroidEmulator.java http://jenkins-ci.org/commit/android-emulator-plugin/3890aa7c656abaf25e9457227bb31b9e6b263905 Log: JENKINS-10785 failure to terminate logcat reading for android emulator safely close logcatStream after killing the logcatProcess.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Richard Mortimer
          Path:
          src/main/java/hudson/plugins/android_emulator/AndroidEmulator.java
          http://jenkins-ci.org/commit/android-emulator-plugin/7dd83c174c95933ea222919f517e15585d3d6168
          Log:
          JENKINS-10785 failure to terminate logcat reading for android emulator

          Always try to terminate the logcat reader if it has not closed itself.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Richard Mortimer Path: src/main/java/hudson/plugins/android_emulator/AndroidEmulator.java http://jenkins-ci.org/commit/android-emulator-plugin/7dd83c174c95933ea222919f517e15585d3d6168 Log: JENKINS-10785 failure to terminate logcat reading for android emulator Always try to terminate the logcat reader if it has not closed itself.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Christopher Orr
          Path:
          src/main/java/hudson/plugins/android_emulator/AndroidEmulator.java
          http://jenkins-ci.org/commit/android-emulator-plugin/0515f6c6a123b8749b610b8d4ee6d95974de675a
          Log:
          Merge pull request #4 from oldelvet/110819-logcat-cleanup

          [FIXED JENKINS-10785] Ensure logcat process is properly terminated.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Christopher Orr Path: src/main/java/hudson/plugins/android_emulator/AndroidEmulator.java http://jenkins-ci.org/commit/android-emulator-plugin/0515f6c6a123b8749b610b8d4ee6d95974de675a Log: Merge pull request #4 from oldelvet/110819-logcat-cleanup [FIXED JENKINS-10785] Ensure logcat process is properly terminated.

            People

            • Assignee:
              oldelvet Richard Mortimer
              Reporter:
              oldelvet Richard Mortimer
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: