Symptoms

Office 365 sync script fails:

Subscription 50010359: error by data comparison: Error during OpenAPI call: Instance of application service with id 768 does not exist.
Subscription 50010361: error by data comparison: Error during OpenAPI call: Instance of application service with id 771 does not exist.

Instances do exist while checking KB 120815

Cause

This is caused by APS-16351. A service was detached, parent service instance was removed but its children were not.

Resolution

  1. Update to POA 5.5.6 where APS-16351 was fixed to prevent this problem for happening,

  2. Verify the service instances are unprovided and refer to nonexistent instances by parent_id:

    psql> select parent_service_instance_id,unprovided from aps_service_instances where service_instance_id = 768;
     parent_service_instance_id | unprovided | app_instance_id  
    ----------------------------+------------+-----------------
                            770 | y          |             250
    
    psql> select service_instance_id from aps_service_instances where service_instance_id = (select parent_service_instance_id from aps_service_instances where service_instance_id = 768);
     service_instance_id
    ----------------------------
    (0 rows)
    
  3. Remove the orphaned records,

    plesk=> begin; delete from aps_service_instances where app_instance_id = 250 and service_id = 771; commit;
    

Internal content

Link on internal Article