Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 10 of 11 total
Thread SessionRemoteReconnect Access Violation
Wed, Feb 5 2014 3:40 AMPermanent Link

codealfa

Hi,

i created a test app, which connect to a remote edb server, it works fine, but if i stop the edb server the delphi app is get an Access Violation, when it try disconnect form dead/missing session.

code:
 sess:=TEDBSession.Create(Application);
 sess.RemoteHost:='...';
 sess.RemotePort:=12010;
 sess.RemoteEncryption:=True;
 sess.SessionName:=s1;
 sess.SessionType:=stRemote;
 sess.OnRemoteReconnect:=SessionRemoteReconnect;  //!!! if this is commented, it works even the server is stopped

i try run sqls with try except, and if the connection is dead, i try first try sess.connected=False except then try sess.connected=True except but it fails at disconnect with access violation. Without the onremotereconnect event it works, it can reconnect fine.
Wed, Feb 5 2014 3:42 AMPermanent Link

codealfa

codealfa wrote:

Hi,

i created a test app, which connect to a remote edb server, it works fine, but if i stop the edb server the delphi app is get an Access Violation, when it try disconnect form dead/missing session.

code:
 sess:=TEDBSession.Create(Application);
 sess.RemoteHost:='...';
 sess.RemotePort:=12010;
 sess.RemoteEncryption:=True;
 sess.SessionName:=s1;
 sess.SessionType:=stRemote;
 sess.OnRemoteReconnect:=SessionRemoteReconnect;  //!!! if this is commented, it works even the server is stopped

i try run sqls with try except, and if the connection is dead, i try first try sess.connected=False except then try sess.connected=True except but it fails at disconnect with access violation. Without the onremotereconnect event it works, it can reconnect fine.

procedure Tfrm_mani.SessionRemoteReconnect(Sender: TObject; var Continue,
                 StopAsking: Boolean);
begin
 Continue   := false;
 StopAsking := true;
end;
Wed, Feb 5 2014 6:25 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

<< i created a test app, which connect to a remote edb server, it works
fine, but if i stop the edb server the delphi app is get an Access
Violation, when it try disconnect form dead/missing session. >>

What version/build of ElevateDB are you using ?

Please always include the version/build of ElevateDB that you're using.
Without it, I can't even begin to help you with an issue.

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Feb 5 2014 6:29 AMPermanent Link

codealfa

version: 2.15 b3  Delphi 7
Wed, Feb 5 2014 8:09 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com


<< version: 2.15 b3  Delphi 7  >>

I'm not seeing any issue here.  The code I'm using is this:

procedure TForm1.Button1Click(Sender: TObject);
begin
  EDBSession1.Connected:=True;
end;

procedure TForm1.EDBSession1RemoteReconnect(Sender: TObject; var Continue,
 StopAsking: Boolean);
begin
Continue   := false;
StopAsking := true;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  try
     EDBQuery1.ExecSQL;
  except
     EDBSession1.Connected:=False;
     EDBSession1.Connected:=True;
  end;
end;

I first click on Button1, then I terminate the EDB Server, and then I click
on Button2.

Do you have other data-aware controls or event handlers attached to the
query that you're trying to execute ?  It could be an event handler, etc.
that is causing the AV.

Tim Young
Elevate Software
www.elevatesoft.com


Wed, Feb 5 2014 10:25 AMPermanent Link

codealfa

I attached the test app. I test with it the edb CS server with large sql running, because we found slowing after some millions data operation. We search what can be the problem. We found that, if we restart the db server, everything is good (fast) again, but the db apps, can not reconnect if the SessionRemoteReconnect event was connected. Thanks for help!



Attachments: db_test.zip
Thu, Feb 6 2014 8:31 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

<< I attached the test app. I test with it the edb CS server with large sql
running, because we found slowing after some millions data operation. We
search what can be the problem. We found that, if we restart the db server,
everything is good (fast) again, but the db apps, can not reconnect if the
SessionRemoteReconnect event was connected. Thanks for help! >>

Please don't post attachments in this newsgroup/forum - use the Binaries
newsgroup/forum instead.

Your AV is due to you trying to reference a nil instance of the TEDBQuery
component:

function sql_open(var db:TEDBDatabase;var
ds:TEDBQuery;muv:char;sql:ansistring):boolean;
var em:string;
begin
result:=False;
try
 if ds<>nil then sql_close(ds);
 if not db.Connected then db.Open;
 global_lock.BeginWrite;
 try
  ds:=TEDBQuery.Create(db);
 finally
  global_lock.EndWrite;
 end;
 ds.SessionName:=db.SessionName;
 ds.DatabaseName:=db.DatabaseName;
 ds.SQL.Clear;
 ds.SQL.Add(sql);
 if muv='O' then
 begin
  ds.Open;
 end
 else ds.ExecSQL;
 result:=True;
except
 on E: Exception do
 begin
  em:=E.Message;
  frmMain.Session_err(E,ds.DBSession);  <<<<<<<<<<<<<< Here !!!!!!
  if ds<>nil then sql_close(ds);
 end;
end;
end;

The reason why it's nil is because you're creating the TEDBDatabase with the
TEDBSession as its owner, and likewise you're creating the TEDBQuery with
the TEDBDatabase as *its* owner.  Therefore, when you free the main
TEDBSession, you're also automatically freeing the TEDBDatabase and the
TEDBQuery, thus leaving your ds variable referencing an instance that no
longer exists.

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Feb 10 2014 10:43 AMPermanent Link

codealfa

Hello Tim,

thanks for info, i rewrote the app to reconnect is the session is dead. It works now,
but maybe it wold be useful for beginners, if there would be a switch to auto reconnect/repair
session without any trick.

The another useful info which i find after some test, i have to prepare(initialize) again the parameterized/prepared sql after the lost session repaired for optimal speed. Without it as slow as a normal sql.

The third, we find edb slowing case: if use sql like this:

select * from  (
 select * from test_table where id= '+inttostr(i)+'
) a order by name

after 1000 running it is 100 times slower and use more resource.
This sql ( select * from test_table where id= '+inttostr(i)+'  ) is fast always, i run it million times.
With outer select it is getting slower. (i use delphi 7 with latest edb cs)
Could you analyze this problem?

Regards, Zsolt
Mon, Feb 10 2014 2:43 PMPermanent Link

codealfa

Sorry for a lot of info, but i want just indicate my experience with edb.
I thought my session reconnect code is perfect Smilebut last time (when i stopped and restart edb server for fast sql handling) my second app server pc (which connected to an edb server pc) could not reconnect. At disconnect there was again AV, but it seems the connect was good (i use try except at connect, and there was no error message), but the session was not created. I closed my app, and then i got this message:

compiled with     : Delphi 7
madExcept version : 4.0.5
callstack crc     : $7c592d15, $7feba805, $7feba805
exception number  : 2
exception class   : EAccessViolation
exception message : Access violation at address 0040464C in module 'i.exe'. Read of address FFFFFFDC.

main thread ($d84):
0040464c +008 i.exe System                 TObject.InheritsFrom
0040459e +00e i.exe System                 @IsClass
004dfb1e +062 i.exe DB                     TCustomConnection.SendConnectEvent
004dfa91 +069 i.exe DB                     TCustomConnection.SetConnected
004dfa24 +004 i.exe DB                     TCustomConnection.Close
007044b8 +034 i.exe edbcomps               TEDBSession.InternalDisconnect
00703b84 +02c i.exe edbcomps               TEDBSession.SetConnected
007027ac +038 i.exe edbcomps               TEDBEngineInstance.CloseAllSessions
00701e1a +332 i.exe edbcomps               TEDBEngineInstance.SetActive
007014c7 +00f i.exe edbcomps               TEDBEngineInstance.Destroy
004043f0 +008 i.exe System                 TObject.Free
00702b73 +033 i.exe edbcomps               TEDBEngine.Destroy
004043f0 +008 i.exe System                 TObject.Free
0070cd22 +01e i.exe edbcomps               Finalization
00404f40 +044 i.exe System                 FinalizeUnits
0045b234 +054 i.exe madExcept              InterceptFinalizeUnits
0045b243 +007 i.exe madExcept              InterceptHalt0FinalizeUnits
00405219 +059 i.exe System                 @Halt0
00848725 +069 i.exe i 20 +6 initialization
75b73368 +010 kernel32.dll                                BaseThreadInitThunk

i will do a session and database free and recreate on next time instead of connected:=False, connected:=True. i tested it, it seems it is working.
Tue, Feb 11 2014 9:38 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

<< thanks for info, i rewrote the app to reconnect is the session is dead.
It works now, but maybe it wold be useful for beginners, if there would be a
switch to auto reconnect/repair session without any trick.  >>

ElevateDB already provides transparent session reconnection to the ElevateDB
Server, *as long as the session still exists on the ElevateDB Server*.
You're talking about a situation where the session on the ElevateDB Server
is *gone*, and you need to start a whole new session.  Some applications
want to do this, while others do not.  If you do want to automatically
establish a new session, then there isn't any "trick" - you simply
disconnect and re-connect the session.

<< The another useful info which i find after some test, i have to
prepare(initialize) again the parameterized/prepared sql after the lost
session repaired for optimal speed. Without it as slow as a normal sql. >>

Yes, that is true.  Remember, the entire state of the session is gone (it
was on the server), so you have to re-establish it all from scratch.
There's absolutely no way for ElevateDB to do this for you.

<< The third, we find edb slowing case: if use sql like this:

select * from  (
 select * from test_table where id= '+inttostr(i)+'
) a order by name

after 1000 running it is 100 times slower and use more resource. This sql
( select * from test_table where id= '+inttostr(i)+'  ) is fast always, i
run it million times. With outer select it is getting slower. (i use delphi
7 with latest edb cs) >>

Please email me the table that you're using, along with the exact SQL/code
that you're using to reproduce the problem, and I'll take a look.

Tim Young
Elevate Software
www.elevatesoft.com
Page 1 of 2Next Page »
Jump to Page:  1 2
Image