Select to view content in your preferred language

Managing attribute domains that have schema locks

02-13-2015 09:10 AM
New Contributor III

We have an attribute domain that will need to be updated on a regular basis as new values are added to a master table of street names, and we are trying to find a way to script out the updating of it. Now the issue is this domain is assigned to fields in several feature classes that will almost always have schema locks on them from users leaving ArcMap documents open and some map services.

We have tried several versions of a workflow in our Python script; but it always ends up reporting the same error at some point:

ERROR 000464: Cannot get exclusive schema lock.  Either being edited or in use by another application.

  • Our first attempt was to simply use the Table to Domain tool to overwrite the existing domain values; but that crashes due to the error.
  • Secondly, we tried to first remove the domain from the pertinent feature class fields, then use Table to Domain to replace the domain values; but the script throws the error when trying to reassign the domain to the needed fields.
  • Our other possibility was to generate a list of all the current domain values, delete those values from the domain, and then append in the new values with Table to Domain (thinking that maybe appending instead of overwriting on the domain would solve it); but the error appears here when trying to delete the existing values from the domain.

When our nightly update scripts run there will almost always be some schema locks on that domain; so we need to find a way to update the domain with those present if possible.

Wondering if anyone has run into a similar issue and found a workflow that gets around those pesky schema locks?


GIS Technician

City of Auburn, AL

Tags (2)
0 Kudos
4 Replies
Occasional Contributor III

Did you ever get an answer? I'm running into the same issue here.

0 Kudos
New Contributor III

Venus, we haven't gotten any answer to this issue so far. We're still having to manually kill locks and update the domains as-needed.

0 Kudos
Occasional Contributor III

Bummer. If I find out anything, I'll post it. Thanks.

0 Kudos
Occasional Contributor II


Have you looked into blocking connections to your database then disconnecting all users?  You would need SDE or DBO level rights on your geodatabase.  

Your script would connect using SDE or DBO and that connection would remain active.  However, you would ensure no additional locks by blocking connections and disconnecting all users:

import arcpy
import time
from arcpy import env

# Connection to database (SDE User), set workspace
database_conn = r'Database Connections\Enterprise.sde'
env.workspace = database_conn

# Block new connections to the database.
    print 'Blocking connections in %s' % database_conn
    arcpy.AcceptConnections(env.workspace, False)
except (arcpy.ExecuteError, arcpy.ExecuteWarning) as e:
    print e
    print 'Blocked all connections'

# wait 60 seconds

# Disconnect all users from the database.
    print 'Disconnecting all users from %s...' % database_conn
    arcpy.DisconnectUser(env.workspace, "ALL")
except (arcpy.ExecuteError, arcpy.ExecuteWarning) as e:
    print e
    print 'Disconnected all users'


# Allow the database to begin accepting connections again
    print 'Accepting Connections from %s...' % database_conn
    arcpy.AcceptConnections(env.workspace, True)
except (arcpy.ExecuteError, arcpy.ExecuteWarning) as e:
    print e