Sunday, 23 June 2019

enterprise geodatabase - Why does multi_user_mode have to be False in edit session on non-versioned dataset using ArcPy?



I'm in the process of implementing Mintx's answer to my question
What would cause a geoprocessing service to say "Cannot Open 'FeatureClass' Failed to Execute"?


However, I had another question come up. I figure the right way to insert records into a dataset is to use an edit session so that doesn't hold an exclusive lock for the duration of the time that an insert cursor is opened. But it only needs the exclusive lock for the duration that edits are saved.


So, I'm looking at the Editor class in ArcPy http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-data-access/editor.htm


In one of the code samples here, it says that startEditing()'s 2nd parameter, which is multi_user_mode, should be set to False for unversioned data... but it doesn't explain why:


# Start an edit session. Must provide the workspace.

edit = arcpy.da.Editor(workspace)

# Edit session is started without an undo/redo stack for versioned data
# (for second argument, use False for unversioned data)
edit.startEditing(False, True)

# Start an edit operation
edit.startOperation()

# Insert a row into the table.

with arcpy.da.InsertCursor(fc, ('SHAPE@', 'Name')) as icur:
icur.insertRow([(7642471.100, 686465.725), 'New School'])

# Stop the edit operation.
edit.stopOperation()

# Stop the edit session and save the changes
edit.stopEditing(True)

Here's the documentation on multi_user_mode:




When False, you have full control of editing a nonversioned, or versioned dataset. If your dataset is nonversioned and you use stopEditing(False), your edit will not be committed (otherwise, if set to True, your edits will be committed). (The default value is True)



I'm a little bit confused because it mentions the behavior of multi_user_mode being set to False -- that you have 'full control' of editing a data set. (My best guess here is that 'full control' refers to having an exclusive lock on the dataset... Is this true?)


I'm just trying to understand what's going on with the database underneath in terms of transactions, commits, rollbacks, and locks.


With that, let me lay out some explicit questions:



  1. What does edit.startEditing(False, False) do on a versioned dataset, and how does it differ from using edit.startEditing(False, True)?

  2. What happens in the DBMS for non-versioned data that requires the use of edit.startEditing(False, False)?





No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...