Subject Clear database cache?
Author Matthew Metlis
Hi all,

I've been searching the archives and can't find quite what I'm looking
for, but this seems like a great place for my question. I'm using
Firebird 1.5.3 classic and I am running into several issues that I
believe would all or most be solved if I could somehow tell the
firebird server to clear its cache by writing everything to the disk
(or even to clear the cache without writing the remaining things to
the disk might be OK for what I need) - to ensure that the next
queries I run come from the database file on the disk or at least from
the file system's viewpoint (I don't think I need to worry about the
OS cache). I was wondering if anyone knows of a way to do this?
Telling Firebird through the command-line or by JDBC connection would
be ideal; restarting the FB server would not be a good option unless
it's the only way.

To give a little more info on my problems: I am using firebird in a
Java application deployed to users on Windows XP. There are different
scenarios under which I need to programmatically restore a database
backup (I'm using gbak for this). In one place where the application
does this, I can consistently reproduce inaccurate results from
queries afterwards if I do not restart my application after the
restore before the queries. Inserts actually insert but gets seem to
be using data ignoring the inserts that occurred after the restore, at
least for the first insert/get pair. I am guessing that I am getting
values cached from the old pre-restore database for the gets.

Another problem is that sometimes even after shutting down the Java
application completely, and I believe the application is doing a good
job of closing all its connections to the database before it shuts
down, overwriting the database file with another file through the file
system will not work and Windows tells me the file is in use; although
I am able to simply delete the file if I am not trying to overwrite it
with another file at the same time. There is another time this (same
file is in use) is happening while my program is still running, even
after I close all my program's connections to it, that is preventing
me from restoring a backup using gbak.

I am interested in any solutions to this. Options in Firebird 1.5.3
are ideal, but an upgrade to a different version of Firebird such as
2.x for my application is possible in the long run.

Thanks in advance,
Matt