check for deleted entity candidates before checking for stale candidates

Project: http://git-wip-us.apache.org/repos/asf/usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/usergrid/commit/a4f32fab
Tree: http://git-wip-us.apache.org/repos/asf/usergrid/tree/a4f32fab
Diff: http://git-wip-us.apache.org/repos/asf/usergrid/diff/a4f32fab

Branch: refs/heads/master
Commit: a4f32fab8b8b044d4a0d3f9436225a147d9ab6f8
Parents: ec7c6b4
Author: Mike Dunker <[email protected]>
Authored: Tue Mar 6 10:50:43 2018 -0800
Committer: Keyur Karnik <[email protected]>
Committed: Tue Aug 28 16:41:43 2018 -0700

----------------------------------------------------------------------
 .../read/search/CandidateEntityFilter.java      | 29 ++++++++++----------
 1 file changed, 14 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/usergrid/blob/a4f32fab/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
----------------------------------------------------------------------
diff --git 
a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
 
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
index 20bcfe9..5dcbd27 100644
--- 
a/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
+++ 
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/pipeline/read/search/CandidateEntityFilter.java
@@ -317,7 +317,20 @@ public class CandidateEntityFilter extends 
AbstractFilter<FilterResult<Candidate
             final UUID entityVersion = entity.getVersion();
             final Id entityId = entity.getId();
 
-            //entity is newer than ES version, could be a missed or slow index 
event
+            // The entity is marked as deleted
+            if (!entity.getEntity().isPresent() || entity.getStatus() == 
MvccEntity.Status.DELETED ) {
+
+                // when updating entities, we don't delete all previous 
versions from ES so this action is expected
+                if(logger.isDebugEnabled()){
+                    logger.debug( "Deindexing deleted entity on edge {} for 
entityId {} and version {}",
+                        searchEdge, entityId, entityVersion);
+                }
+
+                batch.deindex( searchEdge, entityId, candidateVersion );
+                return;
+            }
+
+            // entity exists and is newer than ES version, could be a missed 
or slow index event
             if ( UUIDComparator.staticCompare(entityVersion, candidateVersion) 
> 0 ) {
 
                Date candidateTimeStamp = UUIDTimeStampToDate(candidateVersion);
@@ -344,20 +357,6 @@ public class CandidateEntityFilter extends 
AbstractFilter<FilterResult<Candidate
                 }
             }
 
-
-            // The entity is marked as deleted
-            if (!entity.getEntity().isPresent() || entity.getStatus() == 
MvccEntity.Status.DELETED ) {
-
-                // when updating entities, we don't delete previous versions 
from ES so this action is expected
-                if(logger.isDebugEnabled()){
-                    logger.debug( "Deindexing deleted entity on edge {} for 
entityId {} and version {}",
-                        searchEdge, entityId, entityVersion);
-                }
-
-                batch.deindex( searchEdge, entityId, candidateVersion );
-                return;
-            }
-
             //ES is newer than cass, it means we haven't repaired the record 
in Cass, we don't want to
             //remove the ES record, since the read in cass should cause a read 
repair, just ignore
             if ( UUIDComparator.staticCompare( candidateVersion, entityVersion 
) > 0 ) {

Reply via email to