Two child process having different process id but the same session id - Possible?
Posted in 2006
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Platform-Specific Issues
Hello again everyone, INFORMIX-4GL Version 7.30.HC4P1, INFORMIX-ESQL Version 9.40.UC2, HP-UX alpha B.11.00 U 9000/800 I have an invoicing module that forks a number of times depending on how many records are to be processed (e.g if there are 1,000,000 div by 100,000 so there will be 10 child processes running and each will process 100,000 records and generate 1 invoice report) The child process will do an sql_detach() as soon as forking is done and individually connect to the informix database and then call the informix functions. Each child will insert a record into a spool table which has unique index (user id, session id, report id). The problem is very often (when there are more than 30 children running) there is an insert error duplicate value for the index. Now all these 10 reports will have the same report name but since they are all running concurrently they should have different session ids right? So the scenario shouldn't happen, but its happening. Soooo, can more than one child process have the same session id even though they have different process id? Any help is appreciated. Ciao!
janderson_ph@blackskull.org wrote: > INFORMIX-4GL Version 7.30.HC4P1, INFORMIX-ESQL Version 9.40.UC2, HP-UX > alpha B.11.00 U 9000/800 > > I have an invoicing module that forks a number of times depending on > how many records are to be processed (e.g if there are 1,000,000 div by > 100,000 so there will be 10 child processes running and each will > process 100,000 records and generate 1 invoice report) > > The child process will do an sql_detach() as soon as forking is done > and individually connect to the informix database and then call the > informix functions. That's mostly correct - but did you consider using DISCONNECT ALL (either in I4GL or in ESQL/C) preferably before forking? I assume that the initial process is connected to the DB in order to tell how many children to spawn. I don't know of any problems with sql_detach(), and it is documented as a way to do the equivalent of DISCONNECT ALL (approximately). Also, if you do that, you can also put a pause into the program that will allow you to validate that its session is not active. Then, of course, the forked children have no active session to dispose of, and you can connect directly and proceed as now. IIRC, even in 7.30, you can use DISCONNECT and CONNECT in I4GL. > Each child will insert a record into a spool table > which has unique index (user id, session id, report id). The problem is > very often (when there are more than 30 children running) there is an > insert error duplicate value for the index. Now all these 10 reports > will have the same report name but since they are all running > concurrently they should have different session ids right? So the > scenario shouldn't happen, but its happening. Soooo, can more than one > child process have the same session id even though they have different > process id? Any help is appreciated. Theoretically, no. But you can head off the trouble as I outlined above.