File geodatabases and locking

If you are the only person working with a dataset in a file geodatabase and are accessing it through one process only, you can edit or modify its properties or contents. You can also delete, compress, or decompress datasets in the geodatabase.

However, ArcGIS prevents you from performing any of these operations if another process is already accessing the data, whether it be a process on your computer, another computer, or a web service. After the other process terminates, you can again perform these operations. For example, if you have a feature class displayed in a map in ArcGIS Pro and attempt to delete the same feature class from the geodatabase, you will get the following message:

Failed to delete selected object(s) Cannot acquire a schema lock because of an existing lock.

If you close the map 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. This prevents 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 through 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 can 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 Compact geoprocessing tool or copy and paste the data in ArcGIS. 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 applications or web services simultaneously. Close one of the applications or stop the service 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 an application does not appear to be running, it may not have closed properly and could still be holding a lock on the data. Check the Microsoft Windows Task Manager for such processes and end them.