At 08:30 PM 6/1/99 +0100, Piers Collins wrote:
>Folks,
>
>Does anybody have any experience of using forked processes on Unix
>within an embedded C Ingres program ?
>
>A list of Pros' & Cons' is what I'm after.
>
>I've been trying to figure out a way of using them to achieve something
>like the following.
>
Piers,
I've much experience in this area. My advice is:
1) Only connect AFTER you fork
2) Don't connect in the main process that does the forking.
I've never gotten both to work together with forking. When
the forked processes close the open file descriptors (either
on purpose or when exitting) the main connection goes to
lunch.
I know this blows everything you are doing into the toilet, so
might I suggest some alternate architectures:
1) Have a master process connect to another process that
forks the children to perform the task. Unfortunately,
you will need to come up with some IPC protocol to deal
with this. And truly making it scale by letting the
forked processes run asychronously is a bear.
2) At risk of being called a salesman again by bitter, mis-informed
OpenROAD fans, you could use Java, JDBC, and a connection caching
product. Java is multi-threaded by design, and our JDBC and
JdbCache products are all multi-thread safe. Our connection
caching product produces run-time statistics, allowing you to
tune it to best meet your load.
3) Set you signal handlers AFTER you connect, as Ingres will not
chain them, but instead overwrite them.
4) Anything older than OpenIngres 2.0 is not thread safe.
So don't bother trying!
Now, all this advice is "multi-platform", meaning you might get
some kind of forking solution to work on a particular platform, but
my experience says it doesn't always travel well.
Mike Leo
mleo@cariboulake.com
Ingres Q & A
Back to William's Home Page
© William Yuan 2000
Email William