Bug 1465812 - [GSS](6.4.z) standalone.bat restart EAP unexpectedly
[GSS](6.4.z) standalone.bat restart EAP unexpectedly
Status: POST
Product: JBoss Enterprise Application Platform 6
Classification: JBoss
Component: Scripts and Commands (Show other bugs)
6.3.3
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Radovan STANCEL
Jiří Bílek
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-06-28 05:28 EDT by Hiroki Daicho
Modified: 2017-07-31 02:32 EDT (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
JBoss Issue Tracker JBEAP-12263 Major Verified standalone.bat restart EAP unexpectedly 2017-08-08 06:40 EDT
JBoss Issue Tracker JBEAP-12423 Major Pull Request Sent [7.0.z] standalone.bat restart EAP unexpectedly 2017-08-08 06:40 EDT
JBoss Issue Tracker WFCORE-3086 Major Resolved standalone.bat restart EAP unexpectedly 2017-08-08 06:40 EDT
Red Hat Knowledge Base (Solution) 3099441 None None None 2017-07-07 00:56 EDT

  None (edit)
Description Hiroki Daicho 2017-06-28 05:28:12 EDT
Description of problem:

By the following code in standalone.bat, domain.bat, EAP restarts unexpectedly when the ERRORLEVEL set more than 10.
> if ERRORLEVEL 10 goto RESTART

For example, when Shutting down Windows while EAP is running, exit code is set as 143 and EAP is restarted.
Originally, EAP expect 10 for restarting.
The value is defined as the following constant.
org.jboss.as.process.ExitCodes.RESTART_PROCESS_FROM_STARTUP_SCRIPT

Version-Release number of selected component (if applicable):
6.x, 7.x

How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:
Comment 1 Hiroki Daicho 2017-06-29 04:23:08 EDT
After the java process shutting down, exit code is put into ERRORLEVEL.
According to the following code, if the ERRORLEVEL is set more than 10, 
the "IF statement" will be true.

If EAP is runnning on Windows shutting down, the java process is finished with return code 143.

- standalone.bat

:RESTART
if x%XLOGGC% == x (
  "%JAVA%" %JAVA_OPTS% ^
   "-Dorg.jboss.boot.log.file=%JBOSS_LOG_DIR%\server.log" ^
   "-Dlogging.configuration=file:%JBOSS_CONFIG_DIR%/logging.properties" ^
      -jar "%JBOSS_HOME%\jboss-modules.jar" ^
      %MODULE_OPTS% ^
      -mp "%JBOSS_MODULEPATH%" ^
      -jaxpmodule "javax.xml.jaxp-provider" ^
       org.jboss.as.standalone ^
      "-Djboss.home.dir=%JBOSS_HOME%" ^
       %SERVER_OPTS%
) else (
  "%JAVA%" -Xloggc:%XLOGGC% %JAVA_OPTS% ^
   "-Dorg.jboss.boot.log.file=%JBOSS_LOG_DIR%\server.log" ^
   "-Dlogging.configuration=file:%JBOSS_CONFIG_DIR%/logging.properties" ^
      -jar "%JBOSS_HOME%\jboss-modules.jar" ^
      %MODULE_OPTS% ^
      -mp "%JBOSS_MODULEPATH%" ^
      -jaxpmodule "javax.xml.jaxp-provider" ^
       org.jboss.as.standalone ^
      "-Djboss.home.dir=%JBOSS_HOME%" ^
       %SERVER_OPTS%
)

if ERRORLEVEL 10 goto RESTART
Comment 2 Hiroki Daicho 2017-06-29 21:35:18 EDT
According to following example, "IF statement" of windows batch doesn't mean "EQUAL" validation.
It runs as "ERRORLEVEL >= 0".

- example_if_statement.bat
@echo off
# failed to call wrong api. ERRORLEVEL will be set to 1.
call :aa
echo %ERRORLEVEL% 
if ERRORLEVEL 0 echo TRUE

- result
> 1
> TRUE
Comment 3 Hiroki Daicho 2017-06-30 02:47:53 EDT
- Reported case
 - When the OS shutting down during EAP is still running. (exit code 143)
 - Shutting down with Ctrl+C and answering No for question of "Terminate batch job <Y/N>?". (exit code 130)

- Workaround
change the IF statament in standalone.bat/domain.bat as follows.

if %ERRORLEVEL%==10 goto RESTART
or
if %ERRORLEVEL% EQU 10 goto RESTART

Note You need to log in before you can comment on or make changes to this bug.