gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[open-cobol-list] Re: Index Files.


From: Louis Castoria
Subject: [open-cobol-list] Re: Index Files.
Date: Mon Nov 14 13:00:02 2005
User-agent: Thunderbird 1.5 (Windows/20051025)

File syncing is done in MF COBOL on indexed files. I don't know the details on how they do it. If they didn't I would have a thousand or so customers with pitch forks and torches ready to burn down my building. Yes there is no doubt doing a sync after a write is slower but is also more stable. Yes! I agree that there is NO guarantee that file sync will be perfect. But it is a lot better than what happens now. Its a trade off that acceptable to my and probably all Cobol applications that are not batch oriented. Yes. I did read the documentation on Berkeley DB before I made the change and understood it would be slower and not perfect. File transactions is the way to go if you are going to stick with indexed files. Just for the hell of it I looked at the TinyCobol fileio.c and they have sync enabled on an ifdef. I think this should be an option given. I've looked into both Tiny and Open and think Open is going in a good direction. I hope in the future I can use OPEN COBOL for my applications.

Now My Ramblings:
Personally, I would not waste my time and add file transaction. I would implement SQL database transactions instead. That would put Open Cobol ahead the competition.

Imagine This:

SELECT TERMINALFL
       ASSIGN TO TERMINALFL-TABLE
ORGANIZATION IS DATABASE-POSTGRESQL ACCESS IS DYNAMIC
       IPADDRESS 127.0.0.1
PORT 5432 RECORD KEY IS TF-KEY FILE STATUS IS TERMINALFL-STATUS.
COBOL READ generates the select.
COBOL WRITE generates an insert.



           Louis  Castoria  -  ADSI
           Software Engineer
           1930 First Commercial  Drive
           Southaven MS,  38671
           Phone: 662-393-2046
           WEB: http://www.e9.com


Roger While wrote:
The intention is good.
The implementation is not.
I have played around with sync'ing before (both for IS
and normal files)

So, some comments.
Let's start with a application program that I have that loads
ca. 750,000 records.
This normally takes a minute or so on one of my big boxen.
With sync'ing, I terminated the run after 2 hours.
It's obvious that we don't want to do this unconditionally.

Also from Berkeley DB -
http://www.sleepycat.com/docs/gsg/C/usingDbt.html#datapersist

Other Cobol's (using standard file handler facilities) also
do not sync I/O (MF, ACU). Note, however, that
"extended file handler" facilities may allow this.


Lets be very clear here that, without file transaction facilities,
there is NO guarentee that file contents are correct if the
run-unit terminates abnormally eg. System crash, program crash.

Following mainly relates to IS I/O (but not exclusively).

What is a concern is when a program does NOT "CLOSE" a file.
(But otherwise terminates normally over a "STOP RUN").
In this case, what we can do is :
(Note 1)Maintain an open file list in libcob/fileio.c
In cob_stop_run, call an I/O exit function that checks the
open file list for non-closed files. If detected, close the file and produce
a warning on stderr.
This is OK for non-transaction file I/O.

This is NOT OK when we eventually get transaction file I/O.
If a program does NOT close the file, it would be assumed that the
program wants a rollback.

Some notes on sync'ing.

System:
Start at low-level -
Disks these days (and for SCSI has been standard for many years) have physically
their own cache.
Data Point 1 ) - Are your disks caching data ?
Data Point 2 ) - What are the controller settings (BIOS) ?
Controllers, specifically cache/raid, have their own cacheing/settings for DP1. Also, Cache policies might be involved (write-back, write-through)
Get to Kernel
Data Point 3) - What are the driver settings ?
                       Are we write-(though|back)?
                       eg. megaraid (Perc xx) assumes write-through)

Get to file system
Data Point 4) - What are the mount options for the file system ?
                       (Assumptions made here that affect recovery)

Now, because of the Data Points above, it maybe that whatever you do, you
are going to land up with something you did not expect when a system crash occurrred.

Program :
We could, theorectically, set a trap signal on
SIGINT, SIGHUP, SIGQUIT and implement Note 1.


----

A fflush on an opened file pointer (and likewise a DB->sync) will not
have expicitely the desired effect.

I will look at implementing Note 1 above until as such time that
we implement transaction file processing.



There is a bug in the fileio.c program.  The data does not get synced
after every write, rewrite, or delete.  It gets left in cashe and  If
the program terminates abnormally  or does not close the file before
exiting all or some file writes, rewrites, and deletes can be lost.  I
fixed the fileio.c program on my system to sync after any write,
rewrite, or delete.  If anyone is interested in this code let me know.
This update needs to be in the standard release of this product if you
desire stable indexed file I-O.








reply via email to

[Prev in Thread] Current Thread [Next in Thread]