Subject | IBS_Base more questions... |
---|---|
Author | Dany M |
Post date | 2006-12-18T12:37:07Z |
Hi!
Really sorry to be such a PITA on this one. But I have come up with one
more thing that confuses me.
I have done a small test case with a simple stored procedure that is
getting prepared in the cnAfterConnect event and being executed *and*
committed in the DoServiceItems function.
After shutting down the database the thread sleeps as it should. Then,
when I bring the database online at the second execution of
DoServiceCanSleep the IsWaiting parameter is set.
This happens when ProcessPassiveTasks is called on the *transaction* via
the session in the service loop.
In TIB_Transaction.ProcessPassiveTasks all the OAT stuff is skipped and
we are ending up here
<code>
if not IsWaiting then
IsWaiting := Started;
</code>
the thing with these two lines is that IsWaiting never gets resetted. I
can of course reset IsWaiting in the DoServiceCanSleep by checking the
Started property of the transaction.
Should I do that?
Regards,
/Dany
BTW I had to change the exception handling in IBS_Base.pas in order for
the service to detect a failed connection and setting the KillCon flag
properly.
<code>
procedure TsvcBase.SysExecuteService;
var
tmpDay, tmpMonth, tmpYear: word;
IsDone, IsWaiting, WasTerminated: boolean;
begin
LastEmailSent := 0;
DecodeDate( now, tmpYear, tmpMonth, FCurrentDay );
if LogThread then LogItem( '[INITIALIZING]', 'Thread' );
try
DoServiceInitialization;
except
on E: Exception do
LogMessage( 'Exception in ServiceInitialization: ' + E.Message );
end;
if LogThread then LogItem( '[EXECUTING]', 'Thread' );
repeat
try
IsDone := true;
IsWaiting := false;
WasTerminated := false;
if not WorkerTerminated then
begin
try
DoServiceItems;
except
on E: Exception do
begin
//HandleProblem( 'Problem in DoServiceItems', E ); // My chg
LogItem( 'Problem in DoServiceItems' ); // My chg
DoServiceLoopException( E ); // My chg
end;
end;
if not WorkerTerminated then
begin
DecodeDate( now, tmpYear, tmpMonth, tmpDay );
if FCurrentDay <> tmpDay then
if DoServiceCanProcessMidnightItems then
try
DoServiceProcessMidnightItems;
FCurrentDay := tmpDay;
except
on E: Exception do
begin
//HandleProblem( 'Problem in DoProcessMidnightItems',
E ); // My chg
LogItem( 'Problem in DoProcessMidnightItems' );// My chg
DoServiceLoopException( E );// My chg
end;
end;
end;
if not WorkerTerminated then
try
se.ProcessPassiveTasks( IsDone, IsWaiting, WasTerminated );
except
on E: Exception do
begin
//HandleProblem( 'Problem in se.ProcessPassiveTasks', E
);// My chg
LogItem( 'Problem in se.ProcessPassiveTasks' );// My chg
DoServiceLoopException( E );// My chg
end;
end;
end;
if not WorkerTerminated and
DoServiceCanSleep( IsDone, IsWaiting, WasTerminated ) and
not WorkerTerminated then
begin
if IsWaiting then
DoPutServiceToSleep( WorkerTimeoutTicks div 10 )
else
DoPutServiceToSleep( WorkerTimeoutTicks );
end;
except
on E: Exception do
DoServiceLoopException( E );
end;
until WorkerTerminated;
if LogThread then LogItem( '[TERMINATING]', 'Thread' );
try
DoServiceFinalization;
except
on E: Exception do
LogMessage( 'Exception in ServiceFinalization: ' + E.Message );
end;
if LogThread then LogItem( '[TERMINATED]', 'Thread' );
end;
</code>
Really sorry to be such a PITA on this one. But I have come up with one
more thing that confuses me.
I have done a small test case with a simple stored procedure that is
getting prepared in the cnAfterConnect event and being executed *and*
committed in the DoServiceItems function.
After shutting down the database the thread sleeps as it should. Then,
when I bring the database online at the second execution of
DoServiceCanSleep the IsWaiting parameter is set.
This happens when ProcessPassiveTasks is called on the *transaction* via
the session in the service loop.
In TIB_Transaction.ProcessPassiveTasks all the OAT stuff is skipped and
we are ending up here
<code>
if not IsWaiting then
IsWaiting := Started;
</code>
the thing with these two lines is that IsWaiting never gets resetted. I
can of course reset IsWaiting in the DoServiceCanSleep by checking the
Started property of the transaction.
Should I do that?
Regards,
/Dany
BTW I had to change the exception handling in IBS_Base.pas in order for
the service to detect a failed connection and setting the KillCon flag
properly.
<code>
procedure TsvcBase.SysExecuteService;
var
tmpDay, tmpMonth, tmpYear: word;
IsDone, IsWaiting, WasTerminated: boolean;
begin
LastEmailSent := 0;
DecodeDate( now, tmpYear, tmpMonth, FCurrentDay );
if LogThread then LogItem( '[INITIALIZING]', 'Thread' );
try
DoServiceInitialization;
except
on E: Exception do
LogMessage( 'Exception in ServiceInitialization: ' + E.Message );
end;
if LogThread then LogItem( '[EXECUTING]', 'Thread' );
repeat
try
IsDone := true;
IsWaiting := false;
WasTerminated := false;
if not WorkerTerminated then
begin
try
DoServiceItems;
except
on E: Exception do
begin
//HandleProblem( 'Problem in DoServiceItems', E ); // My chg
LogItem( 'Problem in DoServiceItems' ); // My chg
DoServiceLoopException( E ); // My chg
end;
end;
if not WorkerTerminated then
begin
DecodeDate( now, tmpYear, tmpMonth, tmpDay );
if FCurrentDay <> tmpDay then
if DoServiceCanProcessMidnightItems then
try
DoServiceProcessMidnightItems;
FCurrentDay := tmpDay;
except
on E: Exception do
begin
//HandleProblem( 'Problem in DoProcessMidnightItems',
E ); // My chg
LogItem( 'Problem in DoProcessMidnightItems' );// My chg
DoServiceLoopException( E );// My chg
end;
end;
end;
if not WorkerTerminated then
try
se.ProcessPassiveTasks( IsDone, IsWaiting, WasTerminated );
except
on E: Exception do
begin
//HandleProblem( 'Problem in se.ProcessPassiveTasks', E
);// My chg
LogItem( 'Problem in se.ProcessPassiveTasks' );// My chg
DoServiceLoopException( E );// My chg
end;
end;
end;
if not WorkerTerminated and
DoServiceCanSleep( IsDone, IsWaiting, WasTerminated ) and
not WorkerTerminated then
begin
if IsWaiting then
DoPutServiceToSleep( WorkerTimeoutTicks div 10 )
else
DoPutServiceToSleep( WorkerTimeoutTicks );
end;
except
on E: Exception do
DoServiceLoopException( E );
end;
until WorkerTerminated;
if LogThread then LogItem( '[TERMINATING]', 'Thread' );
try
DoServiceFinalization;
except
on E: Exception do
LogMessage( 'Exception in ServiceFinalization: ' + E.Message );
end;
if LogThread then LogItem( '[TERMINATED]', 'Thread' );
end;
</code>