mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-15 15:02:20 +00:00
PostgreSQL and MySQL fixes for ACE-5143: CLONE - CleanAlfPropTables deleting more than it should
- New test PropertyValueCleanupTest - Generates some data for the script to clean up - Concurrently generates attribute values while cleanup script is running - Checks that the script cleaned up the orphaned data - Checks all newly-generated attributes to ensure that they survived the script in tact - The second SQL statement modification can be reverted to produce the failure mode observed in ACE-5143 git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.1.N/root@122471 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
-- the rest of the values used in audit can be deleted from alf_prop_string_value, alf_prop_serializable_value, alf_prop_double_value.
|
||||
|
||||
-- create temp tables
|
||||
--BEGIN TXN
|
||||
create table temp_prop_root_ref
|
||||
(
|
||||
id INT8 NOT NULL
|
||||
@@ -69,6 +68,18 @@ create table temp_del_double2
|
||||
PRIMARY KEY (id)
|
||||
);
|
||||
|
||||
-- Determine the maximum IDs in order to constrain deletion ranges and avoid deleting new data
|
||||
--ASSIGN:PROP_ROOT_MAX_ID=idmax!-1
|
||||
select max(id) as idmax from alf_prop_root;
|
||||
--ASSIGN:PROP_VAL_MAX_ID=idmax!-1
|
||||
select max(id) as idmax from alf_prop_value;
|
||||
--ASSIGN:PROP_STRING_MAX_ID=idmax!-1
|
||||
select max(id) as idmax from alf_prop_string_value;
|
||||
--ASSIGN:PROP_SERIALIZABLE_MAX_ID=idmax!-1
|
||||
select max(id) as idmax from alf_prop_serializable_value;
|
||||
--ASSIGN:PROP_DOUBLE_MAX_ID=idmax!-1
|
||||
select max(id) as idmax from alf_prop_double_value;
|
||||
|
||||
-- get all active references to alf_prop_root
|
||||
--FOREACH alf_audit_app.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||
insert into temp_prop_root_ref select disabled_paths_id as id from alf_audit_app where id >= ${LOWERBOUND} and id <= ${UPPERBOUND};
|
||||
@@ -79,7 +90,7 @@ insert into temp_prop_root_ref select prop1_id from alf_prop_unique_ctx where pr
|
||||
|
||||
-- determine the obsolete entries from alf_prop_root
|
||||
--FOREACH alf_prop_root.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||
insert into temp_prop_root_obs select alf_prop_root.id from alf_prop_root left join temp_prop_root_ref on temp_prop_root_ref.id = alf_prop_root.id where temp_prop_root_ref.id is null and alf_prop_root.id >= ${LOWERBOUND} and alf_prop_root.id <= ${UPPERBOUND};
|
||||
insert into temp_prop_root_obs select alf_prop_root.id from alf_prop_root left join temp_prop_root_ref on temp_prop_root_ref.id = alf_prop_root.id where temp_prop_root_ref.id is null and alf_prop_root.id >= ${LOWERBOUND} and alf_prop_root.id <= ${UPPERBOUND} and alf_prop_root.id <= ${PROP_ROOT_MAX_ID};
|
||||
|
||||
-- clear alf_prop_root which cascades DELETE to alf_prop_link
|
||||
--FOREACH temp_prop_root_obs.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||
@@ -103,7 +114,7 @@ insert into temp_prop_val_ref select value3_prop_id from alf_prop_unique_ctx whe
|
||||
|
||||
-- determine the obsolete entries from alf_prop_value
|
||||
--FOREACH alf_prop_value.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||
insert into temp_prop_val_obs select apv.id, apv.persisted_type, apv.long_value from alf_prop_value apv left join temp_prop_val_ref on (apv.id = temp_prop_val_ref.id) where temp_prop_val_ref.id is null and apv.id >= ${LOWERBOUND} and apv.id <= ${UPPERBOUND};
|
||||
insert into temp_prop_val_obs select apv.id, apv.persisted_type, apv.long_value from alf_prop_value apv left join temp_prop_val_ref on (apv.id = temp_prop_val_ref.id) where temp_prop_val_ref.id is null and apv.id >= ${LOWERBOUND} and apv.id <= ${UPPERBOUND} and apv.id <= ${PROP_VAL_MAX_ID};
|
||||
|
||||
-- clear the obsolete entries
|
||||
--FOREACH temp_prop_val_obs.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||
@@ -148,5 +159,3 @@ delete from alf_prop_double_value apd using temp_del_double1 tdd where apd.id =
|
||||
-- insert into temp_del_double2 select apd.id from alf_prop_double_value apd left join alf_prop_value apv on apv.long_value = apd.id and apv.persisted_type = 2 where apv.id is null and apd.id >= ${LOWERBOUND} and apd.id <= ${UPPERBOUND};
|
||||
-- FOREACH temp_del_double2.id system.upgrade.clean_alf_prop_tables.batchsize
|
||||
-- delete from alf_prop_double_value apd using temp_del_double2 tdd where apd.id = tdd.id and tdd.id >= ${LOWERBOUND} and tdd.id <= ${UPPERBOUND};
|
||||
|
||||
--END TXN
|
||||
|
Reference in New Issue
Block a user