Limit on open files
When writing audit-data for a table, the audit server must open the information file and one sequence file for that table. After these files are opened, the files are kept open for subsequent use, even after the end of a transaction. These open files can be used in all subsequent transactions involving this table.
Having so many files open, however, implies that the server can reach the operating systems limit of maximum open files per process. For example, if a transaction involves 15 tables, 30 files are opened at the end of that transaction. If the next transaction has 10 different tables, 20 more files are opened. At the end of the second transaction, 50 files are open, which exceeds the maximum limit.
When this limit is reached, the server closes two open files: the information file and the sequence file for a table. The server uses the least recently used (LRU) criteria to choose the table for which the files are closed.
The audit server uses a data structure called a handler to keep track of the file descriptors for the information and sequence files on each table. When these files are opened, the file descriptors are stored in the handler.
The handlers of all tables are kept in a linked list in an LRU manner. For example, when files are first opened, the handler is allocated and is put in most recently used (MRU) position. As other tables are opened, this handler moves toward the LRU position. Later on, if this table is involved in another transaction, the same handler is reused and is again moved to the MRU position. In addition, when a file is open, all data is written to the file before the data goes to the next table. As a result, until all data is written for a table in the current transaction, the handler for that table is guaranteed to stay in the MRU position and in no way can the handler reach the LRU position.
If the audit server reaches the open file limit when opening a new information file, sequence file, or overflow file, the server picks up the LRU handler in the handler list and closes the handler’s information file and sequence file. The assumption is that because the table has not recently been used, this table is the best choice as a victim for closing files.