Kbase P5586: How to handle database disconnections gracefully from the 4GL
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  03/12/2009 |
|
Status: Unverified
GOAL:
How to handle database disconnections gracefully from the 4GL
GOAL:
How to capture and handle socket errors using ABL ?
FACT(s) (Environment):
Progress 9.x
OpenEdge 10.x
All Supported Operating Systems
FIX:
Normally, when a database disconnects due to a network error or execution of the PROSHUT utility, Progress raises an untrappable STOP condition and unwinds the procedure call stack to the point above which no procedures reference the disconnected database. At that point Progress converts the untrappable STOP condition to a trappable STOP condition. Before unwinding the call stack, Progress also deletes any persistent procedures that reference the disconnected database.
Run the following sample against a sports database, connected via client-server:
/* outer.p */
/* Start off with no database connections. */
CONNECT sports.
main-block:
DO ON STOP UNDO main-block, RETRY main-block:
IF RETRY THEN DO:
MESSAGE "RETRY block in outer.p" VIEW-AS ALERT-BOX.
LEAVE main-block.
END.
RUN inner.p.
END.
MESSAGE "Outside main-block in outer.p" VIEW-AS ALERT-BOX.
/* inner.p */
main-block:
DO ON STOP UNDO main-block, RETRY main-block:
IF RETRY THEN DO:
MESSAGE "RETRY block in inner.p" VIEW-AS ALERT-BOX.
LEAVE main-block.
END.
FOR EACH customer:
DISPLAY customer EXCEPT comments WITH 2 COLUMNS.
END.
END.
MESSAGE "Outside main-block in inner.p" VIEW-AS ALERT-BOX.
When the inner.p is pausing to view more customer records, pull the network plug and then press the space bar. After some time you'll see the following errors:
Error reading socket, ret=10054, errno=2. (778)
** Incomplete write when writing to the server. (735)
After these two messages are displayed, a STOP condition is generated.
Because inner.p references the database, the STOP condition is untrappable and the RETRY block in inner.p is not executed. On the other hand, outer.p does not reference the database, therefore the STOP condition becomes trappable, and the messages "RETRY block in outer.p" and "Outside main-block in outer.p" are displayed.