Managing attribute domains that have schema locks

4055
4
02-13-2015 09:10 AM
Highlighted
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?

Britt

GIS Technician

City of Auburn, AL

Tags (2)
Reply
0 Kudos
4 Replies
Highlighted
Occasional Contributor III

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

Reply
0 Kudos
Highlighted
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.

Reply
0 Kudos
Highlighted
Occasional Contributor III

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

Reply
0 Kudos
Highlighted
Occasional Contributor II

Britt,

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.
try:
    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
time.sleep(60)

# Disconnect all users from the database.
try:
    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'

# RUN ADDITIONAL PROCESSING HERE

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

‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Regards,

Alex