Solved

Flatfile database over NFS (CGI)

Posted on 1998-07-03
8
274 Views
Last Modified: 2010-03-18
We use two machines, one webserver and one for data which is nfs mounted on the webserver. Using a webinterface, I want people to add records to a flatfile database (using perl). I have to lock the file because I dont want two people adding records at the same time, this will mess up the database. I think I have to use the rpc.lockd daemon but it doesnt exist on my debian ditribution, Some people say this is impossible because of the caching of NFS.
0
Comment
Question by:bjornh
  • 4
  • 4
8 Comments
 
LVL 3

Expert Comment

by:marcelofr
ID: 1584663
Some people are right... you must avoid such a thing. There NO NFS locking implementation that really works... but...

I assume people whould like to read the file, not only add records... but, why don't you do it with sockets with perl?

Good Luck,

--Marcelo
0
 

Author Comment

by:bjornh
ID: 1584664
I know how to use sockets but what do you want to accomplish with that?

In my current implementation I use a semaphore file containing the pid of the proces and so far no more problems did occur. I think this should be completely safe, no other proces will read from the file when another proces is busy. Will this work or is it still dangerous (due to caching)?
0
 
LVL 3

Expert Comment

by:marcelofr
ID: 1584665
Of course... I believe the process opens the file, reads its contents, determines if the pid stored on it is still alive, if not, it writes its own pid to the file... How can you be sure all this is done atomically even without NFS... Any way you can have a process that auto-locks its own binary: this is better, but still you can have a race condition while loading the binary. You can go further, and use named pipes which will manage up to 4kb atomically and make it work locally, but then, why don't have the file local, and share it to the data server (I can hear you shouting that this approach breaks your servers functionalities ;-)

To can get close to 100% safe algoritm in your web server side, but you can't be sure of what you have on the data server side unless the filesystem is unmounted...

Good Luck

-- Marcelo
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:bjornh
ID: 1584666
Marcelo,

Thank you for your respone, I think you're right. If you answer the question I can give you the 100 points.

Thanks again,
Bjorn
0
 
LVL 3

Expert Comment

by:marcelofr
ID: 1584667
you forgot the check box ;-)
0
 

Author Comment

by:bjornh
ID: 1584668
Check box?
0
 
LVL 3

Accepted Solution

by:
marcelofr earned 100 total points
ID: 1584669
To "give the 100 points" you are supposed to check a box telling so (probably in the same page you are looking at now) and also rate the answer with an A, B etc. grade ;-)
0
 

Author Comment

by:bjornh
ID: 1584670
That's right. But to do that you have to _answer_ the question, I cant give you points if you only add a comment. Anyway, my database works perfect now.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have seen several blogs and forum entries elsewhere state that because NTFS volumes do not support linux ownership or permissions, they cannot be used for anonymous ftp upload through the vsftpd program.   IT can be done and here's how to get i…
Note: for this to work properly you need to use a Cross-Over network cable. 1. Connect both servers S1 and S2 on the second network slots respectively. Note that you can use the 1st slots but usually these would be occupied by the Service Provide…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now