Discussion:
BDE Private and Net dir
(too old to reply)
Henry
2004-02-22 10:04:32 UTC
Permalink
Hi

I'm struggling with a few BDE problems which I can see has been covered in
this NG several time, however I'm not sure if I have fully understood how to
make the database shared correct.

So I have some questions/facts

The database path must of course be plased in a shared directory (UNC)?
The Alias path parameter will point to the database path.
The session NetFileDir must also be a shared directory (UNC)?
The session PrivateDir must be seperate directory for each application and
cannot not be share between the applications?
Local Share must be true!
Share memory size must be increased to e.g. 8192!
Share memory location could be 5BDE but no there's guaranty?

Especially the private directory bugs me a bit.

Is this all true, have I forgotten something?

regards
Henry
Steven Green
2004-02-22 11:53:05 UTC
Permalink
Post by Henry
Especially the private directory bugs me a bit.
yes, these things are all correct.. why does the "private dir" thing confuse
you?.. this is where the BDE makes temp tables for each user.. if it was shared,
it wouldn't be private <g>


--
Steven Green - Waldorf Maryland USA

Diamond Software Group
http://www.diamondsg.com/main.htm
Paradox Support & Sales - Corel CTech Paradox
---------------------------------------------------
Diamond Sports Gems
http://www.diamondsg.com/gemsmain.htm
Trading Cards and other Sports Memorabilia
---------------------------------------------------
Henry
2004-02-22 12:15:00 UTC
Permalink
Post by Steven Green
Post by Henry
Especially the private directory bugs me a bit.
yes, these things are all correct.. why does the "private dir" thing confuse
you?.. this is where the BDE makes temp tables for each user.. if it was shared,
it wouldn't be private <g>
Yes but, are you talking about user or application?

I have two different applications using the same database, but they are run
by the same user (person) ;o)

regards
Henry
Steven Green
2004-02-22 12:56:42 UTC
Permalink
Post by Henry
I have two different applications using the same database, but they are run
by the same user (person) ;o)
then each independent session must has a unique PRIV.. look at it this way..
Joe in app 1, does a query that makes an Answer table.. at the same time, Joe
in app 2 does another, unrelated query, that also makes an Answer table.. if
the two apps don't have separate PRIV folders, they'll be stepping all over
each other..


--
Steven Green - Waldorf Maryland USA

Diamond Software Group
http://www.diamondsg.com/main.htm
Paradox Support & Sales - Corel CTech Paradox
---------------------------------------------------
Diamond Sports Gems
http://www.diamondsg.com/gemsmain.htm
Trading Cards and other Sports Memorabilia
---------------------------------------------------
Bill Todd (TeamB)
2004-02-22 13:55:48 UTC
Permalink
Post by Henry
The database path must of course be plased in a shared directory (UNC)?
The Alias path parameter will point to the database path.
That is true if you use an alias but you do not have to use an alias
if your application is written in Delphi. You can specify the path in
the Params property of the TDatabase component instead of using an
alias.
Post by Henry
The session NetFileDir must also be a shared directory (UNC)?
The session PrivateDir must be seperate directory for each application and
cannot not be share between the applications?
Not necessarily. See below.
Post by Henry
Local Share must be true!
Share memory size must be increased to e.g. 8192!
That is not correct. Some applications may require SharedMemorySize to
be set to a value higher than the default 2048 but most do not.
Post by Henry
Share memory location could be 5BDE but no there's guaranty?
Steve's explanation of the private directory is correct for
applications written in Paradox for Windows because Paradox for
Windows creates temporary files with fixed names, for example
ANSWER.DB, so each session (user) must have his/her own private
directory.

The BDE creates temporary files with unique names so multiple users
can share a private directory. This is what allows you to put a Delphi
EXE on a shared drive and have all users load the same instance of the
EXE. By default the private directory is the application's startup
directory and this will be the same for all users and will work. If,
however, you set the Session.PrivateDir property in your application
the BDE assumes you are going to create files in the private directory
so it locks the private directory and each session must have its own
private directory. I hope this is clear.

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
Henry
2004-02-22 14:35:12 UTC
Permalink
Post by Bill Todd (TeamB)
Steve's explanation of the private directory is correct for
applications written in Paradox for Windows because Paradox for
Windows creates temporary files with fixed names, for example
ANSWER.DB, so each session (user) must have his/her own private
directory.
The BDE creates temporary files with unique names so multiple users
can share a private directory. This is what allows you to put a Delphi
EXE on a shared drive and have all users load the same instance of the
EXE. By default the private directory is the application's startup
directory and this will be the same for all users and will work. If,
however, you set the Session.PrivateDir property in your application
the BDE assumes you are going to create files in the private directory
so it locks the private directory and each session must have its own
private directory. I hope this is clear.
Hi Bill and Steven

Thanks a lot for your answers!

I have been testing this meanwhile and I have found that setting up a
seperate database, net and private directory have solved my problems with
"invalid parameter", "lock file bla bla" aso. my application is stable when
I'm seriously stress testing it.

I do would however like to avoid setting up the private directories, and if
I understand you correctly then I should just leave that property alone
which would then cause the BDE to handle the tempory files automatically, is
that correct?

The situation is that I have two applications (exe) laying in the same
directory (bin) these two applications shares the database which is in
another directory, now I have an alias which both appls are using and a net
directory which is the same for both appls. On top of that, I have made two
private directories on for each appls APP1 and APP2.

Now this runs perfect at present time when I'm running one instance of each
appl on the same PC, but will I face problems later when I get multiple
users accros the network?

Directory structures

\\server\MyApplication\bin\Appl1.exe
\\server\MyApplication\bin\Appl2.exe
\\server\Myapplication\database (database directory)
\\server\Myapplication\database\net (net directory all appls)
\\server\Myapplication\database\APP1 (private directory appl 1)
\\server\Myapplication\database\APP2 (private directory appl 2)


regards
Henry
C P
2004-02-22 16:09:08 UTC
Permalink
I'd suggest setting your private directory to a location on users local
machine. The Windows API function GetTempPath will allow you to get the
%TEMP% (or %TMP%) folder for a user's machine. With something like Paradox
that's not client-server, you'll get better performance if more of your
tables are local. Shared tables will have to be on a network location, but
your private tables can be local. You'll lose performance if your app has
to go accross the network to deal with it's temporary folders.

What I have generally done is create a structure like this:

%TEMP%\MyApp\20040222\
%TEMP%\MyApp\20040223\
%TEMP%\MyApp\20040224\
etc.

for my temp files. You can see the last folder in the path is actually a
date (YYYYMMDD). When my app starts it checks for any of these folders
whose date is more than 2 days old, and deletes them. I like to keep my
temp files seperate from the base temp folder to make it easier to clean
things up. The reason for the dated folders is that on NT-based OS'es an app
that uses the BDE can't delete folders containing tables used by the BDE
(even if the tables have been properly closed) until the app has shut down
and been restarted. By deleting folders more than 2 days old when the app
starts, I'm able to clean up anything that remains because of crashes or
this NT issue. By putting the 2 day delay, I avoid deleting stuff that may
be in user (no one keeps my app running for more than a working day at a
time).

The nice thing about using GetTempPath for figuring out where to put your
PRIV folders is that you are using the 'proper' place for temp files.
Generally this will be on the local drive, and for cases where users don't
have local harddrives, the admin will have probably defined %TEMP% to be on
the network, so everything will still work OK (though maybe not as fast as
with a local drive).
Steven Green
2004-02-22 16:31:34 UTC
Permalink
Shared tables will have to be on a network location, but your private tables
can be local. You'll lose performance if your app has to go accross the
network to deal with it's temporary folders.
Bill's advice is excellent, of course.. a separate "priv" for each user isn't
required in all platforms using BDE.. but there are other considerations, such
as the above..

no matter what the platform, if there is heavy "private" activity, a local priv
can help performance dramatically..

in my apps, a "private holding area" is also needed for other files used by
and/or produced by the apps, and the "priv" is a convenient choice, because it's
always there.. (for performance reasons, and because my apps *are* Paradox)..

and.. the number of files in a folder, temp or permanent, can in itself have a
big impact on performance.. even on the screaming fast machines we use these
days.. I was just with a new client that had almost 4,000 files in the main
shared folder for their apps.. it only took about a minute to show them the
*huge* difference, when the shared folders only hold a few hundred files..


--
Steven Green - Waldorf Maryland USA

Diamond Software Group
http://www.diamondsg.com/main.htm
Paradox Support & Sales - Corel CTech Paradox
---------------------------------------------------
Diamond Sports Gems
http://www.diamondsg.com/gemsmain.htm
Trading Cards and other Sports Memorabilia
---------------------------------------------------
C P
2004-02-22 17:07:34 UTC
Permalink
Post by Steven Green
in my apps, a "private holding area" is also needed for other files used by
and/or produced by the apps, and the "priv" is a convenient choice, because it's
always there.. (for performance reasons, and because my apps *are* Paradox)..
In addition to setting the PRIV directory to "%TEMP%\MyApp\YYYYMMDD", I too
use this folder for any non-BDE temporary files my app may need. This has
the performance benefit like you said, but also another important benefit.
If your app is ever set up in a Terminal Server environment, then you'll be
OK. Even though everyone will be running on the same machine, the fact that
you're putting temp files somewhere in %TEMP% will keep people from
interfering with each other. By using a %TEMP%-based path for temp files,
you ensure that every user's temp files are actually being put in a separate
folder. (As Bill mentioned, this stuff isn't an issue with the BDE part of
Delphi apps, but for other temp files it could be a problem if multiple
users on the same machine have the same temp path).
Henry
2004-02-22 17:26:22 UTC
Permalink
Post by Steven Green
by
Post by Steven Green
and/or produced by the apps, and the "priv" is a convenient choice,
because it's
Post by Steven Green
always there.. (for performance reasons, and because my apps *are*
Paradox)..
In addition to setting the PRIV directory to "%TEMP%\MyApp\YYYYMMDD", I too
use this folder for any non-BDE temporary files my app may need. This has
the performance benefit like you said, but also another important benefit.
If your app is ever set up in a Terminal Server environment, then you'll be
OK. Even though everyone will be running on the same machine, the fact that
you're putting temp files somewhere in %TEMP% will keep people from
interfering with each other. By using a %TEMP%-based path for temp files,
you ensure that every user's temp files are actually being put in a separate
folder. (As Bill mentioned, this stuff isn't an issue with the BDE part of
Delphi apps, but for other temp files it could be a problem if multiple
users on the same machine have the same temp path).
Thank you for your very valuable suggestions, this is simply great.

I do however still have one question for you.

As I wrote I have 2 appls sharing the same database, so netfiledir and
database are the same.

Is it okay to use e.g "%TEMP%\MyApp\YYYYMMDD" as PrivDir for both
applications running on the same PC?

regards
Henry
Henry
2004-02-22 17:50:19 UTC
Permalink
Post by Henry
Is it okay to use e.g "%TEMP%\MyApp\YYYYMMDD" as PrivDir for both
applications running on the same PC?
no.. once you set a Priv, it must be unique for each app.. on the same
machine,
the above will be the same for each instance..
Which then will result in

"%TEMP%\MyApp1\YYYYMMDD"

"%TEMP%\MyApp2\YYYYMMDD"

regards
Henry
Steven Green
2004-02-22 17:44:48 UTC
Permalink
Post by Henry
Is it okay to use e.g "%TEMP%\MyApp\YYYYMMDD" as PrivDir for both
applications running on the same PC?
no.. once you set a Priv, it must be unique for each app.. on the same machine,
the above will be the same for each instance..


--
Steven Green - Waldorf Maryland USA

Diamond Software Group
http://www.diamondsg.com/main.htm
Paradox Support & Sales - Corel CTech Paradox
---------------------------------------------------
Diamond Sports Gems
http://www.diamondsg.com/gemsmain.htm
Trading Cards and other Sports Memorabilia
---------------------------------------------------
Olivier Sauterel
2004-03-03 15:21:31 UTC
Permalink
Hi all,
Just another question:
- What happens if Private directory will be for sample: "C:\Temp\MyApp" but
there is 2 instance of application
that implies also 2 applications using the same database, same private
directory and same user ???
- How do you setup the Local Share to true ? -> HandleShare property ?
- How do you setup the Share Memory size ? -> in BDE admin tools ?

Regards Olivier
Post by Bill Todd (TeamB)
Post by Henry
The database path must of course be plased in a shared directory (UNC)?
The Alias path parameter will point to the database path.
That is true if you use an alias but you do not have to use an alias
if your application is written in Delphi. You can specify the path in
the Params property of the TDatabase component instead of using an
alias.
Post by Henry
The session NetFileDir must also be a shared directory (UNC)?
The session PrivateDir must be seperate directory for each application and
cannot not be share between the applications?
Not necessarily. See below.
Post by Henry
Local Share must be true!
Share memory size must be increased to e.g. 8192!
That is not correct. Some applications may require SharedMemorySize to
be set to a value higher than the default 2048 but most do not.
Post by Henry
Share memory location could be 5BDE but no there's guaranty?
Steve's explanation of the private directory is correct for
applications written in Paradox for Windows because Paradox for
Windows creates temporary files with fixed names, for example
ANSWER.DB, so each session (user) must have his/her own private
directory.
The BDE creates temporary files with unique names so multiple users
can share a private directory. This is what allows you to put a Delphi
EXE on a shared drive and have all users load the same instance of the
EXE. By default the private directory is the application's startup
directory and this will be the same for all users and will work. If,
however, you set the Session.PrivateDir property in your application
the BDE assumes you are going to create files in the private directory
so it locks the private directory and each session must have its own
private directory. I hope this is clear.
--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
Bill Todd (TeamB)
2004-03-03 16:32:02 UTC
Permalink
On Wed, 3 Mar 2004 16:21:31 +0100, "Olivier Sauterel"
Post by Olivier Sauterel
- What happens if Private directory will be for sample: "C:\Temp\MyApp" but
there is 2 instance of application
If the app sets Session.PrivateDir you will get an error.
Post by Olivier Sauterel
that implies also 2 applications using the same database, same private
directory and same user ???
- How do you setup the Local Share to true ? -> HandleShare property ?
Choose Configuration | System | Init

What do you mean by "-> HandleShare property "?
Post by Olivier Sauterel
- How do you setup the Share Memory size ? -> in BDE admin tools ?
Choose Configuration | System | Init

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)

Loading...