TurboDB Engine Documentation
Multi-User Access and Locking
By default TurboDB tables are opened in shared mode. This allows applications to access the same database tables at the same time. In order to prevent inconsistent changes to the table, there is a transparent locking mechanism that locks a record for the time it is modified by one application.
Some operations need exclusive access to a database table and are therefore rejected if another application accesses the table. These operations are:
|•||Altering a table|
|•||Deleting a table|
|•||Deleting an index|
Because TurboDB Engine is a file-based database engine, it must manage its locks via a lock file. The lock file for a table has the same name as the table itself but the extension is "net". The lock files contains a list of all applications that access the database table and manages the different locks on that table.
When an application wants to write to the database table, it must first look into the lock file to determine, if it is allowed to do so. If it is, it registers itself with the lock file for write access, performs the writing and then unregisters again. The lock file is created by the first application that accesses the table and deleted when the last application finishes access. Therefore a database table has no lock file as long as it is unused.
Note: If an application crashes or is killed while it has locked the table or a record of the table, it cannot remove the lock and the lock persists. This is especially the case while debugging an application that uses TurboDB Engine, because resetting it while it has acquired a lock has the same effect. As of version 4, TurboDB has a unique mechanism for detecting such dead locks and removing them automatically.