Edit operation failed - data is currently locked?

9269
18
03-07-2016 07:41 AM
by Anonymous User
Not applicable

I'm trying to use an edit operation to populate attributes of a newly added field in a feature class. But the edit operation fails with the following message:  "Edit operation failed. The data is currently locked by another user and cannot be saved"

My workflow is as follows:

  1. Create new feature class using existing feature class as template (using GP) - success
  2. Copy selected features in template feature class to the new feature class (using GP) - success
  3. Create a new field in feature class (using GP) - success
  4. Try to populate the new field (using this example) - error

What's locking the data? It's certainly not another user. I'm the only user. The gdb workspace is a temp folder in my user appdata dir.

The data isn't on the map or open anywhere else.

18 Replies
by Anonymous User
Not applicable

Yes this is an issue after Add Field or anything that grabs a schema lock. This was fixed in 2.0.

0 Kudos
MaxMax2
Occasional Contributor II

Hmm.. As I said in my previous post Add Field with shapefile as an input table produces lock files near shp. These lock files will be removed only when I close ArcGIS Pro. Is it OK? I suppose tools that change schema must delete locks were set by them. I see this behavior in 2.0.

0 Kudos
by Anonymous User
Not applicable

You'll see a bunch of *.lock files in a geodatabase during normal operation. These are either shared or exclusive locks depending on what you are doing. Schema locks are a type of exclusive lock which are set on a dataset when its modified (add field, field index etc). Exclusive locks are normally removed when the operation completes. Shared locks are removed when the dataset is no longer being referenced by anything. In a file geodatabase you can get more information about locks via ArcObjects. For enterprises geodatabases there is a dialog (administer geodatabase in ArcMap or database properties in Pro).

For this particular bug, add field wasn't removing the exclusive lock in a timely manner.

0 Kudos
MaxMax2
Occasional Contributor II

Yes, I know about exclusive/shared locks since I work with them using ArcObjects. In ArcGIS Pro 2.0 I see that Add Field doesn't delete locks were set by this tool for shapefiles. Do you confirm this issue?

0 Kudos
TimothyMichael
Occasional Contributor II

I am also getting the same behavior at 2.0, attempting to modify features in a file geodatabase.  Closing and reopening ArcGIS Pro 'fixes' the issue.

0 Kudos
by Anonymous User
Not applicable

Max and Tim, what are your workflows here to add the field and do an edit?

Are you adding a field manually or through code?

What sorts of edits are you making after that? Any .callback code?

Thanks

Sean

0 Kudos
MaxMax2
Occasional Contributor II

Hi Sean,

My workflow was:

  1. create feature class via executing appropriate geoprocessing tool;
  2. get path to created feature class as result of previous step;
  3. get Item by this path (through ItemFactory) and add feature layer by this item to a map;
  4. add fields to the created feature class via executing appropriate geoprocessing tool;
  5. execute EditOperation via callback which populates the feature class with some features.

In 1.4 this stuff works fine, in 2.0 not. Edit operation was failed with the "Edit operation failed. The data is currently locked by another user and cannot be saved" message. I even didn't fall to the callback's body.

But I fixed this with moving step 3 (adding of feature layer to a map) to the end of instructions list above. I decided to make a clean test creating test add-in and reproduce this workflow, and got no errors... So it is kind of mystic.

But as I said in my previous post "Add Field with shapefile as an input table produces lock files near shp". I mean executing the tool from ArcGIS Pro, not programmatically. Unfortunately I didn't see any reaction of the ESRI staff to this behavior. For me it seems like a bug.

0 Kudos
by Anonymous User
Not applicable

Hi Max,

I still cant reproduce this with shapefiles. I tried a few things, through the UI with GP tools and the editor to create a shapefile, add a field and make some edits. No locking persisted.

Programmatically, create a shape file, add a field and calc values with editor callback. The shapefile wasn't added to the map during this. No locking persisted.

Programmatically, created a shapefile, added a field, added the shapefile to a new map, calc values with edit operation (callback isn't recommended here as the layer is in the map). No locking persisted.

In all three cases there are three shared resource lock files (*.sr.lock) remaining, but this is normal. They are removed when Pro exits, assuming nothing else is referencing the shape file.

0 Kudos
RichardReinicke
Occasional Contributor II

Hi, I`m also encountering lock problems in the ArcGIS Pro SDK while creating and editing FGDB Feature Classes. Creation works without errors but the population with EditOperation only work once.

I`m calling 

await Project.Current.SaveEditsAsync();

after my whole process is done, which should finish all remaining edit locks, or not? My code is shown here:
Writing Features into FGDB very slow 

I`m repeating this multiple times in my running ArcGIS Pro session. User is selecting a MeasureSet, if its not availabale in FGDB it will be fetached from Postgres DB, written into FGDB and loaded into the map.

This works only once. The second time, fc is created in DB but I never enter my EditOperation callback, instead I get "ArcGIS.Core.Data.GeodatabaseTableException".

I have to reopen ArcGIS Pro to get it again work only once!!!

So this also doesn`t get fixed when migrating to 2.x?

0 Kudos