Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)

57233: Merged V4.2-BUG-FIX (4.2.1) to HEAD-BUG-FIX (Cloud/4.3)
      57116: Merged V4.1-BUG-FIX (4.1.7) to V4.2-BUG-FIX (4.2.1)
         56986: MNT-9829: Merged V4.1.5 (4.1.5.10) to V4.1-BUG-FIX (4.1.7)
            56818: Fix for     MNT-9706  Big amount of alf_acl_change_set entries slowing down massively index times and prevent access to report / summary pages of SOLR
            56848: Fix for     MNT-9706  Big amount of alf_acl_change_set entries slowing down massively index times and prevent access to report / summary pages of SOLR
            - moved to join, count and group by    as having is causing issues.
            56868: Fix for     MNT-9706  Big amount of alf_acl_change_set entries slowing down massively index times and prevent access to report / summary pages of SOLR
            - also protect direct acl fetch with node exists test
            - fix test to use a sensible loop .....


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@61788 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Alan Davis
2014-02-11 20:21:04 +00:00
parent 6a4a1d50a1
commit 53fdfb2593
2 changed files with 16 additions and 35 deletions

View File

@@ -36,15 +36,10 @@
select select
acs.id as id, acs.id as id,
acs.commit_time_ms as commit_time_ms, acs.commit_time_ms as commit_time_ms,
(select count(acl_id) as acl_count
count(acl.id)
from
alf_access_control_list acl
where
acl.acl_change_set = acs.id
) as acl_count
from from
alf_acl_change_set acs alf_acl_change_set acs
join alf_access_control_list acl on (acl.acl_change_set = acs.id and exists (select 1 from alf_node admnode where admnode.acl_id = acl.id))
<where> <where>
<if test="fromCommitTimeInclusive != null"> <if test="fromCommitTimeInclusive != null">
<![CDATA[acs.commit_time_ms >= #{fromCommitTimeInclusive}]]> <![CDATA[acs.commit_time_ms >= #{fromCommitTimeInclusive}]]>
@@ -59,6 +54,7 @@
and <![CDATA[acs.id < #{toIdExclusive}]]> and <![CDATA[acs.id < #{toIdExclusive}]]>
</if> </if>
</where> </where>
group by acs.commit_time_ms, acs.id
order by acs.commit_time_ms ASC, acs.id ASC order by acs.commit_time_ms ASC, acs.id ASC
</select> </select>
@@ -69,8 +65,9 @@
from from
alf_access_control_list acl alf_access_control_list acl
<where> <where>
exists (select 1 from alf_node admnode where admnode.acl_id = acl.id)
<if test="fromIdInclusive != null"> <if test="fromIdInclusive != null">
<![CDATA[acl.id >= #{fromIdInclusive}]]> and <![CDATA[acl.id >= #{fromIdInclusive}]]>
</if> </if>
<if test="ids != null"> <if test="ids != null">
and acl.acl_change_set in and acl.acl_change_set in
@@ -84,27 +81,14 @@
</select> </select>
<select id="select_Txns" parameterType="SOLRTrackingParameters" resultMap="result_Transaction"> <select id="select_Txns" parameterType="SOLRTrackingParameters" resultMap="result_Transaction">
select select
txn.id as id, txn.id as id,
txn.commit_time_ms as commit_time_ms, txn.commit_time_ms as commit_time_ms,
(select count(case when node.type_qname_id != #{deletedTypeQNameId} then 1 end) as updates,
count(node.id) count(case when node.type_qname_id = #{deletedTypeQNameId} then 1 end) as deletes
from
alf_node node
where
txn.id = node.transaction_id and
node.type_qname_id != #{deletedTypeQNameId}
) as updates,
(select
count(node.id)
from
alf_node node
where
txn.id = node.transaction_id and
node.type_qname_id = #{deletedTypeQNameId}
) as deletes
from from
alf_transaction txn alf_transaction txn
join alf_node node on (txn.id = node.transaction_id)
<where> <where>
<if test="fromCommitTimeInclusive != null"> <if test="fromCommitTimeInclusive != null">
<![CDATA[txn.commit_time_ms >= #{fromCommitTimeInclusive}]]> <![CDATA[txn.commit_time_ms >= #{fromCommitTimeInclusive}]]>
@@ -119,6 +103,7 @@
and <![CDATA[txn.id < #{toIdExclusive}]]> and <![CDATA[txn.id < #{toIdExclusive}]]>
</if> </if>
</where> </where>
group by txn.commit_time_ms, txn.id
order by txn.commit_time_ms ASC, txn.id ASC order by txn.commit_time_ms ASC, txn.id ASC
</select> </select>

View File

@@ -21,6 +21,7 @@ package org.alfresco.repo.solr;
import java.io.InputStream; import java.io.InputStream;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@@ -138,25 +139,20 @@ public class SOLRTrackingComponentTest extends TestCase
{ {
List<AclChangeSet> cs = solrTrackingComponent.getAclChangeSets(null, null, null, null, 50); List<AclChangeSet> cs = solrTrackingComponent.getAclChangeSets(null, null, null, null, 50);
assertTrue("Expected results to be limited in number", cs.size() <= 50); assertTrue("Expected results to be limited in number", cs.size() <= 50);
List<Long> aclChangeSetIds = new ArrayList<Long>(50);
int totalAcls = 0; int totalAcls = 0;
for (AclChangeSet aclChangeSet : cs) for (AclChangeSet aclChangeSet : cs)
{ {
aclChangeSetIds.add(aclChangeSet.getId());
totalAcls += aclChangeSet.getAclCount(); totalAcls += aclChangeSet.getAclCount();
} }
int totalAclsCheck = 0; int totalAclsCheck = 0;
Long fromAclId = null;
while (true) for (AclChangeSet aclChangeSet : cs)
{ {
List<Acl> acls = solrTrackingComponent.getAcls(aclChangeSetIds, fromAclId, 2); List<Acl> acls = solrTrackingComponent.getAcls(Arrays.asList(new Long[]{aclChangeSet.getId()}), null, 200);
if (acls.size() == 0) assertEquals(aclChangeSet.getAclCount(), acls.size());
{
break;
}
totalAclsCheck += acls.size(); totalAclsCheck += acls.size();
fromAclId = acls.get(acls.size() - 1).getId() + 1;
} }
// Double check number of ACLs // Double check number of ACLs
assertEquals("ACL count should have matched", totalAcls, totalAclsCheck); assertEquals("ACL count should have matched", totalAcls, totalAclsCheck);
} }