APS database (apsc) inconsistency after upgrade on Windows

Created:

2016-11-16 12:56:18 UTC

Modified:

2017-04-24 12:06:57 UTC

0

Was this article helpful?


Have more questions?

Submit a request

APS database (apsc) inconsistency after upgrade on Windows

Applicable to:

  • Plesk 10.4 for Windows
  • Plesk 11.0 for Windows
  • Plesk 11.5 for Windows
  • Plesk 12.0 for Windows
  • Plesk 12.5 for Windows

Symptoms

  1. After upgrading, the following messages are shown in Plesk:

    Error: New web server configuration for some domains within the marked subscriptions was not built due to errors in configuration templates

    List of applications is not loaded
  2. The following errors are shown in php_error.log or panel.log file:

    APS Catalog error: Unable to parse metadata

    ERR (3): The service instance was not found.

    ERR [panel] There are 1 dangling installations of WordPress: (df50cc2e-89f0-4ead-a540-e8b2c64dfb5f)
    ERR [panel] There are 1 dangling installations of typo3: (d37a2916-b965-4067-ab87-9dd14065a85e)
    ERR [panel] There are 1 dangling installations of osTicket: (a91a104f-f9ef-4b9e-80b3-f7bab40772fd)
    ERR [panel] There are 1 dangling installations of Drupal: (6e308f62-6370-45bd-897e-4ca7da41bee9)

Cause

apsc database inconsistency.

Resolution

Note: Some of the below commands are to be run when logged in to MySQL. Do not forget to replace <plesk_admin_password> with your actual password.

You have four options:

I. To remove the application from the database, you may want to perform the following:

MUST

cd %plesk_dir%\\MySQL\\bin

mysqldump -P8306 -uadmin -p<plesk_admin_password> psa > ~/psa.backup.sql

mysqldump -P8306 -uadmin -p<plesk_admin_password> apsc > ~/apsc.backup.sql

1 - Get the domains with the inconsistency

Applicable for Linux only:

mysql -P8306 -uadmin -p<plesk_admin_password> psa -Nse"select d.name as DOMAIN,c.status from Configurations c left join domains d on c.objectId=d.id where c.status='error'"

2 - Get the UID for the application with missing data.

The required data can be found in the log ( %plesk_dir%\\admin\\logs\\panel.log ) when going to the Applications tab of the domain in question:

======================
2011-10-07T11:21:01-06:00 ERR (3): Problem retrieving application's 0b2ff3e6-0585-4f17-ac10-ded4cb5c73b1 information: resource of type aps.database with id 518e38c8-6e05-4926-a271-b157be43d472 not found by brokers
======================

3 - Gather the required information.

%plesk_dir%\\MySQL\\bin\\mysql -P8306 -uadmin -p<plesk_admin_password> psa

mysql> select reg.id as REGISTRY_OBJECT_ID,reg.uid as APPLICATION_UID,reg.type as TYPE,ap.id as APPLICATION_ID from apsc.aps_registry_object reg left join apsc.aps_application ap on reg.id=ap.registry_object_id where reg.uid='89d578dc-9669-4629-a3fa-6f9ea9210e8d';


+--------------------+--------------------------------------+-----------------+----------------+
| REGISTRY_OBJECT_ID | APPLICATION_UID | TYPE | APPLICATION_ID |
+--------------------+--------------------------------------+-----------------+----------------+
| 666 | 89d578dc-9669-4629-a3fa-6f9ea9210e8d | aps.application | 12 |
+--------------------+--------------------------------------+-----------------+----------------+
1 row in set (0.00 sec)

4 - Remove the rest of the data.

mysql> delete from apsc.aps_application_resource where app_id=12;
mysql> delete from apsc.aps_application where id=12;
mysql> delete from apsc.aps_registry_object where id=666;

mysql> delete from psa.apsContextsApplications WHERE (apsContextId IN ('12'));


mysql> select s.object_id as pleskId,s.id as subscriptionId from psa.Subscriptions s left join psa.domains d on s.object_id=d.id where name = 'domain.tld';`

+---------+----------------+
| pleskId | subscriptionId |
+---------+----------------+
| 229 | 221 |
+---------+----------------+
1 row in set (0.00 sec)


mysql> delete from psa.apsContexts where (pleskType = "hosting" AND pleskId IN (229)) OR (pleskType = "subscription" AND subscriptionId IN ('221'));`

5 - Reconfigure the domain.

%plesk_bin%\\websrvmng --reconfigure-vhost --vhost-name=domain.tld

II. If you only have the resource ID:

MUST

%plesk_dir%\\MySQL\\bin\\mysqldump -P8306 -uadmin -p<plesk_admin_password> psa > ~/psa.backup.sql

%plesk_dir%\\MySQL\\bin\\mysqldump -P8306 -uadmin -p<plesk_admin_password> apsc > ~/apsc.backup.sql

1 - The required data can be found by going to the Applications tab of the domain in question: https://domain.tld:8443/smb/service/index/resourceId/e7928006-33c9-4575-8ab8-b9a485468313

2 - Get the resource ID.

mysql> SELECT apsc.id, apsc.uid, apsc.type, apsc.creation_time, apsc.enabled from aps_registry_object apsc WHERE (apsc.uid) = ('e7928006-33c9-4575-8ab8-b9a485468313');`


+----+--------------------------------------+--------------+---------------------+---------+
| id | uid | type | creation_time | enabled |
+----+--------------------------------------+--------------+---------------------+---------+
| 16 | e7928006-33c9-4575-8ab8-b9a485468313 | aps.resource | 2011-10-11 07:35:33 | y |
+----+--------------------------------------+--------------+---------------------+---------+
1 row in set (0.00 sec)

3 - Get the application UID.

mysql> SELECT 1.id, 1.resource_type, 1.parent_resource_id, 2.uid, 1.service_id from (((aps_application_resource 3 RIGHT JOIN aps_resource 1 ON (1.id) = (3.resource_id)) LEFT JOIN aps_application 4 ON (3.app_id) = (4.id)) LEFT JOIN aps_registry_object 2 ON (4.registry_object_id) = (2.id)) WHERE (1.registry_object_id) = (16);


+----+----------------------------------------------+--------------------+--------------------------------------+------------+
| id | resource_type | parent_resource_id | uid | service_id |
+----+----------------------------------------------+--------------------+--------------------------------------+------------+
| 6 | aps::aps12::http://wordpress.org/::wordpress | NULL | a0fe2a37-1b57-4588-9571-20e2d639ea82 | wordpress |
+----+----------------------------------------------+--------------------+--------------------------------------+------------+
1 row in set (0.00 sec)

4 - Gather the required information.

mysql> select reg.id as REGISTRY_OBJECT_ID,reg.uid as APPLICATION_UID,reg.type as TYPE,ap.id as APPLICATION_ID from apsc.aps_registry_object reg left join apsc.aps_application ap on reg.id=ap.registry_object_id where reg.uid='a0fe2a37-1b57-4588-9571-20e2d639ea82';


+--------------------+--------------------------------------+-----------------+----------------+
| REGISTRY_OBJECT_ID | APPLICATION_UID | TYPE | APPLICATION_ID |
+--------------------+--------------------------------------+-----------------+----------------+
| 15 | a0fe2a37-1b57-4588-9571-20e2d639ea82 | aps.application | 6 |
+--------------------+--------------------------------------+-----------------+----------------+
1 row in set (0.00 sec)

5 - Remove the rest of the data.

mysql> delete from apsc.aps_application_resource where app_id=6;`

mysql> delete from apsc.aps_application where id=6;`

mysql> delete from apsc.aps_registry_object where id=15;`

mysql> delete from psa.apsContextsApplications WHERE (apsContextId IN ('6'));`

mysql> select s.object_id as pleskId,s.id as subscriptionId from psa.Subscriptions s left join psa.domains d on s.object_id=d.id where name = 'domain.tld';`

+---------+----------------+
| pleskId | subscriptionId |
+---------+----------------+
| 1 | 1 |
+---------+----------------+
1 row in set (0.00 sec)


mysql> delete from psa.apsContexts where (pleskType = "hosting" AND pleskId IN (1)) OR (pleskType = "subscription" AND subscriptionId IN ('1'));`

6 - Reconfigure the domain.

%plesk_bin%\\websrvmng --reconfigure-vhost --vhost-name=domain.tld

III. If you want to remove ALL existing APS packages, the following script may be useful:

--- aps_remove.bat

echo "STARTED";
date /T;
mysqldump -P8306 -uadmin -p<plesk_admin_password> psa > ~/psa.backup.sql;
mysqldump -P8306 -uadmin -p<plesk_admin_password> apsc > ~/apsc.backup.sql;

mysqldump -P8306 -uadmin -p<plesk_admin_password> apsc --no-data > apsc.schema.sql;
mysql -P8306 -uadmin -p<plesk_admin_password> apsc < apsc.schema.sql;

mysqldump -P8306 -uadmin -p<plesk_admin_password> psa apsContexts apsContextsApplications apsResources apsResourcesParameters aps_application aps_package aps_registry_object aps_resource aps_resource_requirement smb_apsCategories smb_apsContexts smb_apsInstanceErrors smb_apsInstances smb_apsMetas smb_apsPackageUpdates smb_apsPackages smb_apsPackagesCategories --no-data > psa.tables.schema.sql;

mysql -P8306 -uadmin -p<plesk_admin_password> psa < psa.tables.schema.sql;

mysql -P8306 -uadmin -p<plesk_admin_password> psa -e"delete from smb_userServicePermissions where servicePermissionId in (select id from smb_servicePermissions where serviceProviderId in (select id from smb_serviceProviders where classname='Smb_Service_Provider_Aps'))";

mysql -P8306 -uadmin -p<plesk_admin_password> psa -e"delete from smb_serviceEntryPoints where servicePermissionId in (select id from smb_servicePermissions where serviceProviderId in (select id from smb_serviceProviders where classname='Smb_Service_Provider_Aps'))";

mysql -P8306 -uadmin -p<plesk_admin_password> psa -e"delete from smb_servicePermissions where serviceProviderId in (select id from smb_serviceProviders where classname='Smb_Service_Provider_Aps')";

mysql -P8306 -uadmin -p<plesk_admin_password> psa -e"delete from smb_serviceInstances where serviceProviderId in (select id from smb_serviceProviders where classname='Smb_Service_Provider_Aps')";

echo "DONE"

IV. If an application has been directly removed from the server without removing it from the databases:

MUST

mysqldump -P8306 -uadmin -p<plesk_admin_password> psa > ~/psa.backup.sql;

mysqldump -P8306 -uadmin -p<plesk_admin_password> apsc > ~/apsc.backup.sql;

1 - Get the application UID.

mysql> select s.object_id as pleskId,s.id as subscriptionId from psa.Subscriptions s left join psa.domains d on s.object_id=d.id where name = 'domain.tld';

+---------+----------------+
| pleskId | subscriptionId |
+---------+----------------+
| 180 | 141 |
+---------+----------------+
1 row in set (0.00 sec)


mysql> select * from psa.apsContexts where (pleskType = "hosting" AND pleskId IN (180)) OR (pleskType = "subscription" AND subscriptionId IN ('141'));`

+----+-----------+---------+-------+----------------+
| id | pleskType | pleskId | ssl | subscriptionId |
+----+-----------+---------+-------+----------------+
| 45 | hosting | 180 | false | 141 |
+----+-----------+---------+-------+----------------+
1 row in set (0.00 sec)


+----+--------------+--------------------------------------+
| id | apsContextId | registryApplicationId |
+----+--------------+--------------------------------------+
| 52 | 45 | b2e46a1d-342e-472a-88c0-21b0e494207d |
+----+--------------+--------------------------------------+
1 row in set (0.00 sec)


mysql> select reg.id as REGISTRY_OBJECT_ID,reg.uid as APPLICATION_UID,reg.type as TYPE,ap.id as APPLICATION_ID from apsc.aps_registry_object reg left join apsc.aps_application ap on reg.id=ap.registry_object_id where reg.uid='b2e46a1d-342e-472a-88c0-21b0e494207d';`

+--------------------+--------------------------------------+-----------------+----------------+
| REGISTRY_OBJECT_ID | APPLICATION_UID | TYPE | APPLICATION_ID |
+--------------------+--------------------------------------+-----------------+----------------+
| 156 | b2e46a1d-342e-472a-88c0-21b0e494207d | aps.application | 52 |
+--------------------+--------------------------------------+-----------------+----------------+
1 row in set (0.01 sec)

2 - Remove the rest of the data.

mysql> delete from apsc.aps_application_resource where app_id=52;
mysql> delete from apsc.aps_application where id=52;
mysql> delete from apsc.aps_registry_object where id=156;`


mysql> delete from psa.apsContextsApplications WHERE (apsContextId IN ('52'));`

mysql> select s.object_id as pleskId,s.id as subscriptionId from psa.Subscriptions s left join psa.domains d on s.object_id=d.id where name = 'domain.tld';`


+---------+----------------+
| pleskId | subscriptionId |
+---------+----------------+
| 180 | 141 |
+---------+----------------+
1 row in set (0.00 sec)


mysql> delete from psa.apsContexts where (pleskType = "hosting" AND pleskId IN (180)) OR (pleskType = "subscription" AND subscriptionId IN ('141'));

3 - Reconfigure the domain.

cd %plesk_bin%

websrvmng --reconfigure-vhost --vhost-name=domain.tld

Have more questions? Submit a request
Please sign in to leave a comment.