Subject Re: [firebird-support] Keeping database connection permanently open
Author Helen Borrie
At 10:43 PM 16/11/2006, you wrote:
>Hi,
>
>In my IntraWeb applications, I typically do the following upon
>destroying sessions:
> IBDatabase1.CloseDataSets;
> IBDatabase1.ForceClose;

This doesn't shut down the database, it closes the connection that
your client had with the database. If nothing else was connected
then the database is just a closed file. There is nothing to time
out. Shutting down a database doesn't shut down the server, unless
you are using the embedded server as your client library.


>My session timeout is configured as 60 minutes. It seems after the
>last session terminated, the database goes offline. Mustn't I
>perhaps reduce the 2-hour keepalive timeout of Windows to 60 minutes
>(my session timeout)?

No, it has nothing to do with anything you are talking about, except
of course if you have crashed or abandoned instances of your web
application hanging about. In that case, you have dead connections
around and the server will *begin* to detect them once the NOS's
timeout has expired. Generally, if a system has web clients that
wander away while their connection is active, the NOS will discover
them eventually and start to time them out. You would want to
shorten the socket timeout setting on the NOS, so that the Firebird
server gets notified sooner and can clean up the dead transactions
that much sooner.

>I also open a database connection per session. I know this is not
>optimal and I must have only one connection per database per process
>and therefore I must use DataModule pooling and not to
>"IBDatabase1.ForceClose;"

This looks a lot like terminology confusion, or something. You never
"close" a database, you disconnect from it - close the connection, if
you like. The database file itself will be closed when the last
connection has been closed. So one instance of your application
closing its connection doesn't "close the database" or stop the
server. I think your statement above means that you run one instance
of your application for each user that connects to your webserver....does it?

"Datamodule pooling" doesn't mean anything to me except that your
application is written in Delphi or C++Builder. But if your
application is an ISAPI module, then a "session" MUST be a distinct
connection and distinct transaction and data access objects for each
instance that the module is called.


>The problem I have is the database (about 600 MB) take about 20
>seconds to open after shut-down.
>The mentioned database is the one under "What's new!" on www.tamaracka.com

I bet you are on WinXP and your database file has the extension
".fdb". If so, read the READ THIS FIRST section of the release notes
and all will be revealed.

However, f you place the database connection (your IBDatabase object)
outside of the ISAPI module then you *are* likely to have the
database *server* crashing, with possibly a window of blindness
before the Guardian restarts it. After that, it will be just a
matter of time before it crashes again. You cannot share a database
connection between threads (and your ISAPI module instances are threads.)

>By the way, can't the postings on this newsgroup be passed on to
>Tamarack Associates for indexing?

I don't know. Can they? can't they? This isn't a newsgroup,
though. It is a mail list. If you are reading these messages as
news articles on news.atkin.com then you are seeing a news mirror of
the mail list archive.

A moderator request: please trim your messages and do not top-post.

^ heLen