If you are the sole user working with a dataset in a file geodatabase and are accessing it via one process only, you are able to freely edit or modify its properties. You are also able to delete, compress, or decompress the dataset.
However, if another process is already accessing the data, whether it be a process on your computer or another user's, ArcGIS prevents you from performing any of these operations until the other process has terminated. For example, if you have a feature class displayed in ArcMap and attempt to delete it from the Catalog tree, you will get the following message:
Failed to delete selected object(s) Cannot acquire a schema lock because of an existing lock.
If you then close ArcMap and try again, you can delete the feature class, provided there are no other processes accessing the data.
When a process accesses a dataset, it locks the dataset, preventing other processes from modifying it. Accessing a dataset also locks additional related datasets as follows:
- A process accessing a feature class within a feature dataset locks all the feature classes in the feature dataset.
- Locks apply to both sides of a relationship class. That is, if two stand-alone feature classes are related via a relationship class and a process accesses one of them, both feature classes lock.
To keep track of locked datasets, ArcGIS places *.lock files in the file geodatabase folder. When a process terminates, the .lock files associated with it are automatically deleted. In some cases, however, such as when a process ends prematurely, .lock files may be left behind in the geodatabase folder. These .lock files are eventually removed by ArcGIS in future sessions as new locks are taken. They are also removed whenever you run the geoprocessing Compact tool or copy and paste the data in the Catalog tree. In the meantime, these .lock files do not continue to lock data.
Locks are critical for file and process management. However, sometimes it can seem like they get in the way. If you are ever prevented from editing a dataset or its properties or from deleting, compressing, or decompressing, it is because one of the following is happening:
- You are accessing the data with two or more processes simultaneously, such as ArcMap and ArcCatalog or ArcCatalog and Python. Close one of the applications so you can perform the operation you want.
- Another process on your computer is still accessing the data because it did not terminate properly. For example, even though ArcCatalog does not appear to be running, it may not have closed properly and could still be holding a lock on the data. Check your Task Manager for such orphaned processes and end them.
- The data is being accessed by one or more processes on another computer. Wait for the processes to terminate or have the user or users terminate any process accessing the data.
If you do not know what other computers are accessing the data, use Windows Explorer to carefully delete the *.lock files in the file geodatabase folder. Exercise caution when doing this—accidental deletion of files other than .lock files can corrupt the data. After deleting the .lock files, look at the names of .lock files that you cannnot delete. The names of these remaining .lock files contain the names of the computers still accessing the data. For example, a .lock file named xxx.PLUTO.15332.sr.lock indicates the computer PLUTO is accessing the data.As a last resort, you can clear all active locks by restarting the computer containing the file geodatabase. However, before you do this, make sure nobody is accessing the data; otherwise, their work may not be saved.