Kbase 17847: What Appserver Should do When a Client Exits Ungracefully
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  12/06/2002 |
|
SUMMARY:
This solution applies to Progress AppServer.
The following code is a CREATE SERVER statement that creates a server
handle, on Progress version 8, by which we can connect to an AppServer:
DEFINE VARIABLE hAppSrv AS HANLE NO-UNDO.
DEFINE VARIABLE ret AS LOGICAL NO-UNDO.
CREATE SERVER hAppSrv.
ret = hAppSrv:CONNECT("-S service -H host").
IF NOT ret THEN
RETURN ERROR "Failed to connect to AppServer".
Notice the -S and -H. They establish the client server connection
essential to successfully connect to the AppServer instance.
For version 9, the connection parameter are a bit different, but the concept is the same.
Refer to the Building Distributed Applications Using the Progress AppServer Guide.
An AppServer is spawned by the AppServer broker when the broker gets
a request from a client that it needs an AppServer. Under normal circumstances and GRACEFULL disconnects from the client machine, we execute the code on page 5-10 of the Building Distributed Applications with the Progress AppServer guide. The code is as follows:
ret=hAppSrv:DISCONNECT().
DELETE OBJECT hAppSrv.
This code allows the AppServer process to disconnect as it has been
informed by the application that the client is disconnecting. Since
there is a one-to-one ratio between the client and AppServer, the
AppServer processes' sole purpose is to service that client, hence
the disconnection when the client goes away.
This knowledgebase article is devised to explain what should happen to
the AppServer process if the DELETE OBJECT statement does not get executed due to an ungraceful logoff.
TCP or socket keepalive is a mechanism with TCP/IP that allows a
process to time out and be disconnected if there is no activity for a
set period of time or if a connection is dropped. How this works is
that the TCP daemon runs to monitor activity on a process. If there is
no activity on the process for the time period defined by socket
keepalive (see Solution # 13493) then the TCP stack sends an empty probe packet to the process to check and see if it is still out there. If there is no response to the probe packet for the time period defined by the socket keepalive setting then it notifies the parent process that the child is dead and sends a connection reset to the parent which in turn shuts itself down. Once this TCP connection is lost it cannot be reestablished.
How this all affects AppServer is somewhat complex but plausible.
Since connecting to the AppServer instance is a network connection,
we are relying on a client disconnection to send a hangup signal to
Progress, in which case we have a GRACEFUL logoff. When this occurs,
the disconnect code mentioned earlier in the article executes and the
AppServer is able to shut itself down when the signal is sent and the
code is executed. If the signal does not get sent for a reason such as
a user powering off their pc, or closing a window on a terminal
emulator, then the shutdown code does not get executed and the
AppServer process stays active as it is not aware of the disconnected
client. If TCP keepalive is functioning as explained earlier in the
article, then it should cause the AppServer process to shut itself
down (on version 8) or to return to the 'AVAILABLE' state, on version 9.
One of the potentially confusing parts of this is the physical
location of the AppServer with respect to the client and the
database. Regardless of the location of the AppServer, whether local
to the database or the client machine, if TCP is functioning properly
then Keepalive should take care of any AppServer process left out
there by a dead client that did not send a signal.
This has been tested on several different platforms with the AppServer
residing both locally to the client and then local to the database
and has performed as expected in all situations. If the AppServer
process is not shutting itself down then speak with your Operating
System vendor to verify the TCP keepalive is functioning correctly.
For AppServer version 9, the keepalive option is not enabled by default for client-side sockets. That means the keepalive will not work for Stateless AppServer, and you may see server process in the CONNECTED / LOCKED state when querying the broker.
This keepalive option is implemented in the latest patches for 9.1C and in 9.1D. The server process will release the Application Server process after a connection failure based on the keepalive setting, and the server process will be shown as AVAILABLE.