Chapter 8. Administering Berkeley DB XML Applications

Table of Contents

Temporary Files
A Note on Snapshot Isolation

This book has until now been an introduction on how to use the BDB XML API to add a native XML database to your application. But having written that application, there's some administrative concerns that you should keep in mind as your application moves into production. These concerns are described in this chapter.

Temporary Files

All Berkeley DB XML applications are capable of writing temporary files to disk. This happens when the disk cache fills up and so BDB XML is forced to write overflow pages. For the most part, these temporary files can be safely ignored.

However, for some class of applications, the presence of the temporary overflow files can be problematic. You can prevent temporary files from being created on your hard drive by creating your disk cache large enough that it can contain your entire working set of data. You do this using the DB_ENV->set_cachesize() method prior to opening your environment.

Note

It is always safe to delete temporary overflow files written by BDB XML after the application has shutdown.

Temporary database files are placed in the directory identified by the DB_ENV->set_temp_dir() method. If this method is not called by the application, then the application will use the directory identified on an environment variable, if your application is configured to do this. Assuming that it is appropriately configured, then the following environment variables are checked to see if they have been set. The following order of precedence matters; the first of the following environment variables found to be set is used to determine the location of the temporary directory:

  1. TMPDIR

  2. TEMP

  3. TMP

  4. TempFolder

  5. TMPDIR

If none of these environment variables are set, BDB XML checks the value returned by the GetTempPath interface to see if that is set. If not, then the default location identified above are attempted.

Note

Environment variables are not used by BDB XML applications unless the DB_USE_ENVIRON or DB_USE_ENVIRON_ROOT flags are set when the environment is opened.

If no other method of determining the location of the temporary file directory can be found, then BDB XML will resort to using built-in default values. That is, the first of the following locations found to exist is used, if a temporary file directory is not otherwise identified for BDB XML:

  1. The directory /var/tmp

  2. The directory /usr/tmp

  3. The directory /temp

  4. The directory /tmp

  5. The directory C:/temp

  6. The directory C:/tmp