core icon indicating copy to clipboard operation
core copied to clipboard

FixTask00020DeleteOrphanedIdentifiers: update or delete on table "identifier" violates foreign key constraint "fk_htmlpage_ver_info_ident" on table "htmlpage_version_info"

Open gabbydotCMS opened this issue 10 years ago • 5 comments

Tested on a client database (postgreSQL) right after their upgrade from 3.2 to 3.6.

Full error can be found here: https://gist.github.com/gabbydotCMS/e8c2cb973c8fafe46a8d59170eb9a4be

I can provide the database dump to reproduce the issue.

Related to changes introduced by this request #9234 which didn't fail when running the fix assets inconsistency tool on 3.5.1.

gabbydotCMS avatar Sep 02 '16 19:09 gabbydotCMS

PR: https://github.com/dotCMS/core/pull/9966

agomez-dotcms avatar Oct 12 '16 22:10 agomez-dotcms

@shaydotcms these are the queries executed by the new fix task (FixTask00015FixAssetTypesInIdentifiers.java) in order to determine whether or not there are inconsistencies to be fixed:

SELECT COUNT() AS count FROM identifier i WHERE EXISTS(SELECT * FROM contentlet WHERE i.id = identifier) AND asset_type <> 'contentlet'; SELECT COUNT() AS count FROM identifier i WHERE EXISTS(SELECT * FROM dot_containers WHERE i.id = identifier) AND asset_type <> 'containers'; SELECT COUNT() AS count FROM identifier i WHERE EXISTS(SELECT * FROM file_asset WHERE i.id = identifier) AND asset_type <> 'file_asset'; SELECT COUNT() AS count FROM identifier i WHERE EXISTS(SELECT * FROM htmlpage WHERE i.id = identifier) AND asset_type <> 'htmlpage'; SELECT COUNT() AS count FROM identifier i WHERE EXISTS(SELECT * FROM links WHERE i.id = identifier) AND asset_type <> 'links'; SELECT COUNT() AS count FROM identifier i WHERE EXISTS(SELECT * FROM template WHERE i.id = identifier) AND asset_type <> 'template';

You should run these queries before and after executing the fix asset inconsistencies process in order to determine whether or not the task is doing what it's supposed to do.

Since the original DB comes from a dotCMS 3.2 instance, remember that the query to check containers is slightly different:

SELECT COUNT(*) AS count FROM identifier i WHERE EXISTS(SELECT * FROM containers WHERE i.id = identifier) AND asset_type <> 'containers';

Let me know if you need any help.

gabbydotCMS avatar Nov 03 '16 21:11 gabbydotCMS

Passed QA. Executed Fix Assets Inconsistencies tool and verified that tasks successfully fixed assets by running the queries provided by @gabbydotCMS Assets count after task returns 0 Tested in latest master-3.7 and 3.7 distribution using a Postgres DB coming from a dotCMS 3.2 instance

shaydotcms avatar Nov 16 '16 18:11 shaydotcms

port to new 3.7

jtesser avatar Jan 09 '17 15:01 jtesser

Merged into master-3.7: https://github.com/dotCMS/core/pull/10421

dsilvam avatar Jan 10 '17 22:01 dsilvam