473,545 Members | 2,663 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple instance of process - memory conflicts

I wonder if anybody could shed some light on a problem I am
encountering.

I have written a program in C that runs on Solaris 2.8. At busy times
of the day there may be multiple instances of it running (5-10), each
process taking approx. 3 seconds to complete.

Each instance of the program basically fetches data from a Oracle
database (using Remedy ARS API routines) and stores it in a user
defined structure that I have defined as a global variable. The
problem I encounter is when multiple instances of the program are
running. Often I find that the data in memory being held in one
process is mixed up with the data in memory of another.

A simplified example could be:

process instance 1 fetches data from record NA1234 and stores record
id in a string variable str1:

process instance 2 fetches data from another record NA9999 and stores
record
id also in a string variable str1:

However when I check the value of var1 in process instance 2, it
sometimes may say NA9999 (which would be correct) but other times it
may say NA1234 (ie. it is sharing the memory space of process 1),
especially when the processes are running in parallel.

Can this phenomena be attributed to global variables - if so changing
to a local instance would relieve this?

Any assistance greatly appreciated.

-- Shuaib
Nov 13 '05 #1
5 4297
sr******@yahoo. com (Shuaib) writes:
I wonder if anybody could shed some light on a problem I am
encountering.

I have written a program in C that runs on Solaris 2.8. At busy times
of the day there may be multiple instances of it running (5-10), each
process taking approx. 3 seconds to complete.

Each instance of the program basically fetches data from a Oracle
database (using Remedy ARS API routines) and stores it in a user
defined structure that I have defined as a global variable. The
problem I encounter is when multiple instances of the program are
running. Often I find that the data in memory being held in one
process is mixed up with the data in memory of another.


Are these processes using shared memory? If not, it's impossible to
get a mixup. If they are using shared memory, you will get that sort
of problems, unless you do something to prevent it.

--
Måns Rullgård
mr*@users.sf.ne t
Nov 13 '05 #2
In article <12************ **************@ posting.google. com>, Shuaib wrote:
I wonder if anybody could shed some light on a problem I am
encountering.

I have written a program in C that runs on Solaris 2.8. At busy times
of the day there may be multiple instances of it running (5-10), each
process taking approx. 3 seconds to complete.

Each instance of the program basically fetches data from a Oracle
database (using Remedy ARS API routines) and stores it in a user
defined structure that I have defined as a global variable. The
problem I encounter is when multiple instances of the program are
running. Often I find that the data in memory being held in one
process is mixed up with the data in memory of another.

A simplified example could be:

process instance 1 fetches data from record NA1234 and stores record
id in a string variable str1:

process instance 2 fetches data from another record NA9999 and stores
record
id also in a string variable str1:

This is virtually impossible, I'd say;
* A bug somewhere in your program
* You are using threads rather than processes, and have locking
issues
* you use shared memory, and have locking issues.
* oracle or the api you use somehow screw things up for you,
or you havn't thought things enough through, e.g. something
updates your database while you query it and similar
potentional problesm.
Nov 13 '05 #3
Shuaib wrote:
I wonder if anybody could shed some light on a problem I am
encountering.

I have written a program in C that runs on Solaris 2.8. At busy times
of the day there may be multiple instances of it running (5-10), each
process taking approx. 3 seconds to complete.

Each instance of the program basically fetches data from a Oracle
database (using Remedy ARS API routines) and stores it in a user
defined structure that I have defined as a global variable. The
problem I encounter is when multiple instances of the program are
running. Often I find that the data in memory being held in one
process is mixed up with the data in memory of another.


My guess is you've done something like this:

(1) open Oracle connection in parent process
(2) fork()
(3) do Oracle query in children

That may not be a valid way to use the Oracle db client code.
I would try doing this instead:

(1) fork()
(2) open Oracle connection in child
(3) do Oracle query in child

I'm not an Oracle expert, I am only thinking of what might happen
if two instances of the client code are sharing the same initial
values in their data structures and are sharing the TCP connection.

Hope that helps.

- Logan

Nov 13 '05 #4
Logan Shaw wrote:
Shuaib wrote:
I wonder if anybody could shed some light on a problem I am
encountering.

I have written a program in C that runs on Solaris 2.8. At busy times
of the day there may be multiple instances of it running (5-10), each
process taking approx. 3 seconds to complete.

Each instance of the program basically fetches data from a Oracle
database (using Remedy ARS API routines) and stores it in a user
defined structure that I have defined as a global variable. The
problem I encounter is when multiple instances of the program are
running. Often I find that the data in memory being held in one
process is mixed up with the data in memory of another.

My guess is you've done something like this:

(1) open Oracle connection in parent process
(2) fork()
(3) do Oracle query in children

That may not be a valid way to use the Oracle db client code.
I would try doing this instead:

(1) fork()
(2) open Oracle connection in child
(3) do Oracle query in child

I'm not an Oracle expert, I am only thinking of what might happen
if two instances of the client code are sharing the same initial
values in their data structures and are sharing the TCP connection.


Extremely likely.

I have found (painfully!) that even this leads to trouble:

(1) Connect to Oracle in parent
(2) fork
(3) Do nothing related to Oracle in child
(4) Exit child

or this:

(3) Do nothing related to Oracle in parent
(4) Exit parent

Because the Oracle client runtime registers an atexit, just exiting the
process becomes akin to an Oracle request!

Since there does not seem to be any way to unregister an atexit handler,
the only thing that works is to have *NO* Oracle connection at all while
you fork. (There may be something in the most recent Oracle OCI API to
circumvent that problem, but I haven't found it yet)

Hope that helps.

- Logan

--
Michel Bardiaux
Peaktime Belgium S.A. Bd. du Souverain, 191 B-1160 Bruxelles
Tel : +32 2 790.29.41

Nov 13 '05 #5

"Michel Bardiaux" <mb*******@peak time.be> wrote in message
news:3F******** ******@peaktime .be...
I have found (painfully!) that even this leads to trouble:

(1) Connect to Oracle in parent
(2) fork
(3) Do nothing related to Oracle in child
(4) Exit child

or this:

(3) Do nothing related to Oracle in parent
(4) Exit parent

Because the Oracle client runtime registers an atexit, just exiting the
process becomes akin to an Oracle request!


That's why the child should not call 'exit'. This same problem exists
with stdio streams.

DS
Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
4912
by: Ohaya | last post by:
Hi, I'm trying to understand a situation where ASP seems to be "blocking" of "queuing" requests. This is on a Win2K Advanced Server, with IIS5. I've seen some posts (e.g., http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=Tidy7IDbDHA.2108%40cpmsftngxa06.phx.gbl) that indicate that ASP will queue up requests when they come...
11
5270
by: Mike | last post by:
Looking to find any information on how to properly configure multiple instances of DB2. This is on Win2k db2 ver 7.2. I am basically looking for information on how the multiple instance settings should configured to work, how memory is shared or not, etc. I can not seem to find any good links to this information. Thanks, Mike
9
23059
by: Abhishek Srivastava | last post by:
Hello All, In IIS 6.0 We have a concept of worker processes and application pools. As I understand it, we can have multiple worker process per appliction pool. Each worker process is dedicated to a pool. If I assign only one application to a applicaton pool and have multiple worker processes assigned to that pool. Will my application be...
6
4967
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing for long running reports. When the processing is complete it uses crystal reports to load a template file, populate it, and then export it to a...
22
8905
by: Brett Romero | last post by:
If my UI app uses three DLLs and two of those DLLs reference something named utilities.dll, does the UI app load utilities.dll twice or does the compiler recognize what is going on and load utilities.dll just once? Thanks, Brett
10
4961
by: John | last post by:
I currently have a Windows Service that runs Transactions that are very Processor/Memory Intensive. I have a requirement to deploy multiple instances of the Web service on the Same server. Each Instance needs to run in its own process. My current approach to this is to put all the logic into a separate "Worker" assembly and install it into...
1
2207
by: mikelujan | last post by:
Hi, Our application starts an external application using System.Diagnostics.Process class and the Start() method, as per code snippet below. This application run as a Windows service, and must start several instances of the same application, like multiple Windows Calculators for instance. We are experiencing difficulties starting...
19
6312
by: Zytan | last post by:
I want multiple instances of the same .exe to run and share the same data. I know they all can access the same file at the same time, no problem, but I'd like to have this data in RAM, which they can all access. It seems like a needless waste of memory to make them all maintain their own copy of the same data in RAM at the same time. ...
1
7400
by: richard.crosh | last post by:
What is the IBM recommendation for the number of DB2-LUW databases per instance on AIX? With Oracle, it is one-to-one. In DB2 multiple databases can co-exist in an instance but is this recommended? What should be considered in making this decision?
0
7490
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7425
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7780
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6009
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5351
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5069
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3465
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1911
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.