The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
will a named pipe always be size 0 on filesystem? JamesByars UNIX for Advanced & Expert Users 4 03-01-2008 04:39 PM
Named Pipe contents to a file carl_vieyra UNIX for Dummies Questions & Answers 4 02-27-2007 12:33 AM
Named PIPE Tamil UNIX for Dummies Questions & Answers 2 01-17-2007 03:20 AM
IPC using named pipe sharanbr High Level Programming 2 02-16-2006 12:01 PM
IPC using named pipe sharanbr UNIX for Advanced & Expert Users 1 02-15-2006 04:24 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 01-09-2007
heck heck is offline
Registered User
  
 

Join Date: Oct 2006
Location: Switzerland
Posts: 8
named pipe with persistent buffer

Hey folks,
i need communicate between 2 processes in a reliable manner. The information delivery has to be guarenteed. I thought about proc 2 sending a signal to proc 1 when information has being written to disc and wirte() has been verified (sync/flush). The IPC method for the data is named pipes.

When proc1 simply writes the data to the named pipe, and the system crashes before proc2 could read it and persistently save it to disc the information is lost.

So my solution to this is:

proc1:
has opened a phys. file, tmpfile; and a named pipe
1. writes data to tmpfile on disc, verify write()
2. writes the data to pipe
3. waits for signal from proc 2

proc2:
has select or poll to the pipe
1. writes data to disc on pipe change, verifiy write()
2. sends signal to proc 1, meaning data is persistently saved.

prioc1:
4. emtpys tmpfile

what do you think about this idea?
Is the pipe necessary?
Could i as well read the physical tmpfile from proc2 instead of double write from proc1 to phys. file AND pipe. Performance?

If you have suggestions introducing completly different concepts, please consider that proc1 is an already written program and outputs the data to a physical file. I cant really change proc1, adding a sighandler and a sigsuspend along a tmpfile creation/ emptiyng and a double write are small changes, but already nearly to big for this process (testing). Regulatory reasons (risk).

My question is also, isn't there anything like a named pipe with persistent buffer on disc, and with fast buffer im mem for the usual work. the persistent buffer is copied to membuffer on open(). So data which was written to pipe but not read before crash is not lost (if the crash was after succesfull write to disc pipe internal). The write() call to this kind of pipe should return when data is assuredly written to disc, so the user program can assume once returned from the write() call, data is now delivered, guaranteed.

Sorry for the long story, but i hope you can help me along with this conceptual problem!

Thanks in advance!
Heck
  #2 (permalink)  
Old 01-09-2007
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,929
Yours is an unusual problem. It's not often you need to guarantee your code works when the system can't. No matter how far down you push it, the data is still going to be waiting in memory sometime -- what if the system dies before you finish writing to your temp file? Even a journalling filesystem can't avoid losing data that hasn't been written yet.
  #3 (permalink)  
Old 01-09-2007
jim mcnamara jim mcnamara is offline Forum Staff  
...@...
  
 

Join Date: Feb 2004
Location: NM
Posts: 5,717
Corona -

You are absolutely correct.

The OP & I had the same discussion earlier in another thread. I assume the OP did not like the first answer, and so tried again.
  #4 (permalink)  
Old 01-10-2007
heck heck is offline
Registered User
  
 

Join Date: Oct 2006
Location: Switzerland
Posts: 8
Exclamation

Namara i did like your suggestions in the other thread. Really, i also wanted to come up with an answer but couldn't order my mind right already. I see this thread as a "subproblem".

And ahm... i really think i understand the problem folks. Data which had never the chance to be written to disc can never be recovered(after crash).
JA, THIS IS LIKE THAT! I know.
I didnt want to dispute about this, we dont need to.

The conceptual discussion is aiming at a design of the system wich behaves as well as possible in all thinkable situations. _Recuding_ the POSSIBLE data loss.
So i realized, as you can see in my thread post, that i have to save the data to disc as soon as possbile.

So far my aimings and my concept are NOT nonsense. It is NOT a "Yes you need your computer powered up to run your program" like problem.


Focus was on two questions.
1. i have to save to disc a soon as possible, but also i need to further process the data. What is more clever?
a.) If i duplicate data as being written to disc AND to Pipe.Disc will never be read if pipe reader (proc2) signals that he has written the pipe data to disc itself. It is just to be transaction save.
b.) I store it in a physical file which i can be read anyway from proc2. So i can forget the pipe.

2. Is there anything like a named pipe with a persistent buffer (disc). (My answer: yes MQseries from IBM - just slightly an overkill) no Really?


And i conclude, yes it is a little bit of an uncommom problem. But were simply a the point, where we cant say, "ahh if the Machine screws up sometime, everything is screwed up anyway."
We have to be able to say. If the Machine screws up, we are prepared the best we can. It is not a devil which will never gonna happen. It is a case which can and over the years WILL happen in PRODUCTION environment, and we have to be prepared to handle it the best we can.
  #5 (permalink)  
Old 01-12-2007
Corona688 Corona688 is offline
Registered User
  
 

Join Date: Aug 2005
Location: Saskatchewan
Posts: 1,929
Quote:
Originally Posted by heck
So far my aimings and my concept are NOT nonsense. It is NOT a "Yes you need your computer powered up to run your program" like problem.
But they are. No matter how far down you push it, the data is still going to be waiting in memory sometime. You didn't just ask for "improved", you demand "guaranteed". Your requirements are simply impossible.
Quote:
It is just to be transaction save.
If you want transaction safety, use a database of some sort. Of course, even a database isn't magical -- it can't store data that hasn't been written yet.
Quote:
And i conclude, yes it is a little bit of an uncommom problem. But were simply a the point, where we cant say, "ahh if the Machine screws up sometime, everything is screwed up anyway."
Unfortunately, it's true. If the machine screws up, nothing can be guaranteed, no matter how rube goldbergian you make your data path.
Quote:
We have to be able to say. If the Machine screws up, we are prepared the best we can.
Right. That is what things like backups, failovers, RAID arrays, redundant power supplies, uninterruptible power supplies, generators, software sandboxing, extensive testing and detailed testing procedures are for. These will be much more useful than demanding magic software that can successfully save irreplaceable data to a hard drive that, perhaps, has no power.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:00 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0