Replica not removed if Offline Area removed while Offline

514
6
08-20-2021 07:44 AM
DougBrowning
MVP Notable Contributor

I noticed we have a lot more Replicas now with Field Maps.  Initial testing shows that if I am online and remove a offline area the replica is removed.  But if I remove the offline area while the tablet is offline it does not remove the replica.  Even when I get back online and refresh the app, map, etc.  Testing with iPad Pro using AGOL hosted service.

Is there a trick to this?  Is this a known issue?

We have to move some content to a new owner and the admin is saying all replicas must be removed first.  I have 800 in just one service.  I think so many due to the above. Is this true?  Is there a API way to remove them all?

thanks

6 Replies
AaronPulver
Esri Regular Contributor

I'm not sure if this is expected behavior or not.

There is a REST API and Python wrapper to remove them:

- https://developers.arcgis.com/rest/services-reference/enterprise/unregister-replica-feature-service-...

- https://developers.arcgis.com/python/api-reference/arcgis.features.managers.html?highlight=replica#a...

 

It looks like if you use "*" for the replicaID it will remove all the replicas.

DougBrowning
MVP Notable Contributor

Well that start would sure help!  Thanks.  Not sure why this would be expected behavior to have orphan replicas.

0 Kudos
ColinLawrence
Esri Regular Contributor

Doug, 

What platform are you using Field Maps on? Also, check the troubleshooting logs within the app. We have logs for when an unregister attempt happens and whether or not its successful. 

 

Regards,

Colin

0 Kudos
DougBrowning
MVP Notable Contributor

iPad Pro 2020 using a AGOL hosted service - latest Field Maps and at 14.6 iOS.

The log is saying [UNREGISTER] failed to load task for (then url of service).  

Seems like it is not checking if you are offline at the time?

thanks

0 Kudos
ColinLawrence
Esri Regular Contributor

Thank you! We have been investigating this but the behavior is far from consistent in our efforts to reproduce it. Your feedback is helpful.

 

Regards,

Colin

DougBrowning
MVP Notable Contributor

Any update yet?  Over the last year now it has been causing us issues.  We have 450+ replicas in just one service.  I created a script for a report and we have many replicas that are months old.  Other teams here have been seeing this also.

It got the point one of our services starting having issues.  We could not export at all for one.  Also random offline errors.  I created another script to unregister anything not touched before June 1.  As soon as I did our export starting working again.

The group with the most issues use iOS but other groups have a mix.  

For anyone that needs it here - it is the very simple and not buffed out code.

Get a list

 

import arcpy
from arcgis.gis import GIS
import arcgis
from arcgis.features import FeatureLayerCollection

gis = GIS('pro')

itemID = "417ebcae"

item = gis.content.get(itemID)
flc = FeatureLayerCollection.fromitem(item)
replicas = flc.replicas.get_list()
print ("ReplicaOwner,ReplicaName,ReplicaID,CreateDate,LastSyncDate")
for r in replicas:
    replica = flc.replicas.get(r['replicaID'])
    create_date = datetime.datetime.fromtimestamp(replica['creationDate'] / 1000)
    last_sync_date = 'n/a' # don't trust this to always be populated
    if type(replica['lastSyncDate']) is int:
        last_sync_date = datetime.datetime.fromtimestamp(replica['lastSyncDate'] / 1000)

    print(replica['replicaOwner'] + "," + replica['replicaName'] + "," + replica['replicaID'] + "," + str(create_date) + "," + str(last_sync_date))

 

 Remove - cool trick to use the token from Pro is way easier.  Input is just a text list of replicaIDs.

 

import requests, arcpy
# read in the list of replcias to remove from file
replicaFile = r"C:\ReplicaList.txt"
replicaRead = open(replicaFile,"r")
replicaList = replicaRead.read().splitlines()
replicaRead.close()

# base URL to the HFS
serviceURL = 'https://services1.arcgis.com/Hp6G80QvQ/arcgis/rest/services/My_Service/FeatureServer/unRegisterReplica?replicaID='

token = arcpy.GetSigninToken()
for replica in replicaList:
    urlResponse = requests.post(serviceURL + "{" + replica + "}&token=" + token['token'])

 

Thank you.

Looks like other seeing this also.  https://community.esri.com/t5/arcgis-field-maps-questions/how-to-delete-offline-sync-version-created... 

0 Kudos