Issue with da updateCursor on a versioned table with blob field.

2616
8
07-04-2016 06:39 PM
New Contributor III

Hi has anybody had a issue when processing a updateCursor over a versioned table that contains a blob field? If the table is not versioned the cursor completes ok but if it is versioned python totally crashes after processing a few records. I have also tested the size of the blob and it seems the if the size is smaller (~<500kb) the cursor completes without issue (versioned or unversioned).

I am writing a script to reduce the size of images in a attachment table as it causes issues with collector taking them offline and have come across this issue. I have a work around but was just wondering if anyone else has come across this issue with the (da) updateCursor?

Reply
0 Kudos
8 Replies
MVP Esteemed Contributor

What DBMS are you working with?  By a few, do you mean 3 or so?  How are you processing the blob before updating it?

Reply
0 Kudos
New Contributor III

Hi Joshua,

DBMS: SQL Server 2012

Yes only about 3 or 4 records process before it crashes. Even if I don't process the blob at all (i.e change nothing in the record) and perform the update it crashes?

cheers

Callum

Reply
0 Kudos
MVP Esteemed Contributor

Is this a geodatabase table or feature class with attachments enabled, or were the blobs/images inserted into a SQL Server table through another means?  I ask because so far I don't see this issue, so I am trying to understand what may be different with your environment.

The more information you can give the better.  For example, what desktop application are you using?  ArcMap?  Stand-alone Python script?  What versions of software?  What version of ArcGIS for Server?  Can you provide snippets of the functional code so we can see all of the arguments you are passing?

Reply
0 Kudos
New Contributor III

Yes it is a geodatabase feature class with attachments enabled. Basically I have a test script which cursors over the features in the feature class and then for each feature cursors over the related attachment records. Pretty standard stuff. It always crashes after 3-4 records. It is important to note that it only crashes when the feature class is registered as versioned and the images in the attachment table are large. I have also had a colleague of mine replicate the issue in a completely separate environment.

We are using desktop 10.4.1 and ArcGIS for Server 10.3.1

Test Script:

# Script to hightlioght insertCursor Issue on attachment table that is versioned in sde
#
# Callum Smith
# 30/6/2016


import arcpy
import os

# Change dataPath to the location of the data
##dataPath = r'D:\CBS\cursorIssue\geodatabase.gdb'
dataPath = r'D:\CBS\cursorIssue\DOWNERGIS@Dev@GISADMIN.sde'

# Run for either Large Images or SmallImages
fcName = 'FC_LargeImages'
#fcName = 'FC_SmallImages'


fc = os.path.join(dataPath, fcName)
attachTable = os.path.join(dataPath, fcName + '__ATTACH')

try:
    # Insert Cursor
    print 'Running the Cursor on the Featurclass...'

    fields = ['GLOBALID']
    with arcpy.da.SearchCursor(fc, fields) as searchCursor:
        for row in searchCursor:
            globalID = row[fields.index('GLOBALID')]
            print 'Processing Feature: ' + str(globalID)

            edit = arcpy.da.Editor(dataPath)
            edit.startEditing(False, True)
            edit.startOperation()

            # Insert Cursor on attach Table.
            count = 1
            whereClause = '"REL_GLOBALID" = ' + "'" + str(globalID) + "'"
            attachCusorFields = ['CONTENT_TYPE', 'DATA_SIZE', 'DATA', 'ATT_NAME']
            with arcpy.da.UpdateCursor(attachTable, attachCusorFields, whereClause) as attachCursor:
                 for attachRow in attachCursor:

                     attName = attachRow[attachCusorFields.index('ATT_NAME')]
                     print '   Attachment: {0} ---> {1}'.format(count, attName)

                     attachCursor.updateRow(attachRow)

                     count += 1

            # Stop Editing.
            edit.stopOperation()
            edit.stopEditing(True)

    print 'Process Complete.'

except Exception, err:
    print err

This is the error I get.

error.png

cheers

Callum

Reply
0 Kudos
New Contributor

What version of Python interpreter are you using?  I had this error when I was trying to manipulate some dataset, but the problem went away once I switched from 32 bit interpreter to 64 bit interpreter.

Reply
0 Kudos
New Contributor III

Hi Dianna

I have tried both the 32 and 64 bit versions and they both give the same error.

cheers

Callum

Reply
0 Kudos
Esri Regular Contributor

Hi Callum, please open a support call so you get this fixed.

There might be other workflows, like dumping and reloading downsized attachments.

Reply
0 Kudos
New Contributor III

Thanks Bruce yes I have opened a call and are working through it with ESRI. I do have a workaround in place like you suggest which dumps the attachments to the file system, processes them and then reattaches them. Works fine. Hopefully ESRI will identify the issue with the updateCursor which I think is a bug? Will post any updates on this issue I get from ESRI here.