Board index » delphi » TQuery in Threads, Multi-user Paradox problem.

TQuery in Threads, Multi-user Paradox problem.

Problem:

        After adding a record from one machine (A), the second machine
(B) does not see it, until it(B) adds a record.  Then (B) will see both
(A)'s record and it's(B) new record.   Then the other user (A) won't see
the new record that the (B) machine added.  

        The Record is written right away, it is physically there, it is
just that the other computer's BDE doesn't seem to care that it has been
updated.

        If I close the application on machine (A), then reopen it, btw,
the query will then have the correct results.

        I have a hotkey in my program to refresh the TQuery by closing
then re-opening it.  I have even gone so far as to delete the TQuery and
then dynamically recreate it entirely.  But it doesn't seem to matter.  
It is like the BDE is caching the results in memory, and refuses to
check
the original table, until it makes a write to the table.

        I have read that you have to refresh all the tables if you are
using the same session; however both complex queries are in another
thread each with a unique datasource & unique session.  

        LocalShare is also set to true.

        Any Idea's on what I can do to force the BDE to flush its cache
after I close the query, so that when I re-open the query I have the
updated results?

Nathan Anderson.

 

Re:TQuery in Threads, Multi-user Paradox problem.


Quote
Nathan Anderson wrote in message <3900D946.985D0DDE@_REMOVE_msn.com>...

>        After adding a record from one machine (A), the second machine
>(B) does not see it, until it(B) adds a record.  Then (B) will see both
>(A)'s record and it's(B) new record.   Then the other user (A) won't see
>the new record that the (B) machine added.

>        I have a hotkey in my program to refresh the TQuery by closing
>then re-opening it.  I have even gone so far as to delete the TQuery and
>then dynamically recreate it entirely.

Simply closing and opening the TQuery *should* be enough. Doing any more
than that is clutching at straws.

Quote
>        LocalShare is also set to true.

Good. Also make sure the Private Dir is set to a local directory and the Net
Dir is set to a *shared* directory on the server. All clients *must* be
looking at this same Net Dir file. That's the only thing I can think of that
might be causing you problems.

--
Wayne Niddery - WinWright Consulting
RADBooks - http://members.home.net/wniddery/
You have a Right to Free Speech, but not the right to make me listen, nor to
use my property as a soapbox.

Re:TQuery in Threads, Multi-user Paradox problem.


On Fri, 21 Apr 2000 13:42:14 -0700, Nathan Anderson

Quote
<Nathan_Anderson@_REMOVE_msn.com> wrote:
>        After adding a record from one machine (A), the second machine
>(B) does not see it, until it(B) adds a record.  Then (B) will see both
>(A)'s record and it's(B) new record.   Then the other user (A) won't see
>the new record that the (B) machine added.  
[snip]        
>        I have read that you have to refresh all the tables if you are
>using the same session; however both complex queries are in another
>thread each with a unique datasource & unique session.  

Do you have a TTable instance or a live query that still has an open
cursor on one of the tables used in your query when you close and
re-open the query?  It this is the case, you'll need to call Refresh
on these before re-opening the query.

Jan

Re:TQuery in Threads, Multi-user Paradox problem.


Wayne,

Quote
>        After adding a record from one machine (A), the second machine
>(B) does not see it, until it(B) adds a record.  Then (B) will see both
>(A)'s record and it's(B) new record.   Then the other user (A) won't see
>the new record that the (B) machine added.
>        I have a hotkey in my program to refresh the TQuery by closing
>then re-opening it.  I have even gone so far as to delete the TQuery and
>then dynamically recreate it entirely.
>>Simply closing and opening the TQuery *should* be enough. Doing any more

than that is clutching at straws.<<

        I wish it was that simple, because that is what I read.  It works
perfectly if it is a single user program.  Once you go multi-user, the
only problem is that the every client _except_ the last client which
posted does not have the current records.  

        It _seems_ as if the BDE is caching a copy of the database locally and
using it until it is forced to write a new record, once it writes then
it "refreshes" its local copy against the server.  Because all
open/closes of any TQueries are getting the same data.  If I close the
application then re-open the application it gets the correct data.

Quote
>>Good. Also make sure the Private Dir is set to a local directory and the Net Dir is set to a *shared* directory on the server. All clients *must* be looking at this same Net Dir file. That's the only thing I can think of that might be causing you problems.<<

        Currently dynamically creating a sub-directory under the application
subdirectory in the temp directory for each thread/session for the
private directories.  (i.e. C:\windows\temp\appname\tempxxxx) Then upon
shutdown delete the temp files and temp directories that I created...

        All Net directories are pointed to a specific network "net" directory.  

See ya, Nathan.
P.S. Any other ideas?

Re:TQuery in Threads, Multi-user Paradox problem.


Quote
Jan Sprengers wrote:

> Do you have a TTable instance or a live query that still has an open
> cursor on one of the tables used in your query when you close and
> re-open the query?  It this is the case, you'll need to call Refresh
> on these before re-opening the query.

        Yes, in the primary default Session I have a Live Query.   Do I have to
refresh all the other sessions, even though the sessions are supposed to
be unique?

See ya, Nathan.

Re:TQuery in Threads, Multi-user Paradox problem.


The BDE *does* cache data locally unless Local Share is set to True on all
machines.  It sounds like that's your problem.

Paul / ColumbuSoft
www.columbusoft.com

Quote
Nathan Anderson <Nathan_Anderson@_REMOVE_msn.com> wrote in message

news:390728C4.5BC43D00@_REMOVE_msn.com...
Quote
> Wayne,

> >        After adding a record from one machine (A), the second machine
> >(B) does not see it, until it(B) adds a record.  Then (B) will see both
> >(A)'s record and it's(B) new record.   Then the other user (A) won't see
> >the new record that the (B) machine added.

> >        I have a hotkey in my program to refresh the TQuery by closing
> >then re-opening it.  I have even gone so far as to delete the TQuery and
> >then dynamically recreate it entirely.

> >>Simply closing and opening the TQuery *should* be enough. Doing any more
> than that is clutching at straws.<<

> I wish it was that simple, because that is what I read.  It works
> perfectly if it is a single user program.  Once you go multi-user, the
> only problem is that the every client _except_ the last client which
> posted does not have the current records.

> It _seems_ as if the BDE is caching a copy of the database locally and
> using it until it is forced to write a new record, once it writes then
> it "refreshes" its local copy against the server.  Because all
> open/closes of any TQueries are getting the same data.  If I close the
> application then re-open the application it gets the correct data.

> >>Good. Also make sure the Private Dir is set to a local directory and the

Net Dir is set to a *shared* directory on the server. All clients *must* be
looking at this same Net Dir file. That's the only thing I can think of that
might be causing you problems.<<

- Show quoted text -

Quote

> Currently dynamically creating a sub-directory under the application
> subdirectory in the temp directory for each thread/session for the
> private directories.  (i.e. C:\windows\temp\appname\tempxxxx) Then upon
> shutdown delete the temp files and temp directories that I created...

> All Net directories are pointed to a specific network "net" directory.

> See ya, Nathan.
> P.S. Any other ideas?

Re:TQuery in Threads, Multi-user Paradox problem.


On Wed, 26 Apr 2000 08:37:43 -0700, Nathan Anderson

Quote
<Nathan_Anderson@_REMOVE_msn.com> wrote:
>    Yes, in the primary default Session I have a Live Query.   Do I have to
>refresh all the other sessions, even though the sessions are supposed to
>be unique?

No.  If this is in another session, it is supposed not to share any
cursors with the one you're having problems with.
The problem that you're having is - I think - caused by the BDE
caching the cursor used for an INSERT query.  This has been reported
before here.  The problem would be solved if you could refresh that
cached cursor, but unfortunately, you can't.

The only workaround that I know of, is to close the session and
database that you used for the INSERT query.  That effectively
releases the cached cursor.

HTH,

Jan

Re:TQuery in Threads, Multi-user Paradox problem.


Jan,

Quote

> No.  If this is in another session, it is supposed not to share any
> cursors with the one you're having problems with.

>> The problem that you're having is - I think - caused by the BDE
> caching the cursor used for an INSERT query.  This has been reported
> before here.  The problem would be solved if you could refresh that
> cached cursor, but unfortunately, you can't.

> The only workaround that I know of, is to close the session and
> database that you used for the INSERT query.  That effectively
> releases the cached cursor.<<

        Interesting.  I will have to try and create a new session  for this
live query and then try the close/open trick.  Thanks for at least
another direction to try...

See ya, Nathan.

Re:TQuery in Threads, Multi-user Paradox problem.


Paul,

Quote
>> The BDE *does* cache data locally unless Local Share is set to True on all machines.  It sounds like that's your problem.<<

        Unfortunately that isn't my problem.  :-(   Local Share is set to true
on all machine.  
See ya, Nathan.

Other Threads