Bug 963167

Summary: Unable to complete tasks when server is shutdown
Product: [JBoss] JBoss Operations Network Reporter: Thomas Segismont <tsegismo>
Component: Core ServerAssignee: Thomas Segismont <tsegismo>
Status: CLOSED CURRENTRELEASE QA Contact: Mike Foley <mfoley>
Severity: medium Docs Contact:
Priority: medium    
Version: JON 3.1.2CC: hrupp, loleary, mazz
Target Milestone: ER01   
Target Release: JON 3.2.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 957689 Environment:
Last Closed: 2014-01-02 20:43:00 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 957689, 958217    
Bug Blocks:    

Description Thomas Segismont 2013-05-15 10:03:02 UTC
+++ This bug was initially created as a clone of Bug #957689 +++

Description of problem:
When the server is shutdown, several components (datasources, ejbs) go down before RHQ's shutdown listener code completes.

Version-Release number of selected component (if applicable):
4.6

How reproducible:
Always

Steps to Reproduce:
1. Add a 'Thread.sleep' statement in Data Purge Job code
2. Change the scheduling code to start the Data Purge Job 30 seconds after server startup
2. Rebuild, start, wait and stop the server when purge job is executed
  
Actual results:
Errors in the server log: http://pastebin.test.redhat.com/138892

Expected results:
The server should not go down until data purge job and shutdown listener code finish.

Additional info:
To be verified: it looks like AS7, unlike AS 4.2.3, does not wait for our Shutdown listener code to complete execution before shutting down all resources (datasources, EJBs, etc...)

--- Additional comment from Thomas Segismont on 2013-04-30 15:29:02 CEST ---

Before RHQ4.6, shutdown listener was implemented as a JMX notification listener. Now it is implemented as a Singleton bean and shutdown logic is in the @PreDestroy method.

It's not really needed to hack the Data Purge Job code to show this. Almost always, when you hit Ctrl-C on a server started in console mode, you'll see the same exception message:

javax.ejb.EJBException: JBAS014559: Invocation cannot proceed as component is shutting down 

This message was introduced in this AS7 pull request:
https://github.com/wildfly/wildfly/pull/1889

Calling @EJB methods in @PreDestroy callbacks is normally allowed by the spec. Somebody reported similar (but not same) problem and the issue was accepted and resolved:
https://community.jboss.org/message/764240
https://issues.jboss.org/browse/AS7-4808

Note: shutdown notification should come back in Wildfly
http://lists.jboss.org/pipermail/jboss-as7-dev/2012-April/005834.html

Comment 1 Thomas Segismont 2013-06-25 14:21:16 UTC
Fixed in master

See comment https://bugzilla.redhat.com/show_bug.cgi?id=957689#c3

Comment 2 Thomas Segismont 2013-06-28 10:50:35 UTC
Second commit in master

See comment https://bugzilla.redhat.com/show_bug.cgi?id=957689#c4

Comment 3 Larry O'Leary 2013-09-06 14:30:59 UTC
As this is MODIFIED or ON_QA, setting milestone to ER1.