ToracleEvent.Stop hangs application...

DavidH

Member²
My problem is that sometimes, when I quit my application, it keeps on running (it is still running according to Delphi).

I seem to be able to reproduce the error, at least most of the times it does not quit. However, if I run Oracle Monitor (Lite) in the background, it always works. At least I haven't been able to reproduce the error though I do the same clicks in my application.

My own test logs shows that the problem lies in this row:
OEvent.Stop;
...here is where it waits forever.

Relevant system facts:

Oracle version: 8.1.6.0.0 Enterprise
DOA version: 3.4.3

object OEvent: TOracleEvent
Session = OSession
ObjectType = otAlert
TimeOut = 0
Synchronized = True
KeepConnection = True
OnEvent = OEventEvent
Left = 176
Top = 88
end

object OSession: TOracleSession
Cursor = crHourGlass
DesignConnection = False
ConnectAs = caNormal
ThreadSafe = True
Preferences.FloatPrecision = 0
Preferences.IntegerPrecision = 0
Preferences.SmallIntPrecision = -1
Preferences.UseOCI7 = False
Preferences.ConvertCRLF = True
Preferences.TrimStringFields = True
Preferences.MaxStringFieldSize = 0
Preferences.ZeroDateIsNull = True
Preferences.NullLOBIsEmpty = False
Pooling = spNone
MTSOptions = [moImplicit, moUniqueServer]
Connected = True
RollbackOnDisconnect = False
NullValue = nvUnAssigned
SQLTrace = stUnchanged
OptimizerGoal = ogUnchanged
IsolationLevel = ilUnchanged
BytesPerCharacter = bc1Byte
Left = 144
Top = 88
end
 
Hey Marco!

This might be a multithread error as well...

I realized that the delay between Start and Stop was very small (and OracleMonitor made the delay larger). Start does not actually start the waiting since the waiting is initiated by the thread, which isn't executed until later on. When I debugged this code (just to test my theory):

begin
OEvent.Start;
OEvent.Stop;
end;

...it worked because the session the Stop function creates took time to connect to the server, enough time to make the TEventThread startup. But what if it doesn't? You will then signal the SessionID-alert earlier than the the thread had got time to register it...

So my problem will occur if the event thread is started (by windows scheduler) between you signal the SessionID-alert and call the critical section wait thing.
 
Anyway, you may wonder about this starting and stopping. Actually, I have several alerts to wait for, and which ones varies over time. But having seen the monitor over what's going to the server, I realize there is a possibility to lose signals since they are unregistered and then registered again as the event is started and stopped.

I don't have an TOracleEvent for each signal, because that would be far to many sessions / threads / etc.

So what I would like is a possibility to change ObjectNames while the service is started. You would then signal the SessionID-alert, figure out which alerts are 1) added 2) removed 3) still there (and make a query according to that), and then run dbms_alert.waitany again.
 
This can't be done with the current TOracleEvent. You need to Stop it, assign a new value to ObjectName, and Start it again.

------------------
Marco Kalter
Allround Automations
 
Back
Top