Gossamer Forum
Home : Products : DBMan : Customization :

adding fails sometimes

Quote Reply
adding fails sometimes
Hello,

I have the dbman script running for some weeks and it is working fine in the past.

Now there is a problem:

The script doesn't add some records to the 'file.db' - file.

After some time (about 6 to 12 hours) the script is writing again the records the users are adding to the db-file without intervention of myself.

In the 'file.log' - file there is reported that the records are added.

The users didnt receive any error messages.

After this happened and i got notice of that, i'm writing to two db-files successively.

To: 'file.db' and 'file_sich.db'. The 2 files are in the same directory, the log-file too.

The script works the about 2 weeks fine and in the last days there was the same error:

in the 'file.db' - file i'm missing some records - in the 'file_sich.db' these record are existent, and the 'file.log' - file is ok too.

I'm using the ms iis 4.0 service pack 6 on an intel p3 machine. i'm using activeperl from Activestate in the version 5.61.

There are about 30 users which are using the script. The size of the db-file is about 350 records and 30 kByte.

According to the 'file.log' -file there was no problem of concourrent access when adding records.

On the NT-Error logfiles i can't figure out some anomaly behavior.

Has anyone a problem alike above described? Has anyone an idea what's going wrong.

Many Thanks - Phil
Quote Reply
Re: [philohnehund] adding fails sometimes In reply to
Hello,

i've found an answer, which seems me to be possible:

in the adding/modify/delete functions the open/flock commands have to be changed to sysopen.

For doing this you have to add to the script (db.cgi at the beginning):

use Fcntl qw/:DEFAULT :flock/;

Then change the code from:

sysopen (DB, ">>$db_file_name") or &cgierr("error in add_record. --- snipp;

flock(DB, 2) or &cgierr("unable to get exclusive lock on $db_fil -- snipp;

print DB &join_encode(%in);

close DB; # automatically removes file lock

To:

sysopen (DB, $db_file_name, O_WRONLY|O_APPEND) or &cgierr("error in -- snipp;

flock(DB, LOCK_EX) or &cgierr("unable to get exclusive lock on -- snipp;

print DB &join_encode(%in);

close DB; # automatically removes file lock

I Hope this will solve my problems.

If you have another idea - please post it.

Thanks - to all - this is a great forum, i've got a lot of tipps out of here.

Merry Christmas - Phil