George Potemkin
Member
Documentation says:
docs.progress.com
There are two recommended practices for cleaning up after using datasets in your code:
DETACH-DATA-SOURCE
EMPTY-DATASET
IMHO, it’s true only partially.
I wrote demo.p that runs the procedure A that calls procedure B. Procedure B creates a dataset with one temp-table record and returns it to A as “OUTPUT DATASET-HANDLE hDataset”.
Through the code’s execution demo.p checks the number of the session’s objects:
SESSION:FIRST-<Object> + NEXT-SIBLING.
Namely FIRST-BUFFER and FIRST-DATASET.
Result:
Procedure A cleans up after using a dataset but I don’t see how it would be possible to do the same in procedure B. Each run of it leaves a dataset with its buffer(s) in memory and its records in DBI files.
A bit more complicated demo program allows to run the procedure B on appserver (classic or PAS) and it confirms that the sizes of DBI files of the session running procedure B keeps growing with every its call. All records created by all calls are stored in DBI file. The only way to clean up is to restart a session. The customer's case: they got a DBI file of about 100 GB.
After running demo.p we are going back to Progress editor. All instances of the previously created datasets are still available for the session. But editor cleans up the buffers!
The following code will crash the session:
Tested with V10.2B and 12.8 on Windows and Linux.
What I missed? How to clean up after a procedure that sends a dataset as OUTPUT DATASET-HANDLE?
Progress Documentation
DETACH-DATA-SOURCE
EMPTY-DATASET
IMHO, it’s true only partially.
I wrote demo.p that runs the procedure A that calls procedure B. Procedure B creates a dataset with one temp-table record and returns it to A as “OUTPUT DATASET-HANDLE hDataset”.
Through the code’s execution demo.p checks the number of the session’s objects:
SESSION:FIRST-<Object> + NEXT-SIBLING.
Namely FIRST-BUFFER and FIRST-DATASET.
Result:
Code:
# Breakpoint Datasets Buffers
1 Test is beginning... 0 0
2 A: Before OUTPUT DATASET-HANDLE 0 0
3 B: Before CREATE TEMP-TABLE 0 0
4 B: After CREATE TEMP-TABLE 0 0
5 B: Before CREATE DATASET 0 1
6 B: After CREATE DATASET 1 1
7 B: After DETACH-DATA-SOURCE 1 1
8 A: After OUTPUT DATASET-HANDLE 2 2
9 A: After GET-BUFFER-HANDLE 2 2
10 A: Before EMPTY-DATASET 2 2
11 A: After EMPTY-DATASET 2 2
12 A: After DELETE hDataset 1 1
13 Test is finished 1 1
Checking from Progress editor 1 0
A bit more complicated demo program allows to run the procedure B on appserver (classic or PAS) and it confirms that the sizes of DBI files of the session running procedure B keeps growing with every its call. All records created by all calls are stored in DBI file. The only way to clean up is to restart a session. The customer's case: they got a DBI file of about 100 GB.
After running demo.p we are going back to Progress editor. All instances of the previously created datasets are still available for the session. But editor cleans up the buffers!
Code:
DEFINE VARIABLE hDataset AS HANDLE NO-UNDO.
DEFINE VARIABLE hBuffer AS HANDLE NO-UNDO.
ASSIGN hDataset = SESSION:FIRST-DATASET.
DISPLAY "VALID-HANDLE(FIRST-DATASET):" VALID-HANDLE(hDataset) SKIP.
IF VALID-HANDLE(hDataset) THEN
ASSIGN hBuffer = hDataset:GET-BUFFER-HANDLE(1).
DISPLAY "VALID-HANDLE(GET-BUFFER-HANDLE):" VALID-HANDLE(hBuffer) SKIP.
ASSIGN hBuffer = SESSION:FIRST-BUFFER.
DISPLAY "VALID-HANDLE(FIRST-BUFFER):" VALID-HANDLE(hBuffer) SKIP.
Code:
DEFINE VARIABLE hDataset AS HANDLE NO-UNDO.
ASSIGN hDataset = SESSION:FIRST-DATASET.
hDataset:EMPTY-DATASET.
What I missed? How to clean up after a procedure that sends a dataset as OUTPUT DATASET-HANDLE?