Select to view content in your preferred language

repeated AddField operations fails in 10.1, works in 10.0

5458
20
Jump to solution
09-10-2012 06:00 PM
TomTyndall
Deactivated User
The following code is throwing exceptions. The exception occurs at different places in the code; where it breaks on one run it may have successfully gotten past on a previous run.

Here's the error I'm receiving:
ExecuteError: ERROR 000464: Cannot get exclusive schema lock.  Either being edited or in use by another application.
Failed to execute (AddField).

This code runs without issue under 10.0.

import arcpy import os, sys from xml.etree import cElementTree as ElementTree  def addCoreFields(fc):     arcpy.AddField_management(fc, "AssetObjectId", "LONG", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")     arcpy.AddField_management(fc, "AssetId", "LONG", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")     arcpy.AddField_management(fc, "AssetObjectStatus", "TEXT", "", "", "32", "", "NULLABLE", "NON_REQUIRED", "")     arcpy.AddField_management(fc, "Status", "TEXT", "", "", "32", "", "NULLABLE", "NON_REQUIRED", "")     arcpy.AddField_management(fc, "Feature", "TEXT", "", "", "32", "", "NULLABLE", "NON_REQUIRED", "")     arcpy.AddField_management(fc, "SubFeature", "TEXT", "", "", "32", "", "NULLABLE", "NON_REQUIRED", "")     arcpy.AddField_management(fc, "AssetCode", "TEXT", "", "", "32", "", "NULLABLE", "NON_REQUIRED", "")     arcpy.AddField_management(fc, "LaneLocation", "TEXT", "", "", "32", "", "NULLABLE", "NON_REQUIRED", "")     arcpy.AddField_management(fc, "Route", "TEXT", "", "", "32", "", "NULLABLE", "NON_REQUIRED", "")     arcpy.AddField_management(fc, "FromMilepost", "LONG", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")     arcpy.AddField_management(fc, "FromOffset", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")     arcpy.AddField_management(fc, "ToMilepost", "LONG", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")     arcpy.AddField_management(fc, "ToOffset", "DOUBLE", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")         if __name__ == '__main__':     scriptPath = sys.path[0]     dataGDB = os.path.join(scriptPath, "data.gdb")     if arcpy.Exists(dataGDB): arcpy.Delete_management(dataGDB)     arcpy.CreateFileGDB_management(scriptPath, "data")      sr = "PROJCS['NAD_1983_StatePlane_Arizona_Central_FIPS_0202_Feet_Intl',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Transverse_Mercator'],PARAMETER['False_Easting',700000.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-111.9166666666667],PARAMETER['Scale_Factor',0.9999],PARAMETER['Latitude_Of_Origin',31.0],UNIT['Foot',0.3048]];-17746700 -44067300 3048;-100000 10000;-100000 10000;3.28083989501312E-03;0.001;0.001;IsHighPrecision"     for name in ['one', 'two', 'three']:           fc = os.path.join(dataGDB, name)         arcpy.CreateFeatureclass_management(dataGDB, name, "POINT", "", "DISABLED", "DISABLED", sr, "", "0", "0", "0")         addCoreFields(fc)
Tags (2)
0 Kudos
20 Replies
TomTyndall
Deactivated User
They're running Microsoft Forefront Endpoint on workstations and servers.

The problem with the pre-built template is that I don't know what fields I'll be adding until run time. I'm reading through xml that defines the schema as well as carrying the data that will end up in the feature classes; and dynamically building the fc's based upon what I find in the xml.

[ATTACH=CONFIG]17675[/ATTACH]
0 Kudos
ChrisSnyder
Honored Contributor
Well that makes it complicated...

Dumb question: Is there any change in behaviour if you leave off the default parameters in AddField? For example:

arcpy.AddField_management(fc, "AssetObjectId", "LONG")
#instead of
arcpy.AddField_management(fc, "AssetObjectId", "LONG", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
Is it possible to temporarily disable Forfront, and at least determine that doing so fixes the issue? Maybe your IT people will make an exception for you... mine did for me.

FYI: I am running the following code in v10.1 SP0 (and actually running it as 16 seperate concurrent python.exe processesall at the same time using the subprocess module) and it is super stable.

#Process: Adds the neccessary fields
arcpy.AddField_management(indxTileFC, "REMSOFT_ID", "LONG"); showGpMessage() #calcs this field in the post-process
arcpy.AddField_management(indxTileFC, "ACCBUFF", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "ADMIN_NM", "TEXT", "", "", "20"); showGpMessage()
arcpy.AddField_management(indxTileFC, "COUNTY_NM", "TEXT", "", "", "20"); showGpMessage()
arcpy.AddField_management(indxTileFC, "CLASS_RPT", "TEXT", "", "", "8"); showGpMessage()
arcpy.AddField_management(indxTileFC, "CLASS_MODL", "TEXT", "", "", "8"); showGpMessage()
arcpy.AddField_management(indxTileFC, "DEFER_RSNS", "TEXT", "", "", "60"); showGpMessage()
arcpy.AddField_management(indxTileFC, "DEFER_YR", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "DFR_YR_MDL", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "DEM_ELV", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "DEM_SLP", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "DISTRCT_NM", "TEXT", "", "", "20"); showGpMessage()
arcpy.AddField_management(indxTileFC, "EAGLES", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "FORESTED", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "HCPLND_FLG", "SHORT"); showGpMessage() #added 20120827
arcpy.AddField_management(indxTileFC, "HCPUNIT_NM", "TEXT", "", "", "20"); showGpMessage()
arcpy.AddField_management(indxTileFC, "ITERATION", "TEXT", "", "", "18"); showGpMessage() #edit made for Rod to QC 
arcpy.AddField_management(indxTileFC, "LANDCOV_CD", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LANDUSE_CD", "TEXT", "", "", "12"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LCL_NW_ID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LCL_PC_ID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LCL_SPS_ID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LCL_E_FLG", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LCL_F_FLG", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LCL_I_FLG", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LCL_S_FLG", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LCL_DF_YR", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LCL_RP_FLG", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LCL_UP_FLG", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LPU_CD", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LPU_NM", "TEXT", "", "", "30"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LSMS_RIP", "TEXT", "", "", "12"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LSMS_UP", "TEXT", "", "", "12"); showGpMessage()
arcpy.AddField_management(indxTileFC, "LYNX_OID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MGMT_FUND", "TEXT", "", "", "4"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_INT_OID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_MA_OID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_MA_NM", "TEXT", "", "", "50"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_PLN_OID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_PLN_LBL", "TEXT", "", "", "50"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_PLN_STA", "TEXT", "", "", "18"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_POL_OID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_POL_LBL", "TEXT", "", "", "50"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_POL_STA", "TEXT", "", "", "18"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_SWA_OID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_SWA_TNM", "TEXT", "", "", "50"); showGpMessage()
arcpy.AddField_management(indxTileFC, "MM_SWA_RSN", "TEXT", "", "", "75"); showGpMessage()
arcpy.AddField_management(indxTileFC, "NRF_DISP_O", "TEXT", "", "", "8"); showGpMessage()
arcpy.AddField_management(indxTileFC, "NSO_FH_OID", "LONG"); showGpMessage() #Future habitat areas
arcpy.AddField_management(indxTileFC, "NSO_KC_OID", "LONG"); showGpMessage() #Kilickitat Core
arcpy.AddField_management(indxTileFC, "NSO_KH_OID", "LONG"); showGpMessage() #Klickitat Habitat
arcpy.AddField_management(indxTileFC, "NSO_MGT_CD", "TEXT", "", "", "3"); showGpMessage()
arcpy.AddField_management(indxTileFC, "NSO_MGT_CS", "TEXT", "", "", "21"); showGpMessage()
arcpy.AddField_management(indxTileFC, "NSO_MGT_AR", "TEXT", "", "", "8"); showGpMessage()
arcpy.AddField_management(indxTileFC, "NSOMGT_OID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "NSO_NESTP", "TEXT", "", "", "4"); showGpMessage()
arcpy.AddField_management(indxTileFC, "O_CMZ_TY", "TEXT", "", "", "2"); showGpMessage() #OESF CMZ buffer type (i or e)
arcpy.AddField_management(indxTileFC, "O_CMZ_WTY", "SHORT"); showGpMessage() #OESF CMZ water type
arcpy.AddField_management(indxTileFC, "O_OC_DIST", "LONG"); showGpMessage() #OESF distance to ocean (saltwater)
arcpy.AddField_management(indxTileFC, "O_RB_DIST", "SHORT"); showGpMessage() #OESF riparian buffer distance
arcpy.AddField_management(indxTileFC, "O_RB_OID", "LONG"); showGpMessage() #OESF riparian buffer objectid
arcpy.AddField_management(indxTileFC, "O_RB_WTY", "SHORT"); showGpMessage() #OESF riparian buffer water type
arcpy.AddField_management(indxTileFC, "O_SWS_ID", "SHORT"); showGpMessage() #OESF subwatershed identified
arcpy.AddField_management(indxTileFC, "O_SWS_PCT", "FLOAT"); showGpMessage() #OESF percent of subwatershed in DNR's forested managment
arcpy.AddField_management(indxTileFC, "O_SWS_UAC", "FLOAT"); showGpMessage() #OESF subwatershed upland acres (no saltwater) 
arcpy.AddField_management(indxTileFC, "O_UNST_SRC", "SHORT"); showGpMessage() #OESF unstable slope data source
arcpy.AddField_management(indxTileFC, "O_UNST_TY", "TEXT", "", "", "2"); showGpMessage() #OESF unstable slope type (i or e)
arcpy.AddField_management(indxTileFC, "O_UNST_WTY", "SHORT"); showGpMessage() #OESF unstable slope water type
arcpy.AddField_management(indxTileFC, "O_WET_TY", "TEXT", "", "", "2"); showGpMessage() #OESF wetland type (i or e)
arcpy.AddField_management(indxTileFC, "OWLS_1R", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "OWLS_1R_E", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "OWLS_M1", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "OWLS_SW", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "PARCEL_ID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "PEREGRINES", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "PLS_OID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "PLS_SEC_NM", "TEXT", "", "", "20"); showGpMessage()
arcpy.AddField_management(indxTileFC, "PLS_TWNRNG", "TEXT", "", "", "8"); showGpMessage()
arcpy.AddField_management(indxTileFC, "REGION_NM", "TEXT", "", "", "20"); showGpMessage()
arcpy.AddField_management(indxTileFC, "RIU_CUR_ID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "RIU_MST_ID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "RMU_POLYID", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "ROAD_BUFF", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "ROAD_DIST", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "ROS", "TEXT", "", "", "8"); showGpMessage()
arcpy.AddField_management(indxTileFC, "ROS_ZN_CD", "TEXT", "", "", "2"); showGpMessage()
arcpy.AddField_management(indxTileFC, "SHU_NM", "TEXT", "", "", "12"); showGpMessage() #added 20120905, csny490 - same as OWNGROUP field
arcpy.AddField_management(indxTileFC, "SLPSTB_AC", "FLOAT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "SOMU_CD", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "SOMU_NM", "TEXT", "", "", "30"); showGpMessage()
arcpy.AddField_management(indxTileFC, "SOMU_PCT", "FLOAT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "SUB_CD", "TEXT", "", "", "8"); showGpMessage()
arcpy.AddField_management(indxTileFC, "SUB_NO", "LONG"); showGpMessage()
arcpy.AddField_management(indxTileFC, "SUB_PCT", "FLOAT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "SUB_UP_AC", "FLOAT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "SUR_OWN_CD", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "SUR_OWN_NM", "TEXT", "", "", "50"); showGpMessage()
arcpy.AddField_management(indxTileFC, "TIM_OWN_CD", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "TIM_OWN_NM", "TEXT", "", "", "50"); showGpMessage()
arcpy.AddField_management(indxTileFC, "WOGHI_INDX", "FLOAT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "WRIA_CD", "SHORT"); showGpMessage()
arcpy.AddField_management(indxTileFC, "WRIA_NM", "TEXT", "", "", "30"); showGpMessage()
arcpy.AddField_management(indxTileFC, "XACT_TY", "TEXT", "", "", "2"); showGpMessage()
arcpy.AddField_management(indxTileFC, "XACT_OID", "LONG"); showGpMessage()
0 Kudos
TomTyndall
Deactivated User
Leaving off the default parameters didn't work, also tried mzcoyle suggesting about putting the field info in a list and iterating through the list when adding fields - similiarly, no work. What's happening in the showGpMessage call in the latest code sample?

All the AV setting's are disabled; going to have to work the AV issue with IT before I can test it.
0 Kudos
ChrisSnyder
Honored Contributor
Bummer...

showGpMessage() is just a logging function - sends the gp messages to txt file.

Might be frustrating, but adding time.sleep(1) between calls to AddField() might be your best option for now... At least you know it works...
0 Kudos
TomTyndall
Deactivated User
I got help with a workaround on the other side of this issue, so I'm back with an in_memory workspace.

Thanks for all your assistance.

Tom
AzDOT
0 Kudos
NathanHeick
Frequent Contributor
After two days of failure, I think I have diagnosed the problem with our ETL after migrating to ArcGIS 10.1.  It seems that Microsoft Forefront is interacting with the files in the file geodatabase while our model and scripts are running, producing highly variable errors and corruption of the file geodatabase.  I am calling Feature Class to Feature Class and Delete from these tools.  The feature classes become read-only and locked and the errors are inconsistent.  This was based on my own investigation.

I decided to research the issue more and I found your Forum post.  Thank you for validation.  I wanted to add my issues to it and see if anyone had anything else to say about it.  We have Microsoft Forefront on both our servers and workstations, so I have been able to reproduce the issue on both Windows 7 and Windows Server 2008 R2.  I uninstalled Microsoft Forefront on my desktop and the issue was resolved.  Any solutions that are workable with Microsoft Forefront?  I will see if there are any settings I can adjust and post them here if they are successful.


Thanks,
Nathan
0 Kudos
NathanHeick
Frequent Contributor
After another day of troubleshooting and planning what to do, I at least learned that under the settings for Real-Time Protection, unchecking Enable Behavior Monitoring resolves my problem, but I cannot modify the system policy for all machines in the City.  I'm wondering if Microsoft Forefront sees certain ArcGIS 10.1 behaviors as suspicious or interferes with the geoprocessing operations with its scanning processes.  I don't see why this would start up at 10.1 versus 10.0.  I'm guessing there might be a definitions update required from Microsoft.  Technical Support is working on the issue, but I thought this was an important subject, so I wanted to leave an update for those who might benefit.  I'm trying to avoid adding exclusions.  I think Esri needs to identify why one version has trouble and not the other, and I think the solution should lie with the vendors on this one, not us changing our policies.
0 Kudos
ChrisSnyder
Honored Contributor
0 Kudos
NathanHeick
Frequent Contributor
I'm still not 100% sure what is causing the problem, but it seems to only occur after repetitive calls to geoprocessing tools.  Also, whenever it has appeared and I have tried disabling the antivirus software, that fixed the problem.  I cannot consistently cause the problem by turning on the antivirus software, but turning it off does seem to fix the problem when it is there.  Usually, the Delete tool appears to delete some of the feature class from the geodatabase metadata, but leaves the table files themselves and the feature classes appear as a tables in the root of the file geodatabase.
0 Kudos
NathanHeick
Frequent Contributor
One behavior we did identify is that the problem seems to only occur when the file geodatabase is open in ArcCatalog.  Previously, this was never a problem.  I could watch the feature classes being deleted one at a time and ArcCatalog would refresh.  It seems the combination of Microsoft Forefront and a shared lock being opened in ArcCatalog while accessing the file geodatabase locks the database from the same user who took out the shared lock, but not necessarily on every geoprocessing tool call, but some of them.  Uninstalling Microsoft Forefront while doing this testing solved the problem.  Reinstalling it did not recreate the problem immediately, but the problems only occur when the antivirus software is installed and Enable Behavior Monitoring is checked under Runtime Protection.  Technical Support created a bug for this:

Bug #NIM085826  Microsoft Forefornt/System Center2012 Endpoint conflicts with file geodatabase operations.

Hope this helps someone searching.
0 Kudos