DisconnectedMode and threading

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

DisconnectedMode and threading

Post by MarkF » Tue 28 Apr 2009 02:12

I seem to have an issue with threading that only comes up if DisconnectedMode is True. I have a single session with Thread Safey on. I start a background thread which is running many small update statements. In a different thread I run a single query. If DisconnectedMode is False, then everything works fine. If DisconnectedMode is True, then I get various Oracle errors and access violations. It seems like some kind of mutexing/thread protection issue. Is that enough to look into it? I don't have a small example, but I can probably make one if needed. Thanks for any help or suggestions!

-Mark Ford
Benthic Software

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Tue 28 Apr 2009 06:48

DisconnectedMode is not designed for working with multiple threads. You can use DisconnectedMode only if you use separate TOraSession component for each thread.

MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Post by MarkF » Tue 28 Apr 2009 11:21

My only reason for using disconnected mode is so that I can disconnect (explicitly) from the database and have my datasets retain their data. Would it be possible to have some other way to do this? Perhaps a Disconnect procedure on the dataset class? It seems like DevArt has already done most of the work to make it possible, so perhaps it's not a major addition? Thanks for any comments.

-Mark

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Wed 29 Apr 2009 12:28

We will add this method in the next ODAC build.

MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

Post by MarkF » Wed 29 Apr 2009 14:06

You guys rock! Thanks.

Ludek
Posts: 301
Joined: Thu 12 Oct 2006 09:34

Post by Ludek » Wed 27 May 2009 11:51

Will this method also be available in SDAC?

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Wed 27 May 2009 11:54

We have considered to make the Disconnected property instead of method. This property will be available in SDAC.

Ludek
Posts: 301
Joined: Thu 12 Oct 2006 09:34

Post by Ludek » Wed 27 May 2009 12:02

so if i want to disconnect a connection and leave my datasets open, i set disconnected := true, when I again want to connect, i set disconnected := false?

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Thu 28 May 2009 06:39

You should set the Disconnected property of the dataset to True, if you want to leave the dataset opened after the connection is closed.

You don't need to set Disconnected to False.

We have released the new build with this property.

Ludek
Posts: 301
Joined: Thu 12 Oct 2006 09:34

Post by Ludek » Thu 28 May 2009 06:57

I need that no dataset closes on disconnect. what do you propose is the best approach? before disconnect somehow enumerate all datasets and set their disconnected property to true?

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Thu 28 May 2009 07:35

Set Disconnected := True just after you create a dataset.

Ludek
Posts: 301
Joined: Thu 12 Oct 2006 09:34

Post by Ludek » Thu 28 May 2009 09:40

easy to write, hard to realize, especially if i have many thousands queries on many thousand .dfm forms and next thousands directly in code... (and thousands in future code, where i certainly would forget it) :(
i'll give a next try to disconnectedmode := true and manual calling of the connect method. a hope, it will really work now as designed and no more disconnect itself...

Ludek
Posts: 301
Joined: Thu 12 Oct 2006 09:34

Post by Ludek » Wed 03 Jun 2009 07:32

once again: can I use disconnected mode in other thread or not? i'm creating and using the db connection in the other thread, but i still get disconnected after each command sent...? in main thread it works fine...

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Thu 04 Jun 2009 09:27

You can use DisconnectedMode in a thread if you work with a session in this thread only.

If you use one session from several threads, DisconnectedMode does not work properly.

Ludek
Posts: 301
Joined: Thu 12 Oct 2006 09:34

Post by Ludek » Thu 04 Jun 2009 15:00

i meant again sdac, AFAIK there are no sessions. at least i don't know anything about it...?
i make new post in sdac forum...

Post Reply