core icon indicating copy to clipboard operation
core copied to clipboard

Error with FixTask00020DeleteOrphanedIdentifiers after running Fix Assets Inconsistencies

Open shaydotcms opened this issue 10 years ago • 3 comments

Related to #9234

When orphaned identifiers exist and you execute Fix Assets Inconsistencies, the logs show the following single error and bad data is not fixed: ERROR fixtask.FixTasksExecutor: Class FixTask00020DeleteOrphanedIdentifiers has invalid name or shouldn't be in the tasks package.

Steps to reproduce: 1.Startup up a dotcms instance 2.Run the following queries that can be used to insert bad data that will allow every select and delete executed by the fixTask to be tested:

INSERT INTO identifier(host_inode, id, parent_path, asset_name, asset_type) VALUES ('SYSTEM_HOST', 'ft20-test-contentlet-001', '/', 'ft20-test-contentlet-001.contentlet', 'contentlet');
INSERT INTO identifier(host_inode, id, parent_path, asset_name, asset_type) VALUES ('SYSTEM_HOST', 'ft20-test-contentlet-002', '/', 'ft20-test-contentlet-002.contentlet', 'contentlet');
INSERT INTO identifier(host_inode, id, parent_path, asset_name, asset_type) VALUES ('SYSTEM_HOST', 'ft20-test-contentlet-003', '/', 'ft20-test-contentlet-003.contentlet', 'contentlet');
INSERT INTO identifier(host_inode, id, parent_path, asset_name, asset_type) VALUES ('SYSTEM_HOST', 'ft20-test-container-001', '/', 'ft20-test-container-001.container', 'containers');
INSERT INTO identifier(host_inode, id, parent_path, asset_name, asset_type) VALUES ('SYSTEM_HOST', 'ft20-test-container-002', '/', 'ft20-test-container-002.container', 'containers');
INSERT INTO identifier(host_inode, id, parent_path, asset_name, asset_type) VALUES ('SYSTEM_HOST', 'ft20-test-container-003', '/', 'ft20-test-container-003.container', 'containers');
INSERT INTO identifier(host_inode, id, parent_path, asset_name, asset_type) VALUES ('SYSTEM_HOST', 'ft20-test-links-001', '/', 'ft20-test-links-001', 'links');
INSERT INTO identifier(host_inode, id, parent_path, asset_name, asset_type) VALUES ('SYSTEM_HOST', 'ft20-test-links-002', '/', 'ft20-test-links-002', 'links');
INSERT INTO identifier(host_inode, id, parent_path, asset_name, asset_type) VALUES ('SYSTEM_HOST', 'ft20-test-links-003', '/', 'ft20-test-links-003', 'links');
INSERT INTO identifier(host_inode, id, parent_path, asset_name, asset_type) VALUES ('SYSTEM_HOST', 'ft20-test-template-001', '/', 'ft20-test-template-001', 'template');
INSERT INTO identifier(host_inode, id, parent_path, asset_name, asset_type) VALUES ('SYSTEM_HOST', 'ft20-test-template-002', '/', 'ft20-test-template-002', 'template');
INSERT INTO identifier(host_inode, id, parent_path, asset_name, asset_type) VALUES ('SYSTEM_HOST', 'ft20-test-template-003', '/', 'ft20-test-template-003', 'template');
INSERT INTO identifier(host_inode, id, parent_path, asset_name, asset_type) VALUES ('SYSTEM_HOST', 'ft20-test-file_asset-001', '/', 'ft20-test-file_asset-001', 'file_asset');
INSERT INTO identifier(host_inode, id, parent_path, asset_name, asset_type) VALUES ('SYSTEM_HOST', 'ft20-test-file_asset-002', '/', 'ft20-test-file_asset-002', 'file_asset');
INSERT INTO identifier(host_inode, id, parent_path, asset_name, asset_type) VALUES ('SYSTEM_HOST', 'ft20-test-file_asset-003', '/', 'ft20-test-file_asset-003', 'file_asset');
INSERT INTO identifier(host_inode, id, parent_path, asset_name, asset_type) VALUES ('SYSTEM_HOST', 'ft20-test-htmlpage-001', '/', 'ft20-test-htmlpage-001.html', 'htmlpage');
INSERT INTO identifier(host_inode, id, parent_path, asset_name, asset_type) VALUES ('SYSTEM_HOST', 'ft20-test-htmlpage-002', '/', 'ft20-test-htmlpage-002.html', 'htmlpage');
INSERT INTO identifier(host_inode, id, parent_path, asset_name, asset_type) VALUES ('SYSTEM_HOST', 'ft20-test-htmlpage-003', '/', 'ft20-test-htmlpage-003.html', 'htmlpage');
INSERT INTO tree(child, parent, relation_type) VALUES ('ft20-test-contentlet-001', 'ft20-test-contentlet-002', 'ft-test-relation-contentlet');
INSERT INTO tree(child, parent, relation_type) VALUES ('ft20-test-contentlet-002', 'ft20-test-contentlet-003', 'ft-test-relation-contentlet');
INSERT INTO tree(child, parent, relation_type) VALUES ('ft20-test-container-001', 'ft20-test-container-002', 'ft-test-relation-container');
INSERT INTO tree(child, parent, relation_type) VALUES ('ft20-test-container-002', 'ft20-test-container-003', 'ft-test-relation-container');
INSERT INTO tree(child, parent, relation_type) VALUES ('ft20-test-links-001', 'ft20-test-links-002', 'ft-test-relation-links');
INSERT INTO tree(child, parent, relation_type) VALUES ('ft20-test-links-002', 'ft20-test-links-003', 'ft-test-relation-links');
INSERT INTO tree(child, parent, relation_type) VALUES ('ft20-test-template-001', 'ft20-test-template-002', 'ft-test-relation-template');
INSERT INTO tree(child, parent, relation_type) VALUES ('ft20-test-template-002', 'ft20-test-template-003', 'ft-test-relation-template');
INSERT INTO tree(child, parent, relation_type) VALUES ('ft20-test-file_asset-001', 'ft20-test-file_asset-002', 'ft-test-relation-file_asset');
INSERT INTO tree(child, parent, relation_type) VALUES ('ft20-test-file_asset-002', 'ft20-test-file_asset-003', 'ft-test-relation-file_asset');
INSERT INTO tree(child, parent, relation_type) VALUES ('ft20-test-htmlpage-001', 'ft20-test-htmlpage-002', 'ft-test-relation-htmlpage');
INSERT INTO tree(child, parent, relation_type) VALUES ('ft20-test-htmlpage-002', 'ft20-test-htmlpage-003', 'ft-test-relation-htmlpage');

Query returned successfully: one row affected, 24 ms execution time.

3.Run below query to verify that bad data was added into DB:

select * from identifier
where id = 'ft20-test-contentlet-001'
OR id = 'ft20-test-container-001'
OR id = 'ft20-test-links-001'
OR id = 'ft20-test-template-002'
OR id = 'ft20-test-file_asset-001'
OR id= 'ft20-test-htmlpage-001'

Total query runtime: 3 ms.
6 rows retrieved.

4.Login to dotcms Navigate to System> Maintenance> Tools Inside Fix Assets Inconsistencias click Execute button

5.You will get this single error in the logs: ERROR fixtask.FixTasksExecutor: Class FixTask00020DeleteOrphanedIdentifiers has invalid name or shouldn't be in the tasks package.

6.If you run the below query again, you will see that bad data is still showing, therefore the inconsistencies were not fixed:

select * from identifier
where id = 'ft20-test-contentlet-001'
OR id = 'ft20-test-container-001'
OR id = 'ft20-test-links-001'
OR id = 'ft20-test-template-002'
OR id = 'ft20-test-file_asset-001'
OR id= 'ft20-test-htmlpage-001'

Total query runtime: 3 ms.
6 rows retrieved.

This issue is NOT happening in Postgres, however it does happen in MySql, SQLServer and Oracle 12c Tested in Master-3.6

shaydotcms avatar Aug 03 '16 19:08 shaydotcms

Issue still persists. New errors in the logs are getting reported https://gist.github.com/shaydotcms/9d68675005fb9e01e755168dce6cf045

shaydotcms avatar Aug 04 '16 14:08 shaydotcms

Fix is working. Orphaned identifiers are deleted after running Fix Assets Inconsistencies in backend. Errors are not showing in the logs Tested locally in: master-3.6 // Win7 Pro SP1 // SQLServer 2012 // Chrome master-3.6 // Mac OS 10.10 // MySQL 5.6.23 // Firefox master-3.6 // Ubuntu 14.04.1 // Postgres 9.3 // Chrome master-3.6 // Mac OS 10.10 // Oracle 12c // Firefox

shaydotcms avatar Aug 05 '16 17:08 shaydotcms

#9234 was incomplete so we needed to handle the sql properly to be able to work in other DBs as well as put the proper total and fixed errors in the return object.

dsilvam avatar Aug 05 '16 17:08 dsilvam