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.

Why would the Add Spatial Index fail on a geometric network? I cannot find anything in the Geometric Network and Spatial Index (and related) docs to indicate why this would happen.

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

enter image description here

Any feature class external to the network succeeds (all are within the same feature dataset)

enter image description here

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.

  • Just a wild guess - could there be any orphan locks left since arcpy accessed the dataset? Restart the machine? Could it be that a lock is created on a dataset after you've accessed another feature class adding an index there (like all datasets in FD are locked somehow?) – Alex Tereshenkov May 29 '17 at 17:49
  • I've tested creating a dummy geometric network with a feature class in a file gdb and I am able to run the Add Spatial Index GP tool on the feature class that participates in the geometric network. I'd probably start looking into properties of a geometric network and try to modify its properties one after one to see when it starts failing (ie create the most primitive geometric network and then come closer to how it should be while running Add Spatial Index after every modification). Does it make sense? Our environment is identical in terms of version and licensing. – Alex Tereshenkov May 30 '17 at 15:45
  • @AlexTereshenkov Thank you for that, it confirms that the tool should be working. I'll give that a test when I'm back at my computer. It is odd, the geometric network is fairly basic with no rules at all. But will test and report back. – Midavalo May 30 '17 at 16:49
  • @AlexTereshenkov I have updated my question with results of extra testing in response to your comments – Midavalo May 31 '17 at 1:37
  • Did this one ever resolve? If not, I am wondering whether creating a simple test Geometric Network using ArcPy might be a way to produce a fully documented procedure that will enable it to be reproduced without access to your data.. – PolyGeo Jul 20 '18 at 3:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.