7

I have a feature class in one of my enterprise geodatabases (10.3.1) that I would like to modify but it is locked by a number of ArcGIS Map Services.

Is there a way to identify specifically which Map Services are locking my feature class? In the GeoDatabase Administrator window (from ArcCatalog) I can see the server and user, however that server and user has hundreds of map services running, and I can't just shut them all off to modify just the one feature class.

enter image description here

Is there a tool/function/command/URL I should be looking at that could tell me specifically which services I need to stop to release the lock on my feature class?

5
  • This is answered here: gis.stackexchange.com/questions/190738/…
    – alexGIS
    May 24, 2016 at 23:57
  • @alexGIS I'm not sure it is. I had already looked at that Q&A however I believe that is the reverse of what I'm asking - That answer explains how to report which feature classes are used by a specified service, and I'm trying to find ALL services that reference my specified feature class
    – Midavalo
    May 25, 2016 at 0:02
  • So you need to build a database of all map services and all the FCs being used by each, using the techniques in that Q&A. Then it's just a matter of selecting a feature class in your database and relating that back to all map services using it. Try doing that, then if you have questions, the community can help you troubleshoot.
    – alexGIS
    May 26, 2016 at 15:56
  • gis.stackexchange.com/questions/101816/… and gis.stackexchange.com/questions/190738/… - have you tried either solution? What about those solutions are not working for you?
    – jbalk
    Feb 24, 2017 at 4:58
  • @jbalk I hadn't seen your first link, so I'll have a good read of that tomorrow. Your second is the same as posted in the comment by alexGIS above, which is the reverse of what I'm after. I'll try to refine my question a bit better in the morning.
    – Midavalo
    Feb 24, 2017 at 6:52

2 Answers 2

5
+100

I actually just created something to do this recently, and plan on implementing it as part of my restapi package eventually once I add more utilities. I just added this serverAdminTools module to GitHub.

To access it, just clone the repo. For finding all services that contain a layer or SDE workspace, you can do the following:

import serverAdminTools   #make sure this is in your PYTHONPATH or use sys.path.append()

url = 'http://gisserver.yourdomain:6080/arcgis/admin/services'

# initialize helper class by loggin in to the ArcGIS Server instance
server = ServerAdministrator(url, 'username', 'password')

# find services that have the parcels layer from this sde database
ws = r'\\arcserver2\SDE_Connections\MN_GIS_LIS.sde'
feature_classes = ['MN_GIS_LIS.DBO.Parcels']
matching = server.find_services_containing(ws, feature_classes)

print matching

This printed the following:

{
  'feature_classes': {
    'MN_GIS_LIS.DBO.Parcels': [{
      'serviceObj': < Service: Duluth_Parcels.MapServer > ,
      'name': 'Duluth_Parcels'
    }]
  },
  'workspace': [{
    'serviceObj': < Service: Duluth_Parcels.MapServer > ,
    'name': 'Duluth_Parcels'
  }]
}

Where the workspace array lists all the services that reference that workspace, and then the feature classes array lists all the services that contain the feature classes that get passed in the list (2nd parameter). The serviceObj in each JSON structure is a reference to a Service in the restapi.admin module.

The find_services_containing() method also supports a third argument to automatically stop the services as they are found. So you can do stuff after you stop the services and restart when you're done. The ServerAdministrator will actually keep track of services that have been stopped within the instance, so you can do some stuff then call startStoppedServices() and they will all be started.

So you can do something like this:

matching = server.find_services_containing(ws, feature_classes, True) # third param is option to stop services, is False by default

# make schema changes to your feature classes
# do more stuff

# now restart the stopped services 
server.startStoppedServices()

# now all services should be up and running (this operation can take a while)

The only other utility I have so far is one to stop a service and compress all databases inside it. It will check for all the unique workspaces in a service, stop the service, run the compress on all relevant databases, and then restart the service. It takes two arguments where the first is a path to your SDE connection files then the service name:

# stop service and compress
sde_dir = r'\\arcserver2\SDE_Connections'
service.stopServiceAndCompressDatabase(sde_dir, 'Duluth_Parcels')

I hope this helps! This has been a huge time saver for my organization.

EDIT:

I changed the source code to use the service manifest.

UPDATE:

This has now been added to the version 1.0 branch of restapi, as as part of the admin sub-package and will soon be merged with the master branch. This is available through restapi like this:

from restapi.admin import utils 
server = utils.ServerAdministrator(server_url, 'username', 'password')
ws = r'\\arcserver2\SDE_Connections\MN_GIS_LIS.sde'
fcs = ['MN_GIS_LIS.DBO.Parcels']
matching = server.find_services_containing(ws, fcs)
print matching
1
0

The lock file should contains the server name and process ID (PID) like MyFeatureClass.MyServerName.57784.63616.sr.lock.

The second number in the file name 63616 is the PID. If you have access to the server, got to the task manager under the Detail tab, search for that PID, and under the Command Line column you can identify the service name

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.