Select to view content in your preferred language

Branch versioning - Deleting a version cause the published service to be corrupted

181
1
03-14-2025 05:33 AM
PierreMasson
Frequent Contributor

We've developped a Windows app that uses ArcGIS Maps SDK .Net. That app displays and edits data from a published service on our portal that is in branch versioning. 

When connecting to the service, the app creates a new version and uses it.

Then I do a few edits and apply them. I go back in ArcGIS Pro and I delete the version I just created so I can redo my tests in our app (meening a new version with the same name is recreated). But then the service acts really strange, some graphics are not showing when I zoom in and zoom out, some simple calls like GetRecordCount fails with bad json but when I retry them it passes and when I try to redo my edits and apply them it says that it cannot open an edit session or something like that.

The only way I found to not have this problem is when I delete the version, I republish my map overriting the existing service. Then it's all good. But I think I should'nt have to do that?

Can you help me understanding what's hapening please?

Thank you

0 Kudos
1 Reply
JenniferNery
Esri Regular Contributor

Hi Pierre,

I have not seen sluggish query when zooming in/out but I've seen the expected lock errors when editing the same version simultaneously from different apps.

How are you creating the ServiceGeodatabase? If you're opening from a web map, there is a load setting that you can set to persistent if you wish to lock the version for editing. It is transient by default. If you've created from URL, be sure all layers and tables of the map come from the same service geodatabase. Use the service geodatabase to apply the edits (instead of table apply edits). More information about session management here.

When starting from web map

 

var map = new Map(new Uri(WebmapItemUrl));
map.LoadSettings = new LoadSettings() { FeatureServiceSessionType = FeatureServiceSessionType.Persistent };

 

When starting from feature service URL

 

var sgdb = await ServiceGeodatabase.CreateAsync(featureServiceUrl, FeatureServiceSessionType.Persistent); // specify session mode

 

Be sure to call close at the end when done with working on the branch version to release the read/write locks. 

 

var parameters = new ServiceVersionParameters()
{
Name = $"VALID_VERSION_{digits}",
Description = versionDescription,
Access = VersionAccess.Private
};
var serviceVersionInfo = await sgdb.CreateVersionAsync(parameters); // create version

await sgdb.SwitchVersionAsync(serviceVersionInfo.Name); // switch

var layer = sgdb.GetTable(serviceLayerId); // all layers/tables

await sgdb.CloseAsync(); // when done

 

 

Opening the same version in ArcGIS Pro or Map Viewer will attempt to acquire read and write locks as well. On the server, there's purge lock and delete version that will allow you to cleanup versions that should be released and deleted.