ArcPy Function To Remove Locks on File Geodatabase

2643
2
04-13-2018 12:03 PM
Status: Open
Occasional Contributor III

Not sure if it's possible or hard it would be to implement, but it would be greatly beneficial to have an ArcPy utility function to release all locks on file geodatabases.

2 Comments

Compact Geodatabase will kill any invalid locks. If you're Geodatabase is still locked after running that tool, someone is editing it (hopefully you if its just a File GDB).

As John Dye‌ points out, there is already a means of removing invalid or orphaned locks.  If Compact doesn't work to remove invalid or orphaned locks, it could be the user running the tool doesn't have the proper permissions at the file system level. 

Setting aside the question of whether one should forcefully remove an active lock, doing so involves more than just file system permissions.  Even if a user has the proper file system permissions to remove the lock files, there is still a process with a lock on the file preventing it from being deleted.   A user would have to have local admin privileges on the machine to identity the file handle from those processes and close those handles forcefully, which comes with its own risks.  Good or bad idea aside, forcefully removing active locks in file geodatabase is messy and difficult for Esri to implement technically.