I am trying to create Spatial Indexes on all the feature classes in one of my databases. It has worked fine on most feature classes so far, but when I started on feature classes in a feature dataset suddenly I was getting errors about locks.
Runtime error Traceback (most recent call last): File "<string>", line 2, in <module> File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\management.py", line 6448, in AddSpatialIndex raise e ExecuteError: ERROR 000464: Cannot get exclusive schema lock. Either being edited or in use by another application. Failed to execute (AddSpatialIndex).
I tested on a couple of other feature datasets, one worked, one gave the same error. Both where it failed contained geometric networks. In a test I deleted the geometric network (leaving all the same feature classes) and the Add Spatial Index tool worked as expected.
Note that I am able to add a spatial index through the right-click feature class properties.
I am using ArcGIS Desktop 10.5 with Advanced license. These feature classes are stored in a local file geodatabase.
In response to comment by @Alex Tereshenkov I have checked there are no locks. I also created a new File Geodatabase and copy/pasted a Feature Dataset that I hadn't used today. This one has feature classes both part of and separate of the geometric network. I tested using tool from ArcToolbox to rule out arcpy being difficult.
Any feature class within the geometric network fails
Any feature class external to the network succeeds (all are within the same feature dataset)
As recommended by @Alex Tereshenkov, I tried everything completely new - I created a new FGDB, Feature Dataset, 2 Feature Classes (1x point, 1x line), and added half-dozen features.
I then closed out and created new Geometric Network with those 2 feature classes.
Add Spatial Join still fails on both feature classes. I have tried with my lines both as Complex (as in my original) and Simple edges, but again it fails.