Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Crashproofing my service
Mon, Sep 10 2012 2:30 AMPermanent Link

Adam H.

Hi,

I'm writing a service based application that connects to a DBISAM Server
(v4).

Within the error handling routines, I would like to be able to
crash-proof this service. (Effectively, if the service looses connection
to the DBISam Server - I want it to be able to disconnect completely,
and re-attempt a connection every x minutes).

However I'm having a hard time trying to replicate this. It appears as
though DBISam tries this automatically, but fails (because it's trying
to reconnect to an existing session that no longer exists in the event
of a DBISam Server restart).

I have tried the following code in the DBSRemoteReconnect event but when
it runs, it pretty much stops completely, and the CrashTimer never
triggers, even though it shows as still being active when it runs the
DBSRemoteReconnect event.

Can someone see what I'm doing wrong, or advise of a better solution?

procedure TMainForm.DBSRemoteReconnect(Sender: TObject; var Continue,
StopAsking: Boolean);
begin
 continue := false;
 dbs.active := false;
end;


procedure TMainForm.CrashTimerTimer(Sender: TObject);
begin
try
 if not db.connected then
  begin
   DBS.Active := false;
   db.Connected := true;
   SetupT.Open;
  end;

  maintimer.enabled := true; //Just runs some other functions
  except
 end;
end;



Cheers

Adam.
Mon, Sep 10 2012 7:07 PMPermanent Link

Adam H.

Looking at this problem a litlte more closely, it would appear as though
the program gets caught up in a loop when it tries to deactivate the
database session. (dbs.active := false);

Looking through the code, in dbisamtb.pas it gets caught in an infinite
loop on the procedure TDBISAMDatabase.CloseDataSets as follows:

procedure TDBISAMDatabase.CloseDataSets;
begin
   while (DataSetCount <> 0) do
      TDBISAMDBDataSet(DataSets[DataSetCount-1]).Disconnect;
end;

The DataSetCount value is 1 (only one dataset in this application), but
it never seems to release from this loop.

I have tried changing my script to close the dataset before it
deactivates the session, but this has not fixed the problem - the
infinite loop remains.

Does anyone have any suggestions how I might be able to handle this?

Thanks & Regards

Adam.





> Hi,
>
> I'm writing a service based application that connects to a DBISAM Server
> (v4).
>
> Within the error handling routines, I would like to be able to
> crash-proof this service. (Effectively, if the service looses connection
> to the DBISam Server - I want it to be able to disconnect completely,
> and re-attempt a connection every x minutes).
>
> However I'm having a hard time trying to replicate this. It appears as
> though DBISam tries this automatically, but fails (because it's trying
> to reconnect to an existing session that no longer exists in the event
> of a DBISam Server restart).
>
> I have tried the following code in the DBSRemoteReconnect event but when
> it runs, it pretty much stops completely, and the CrashTimer never
> triggers, even though it shows as still being active when it runs the
> DBSRemoteReconnect event.
>
> Can someone see what I'm doing wrong, or advise of a better solution?
>
> procedure TMainForm.DBSRemoteReconnect(Sender: TObject; var Continue,
> StopAsking: Boolean);
> begin
>   continue := false;
>   dbs.active := false;
> end;
>
>
> procedure TMainForm.CrashTimerTimer(Sender: TObject);
> begin
> try
>   if not db.connected then
>    begin
>     DBS.Active := false;
>     db.Connected := true;
>     SetupT.Open;
>    end;
>
>    maintimer.enabled := true; //Just runs some other functions
>    except
>   end;
> end;
>
>
>
> Cheers
>
> Adam.
Thu, Sep 13 2012 6:38 PMPermanent Link

Adam H.

Problem appears to be solved:

Needed to set StopAsking := true;


> Looking at this problem a litlte more closely, it would appear as though
> the program gets caught up in a loop when it tries to deactivate the
> database session. (dbs.active := false);
>
> Looking through the code, in dbisamtb.pas it gets caught in an infinite
> loop on the procedure TDBISAMDatabase.CloseDataSets as follows:
>
> procedure TDBISAMDatabase.CloseDataSets;
> begin
>     while (DataSetCount <> 0) do
>        TDBISAMDBDataSet(DataSets[DataSetCount-1]).Disconnect;
> end;
>
> The DataSetCount value is 1 (only one dataset in this application), but
> it never seems to release from this loop.
>
> I have tried changing my script to close the dataset before it
> deactivates the session, but this has not fixed the problem - the
> infinite loop remains.
>
> Does anyone have any suggestions how I might be able to handle this?
>
> Thanks & Regards
>
> Adam.
>
>
>
>
>
>> Hi,
>>
>> I'm writing a service based application that connects to a DBISAM Server
>> (v4).
>>
>> Within the error handling routines, I would like to be able to
>> crash-proof this service. (Effectively, if the service looses connection
>> to the DBISam Server - I want it to be able to disconnect completely,
>> and re-attempt a connection every x minutes).
>>
>> However I'm having a hard time trying to replicate this. It appears as
>> though DBISam tries this automatically, but fails (because it's trying
>> to reconnect to an existing session that no longer exists in the event
>> of a DBISam Server restart).
>>
>> I have tried the following code in the DBSRemoteReconnect event but when
>> it runs, it pretty much stops completely, and the CrashTimer never
>> triggers, even though it shows as still being active when it runs the
>> DBSRemoteReconnect event.
>>
>> Can someone see what I'm doing wrong, or advise of a better solution?
>>
>> procedure TMainForm.DBSRemoteReconnect(Sender: TObject; var Continue,
>> StopAsking: Boolean);
>> begin
>>   continue := false;
>>   dbs.active := false;
>> end;
>>
>>
>> procedure TMainForm.CrashTimerTimer(Sender: TObject);
>> begin
>> try
>>   if not db.connected then
>>    begin
>>     DBS.Active := false;
>>     db.Connected := true;
>>     SetupT.Open;
>>    end;
>>
>>    maintimer.enabled := true; //Just runs some other functions
>>    except
>>   end;
>> end;
>>
>>
>>
>> Cheers
>>
>> Adam.
>
Image