Solved

Flatfile database over NFS (CGI)

Posted on 1998-07-03
8
263 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
 

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
New! My Passport Wireless Pro Wi-Fi Mobile Storage

Portable wireless storage to offload, edit, and stream anywhere.

High-capacity, wireless mobile storage designed to accompany professional photographers and videographers in the field to easily offload, edit and stream captured photos and high-definition videos.

 
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

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Question has a verified solution.

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

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 hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

912 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

24 Experts available now in Live!

Get 1:1 Help Now