sling-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thomas Mueller (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (SLING-8407) JobManagerImpl.findJobs should prevent traversal
Date Thu, 09 May 2019 07:28:00 GMT

    [ https://issues.apache.org/jira/browse/SLING-8407?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16836157#comment-16836157
] 

Thomas Mueller commented on SLING-8407:
---------------------------------------

Here a first patch that passes the tests. I will try to throw a special kind of RuntimeException
instead of returning an empty list / null:

{noformat}
--- a/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java
+++ b/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java
@@ -520,6 +520,7 @@ public class JobManagerImpl
                 buf.append(Job.PROPERTY_JOB_CREATED);
                 buf.append(" ascending");
             }
+            buf.append(" option(traversal fail)");
             final Iterator<Resource> iter = resolver.findResources(buf.toString(),
"xpath");
             long count = 0;
 
@@ -535,7 +536,10 @@ public class JobManagerImpl
                 }
              }
         } catch (final QuerySyntaxException qse) {
-            logger.warn("Query syntax wrong " + buf.toString(), qse);
+            // no index is available
+            String message = "Query " + buf.toString() + " failed: " + qse.getMessage();
+            logger.debug(message, qse);
+            logger.info(message, qse);
         } finally {
             resolver.close();
         }
diff --git a/src/test/java/org/apache/sling/event/it/AbstractJobHandlingTest.java b/src/test/java/org/apache/sling/event/it/AbstractJobHandlingTest.java
index c51ecd9..42af6e8 100644
--- a/src/test/java/org/apache/sling/event/it/AbstractJobHandlingTest.java
+++ b/src/test/java/org/apache/sling/event/it/AbstractJobHandlingTest.java
@@ -98,8 +98,8 @@ public abstract class AbstractJobHandlingTest {
 
         String localRepo = System.getProperty("maven.repo.local", "");
 
-        final String jackrabbitVersion = "2.13.1";
-        final String oakVersion = "1.5.7";
+        final String jackrabbitVersion = "2.14.6";
+        final String oakVersion = "1.6.0";
 
         final String slingHome = new File(buildDir + File.separatorChar + "sling_" + System.currentTimeMillis()).getAbsolutePath();
 
@@ -230,6 +230,7 @@ public abstract class AbstractJobHandlingTest {
 
                 mavenBundle("com.google.guava", "guava", "15.0"),
                 mavenBundle("org.apache.jackrabbit", "jackrabbit-api", jackrabbitVersion),
+                mavenBundle("org.apache.jackrabbit", "jackrabbit-data", jackrabbitVersion),
                 mavenBundle("org.apache.jackrabbit", "jackrabbit-jcr-commons", jackrabbitVersion),
                 mavenBundle("org.apache.jackrabbit", "jackrabbit-spi", jackrabbitVersion),
                 mavenBundle("org.apache.jackrabbit", "jackrabbit-spi-commons", jackrabbitVersion),
{noformat}

> JobManagerImpl.findJobs should prevent traversal
> ------------------------------------------------
>
>                 Key: SLING-8407
>                 URL: https://issues.apache.org/jira/browse/SLING-8407
>             Project: Sling
>          Issue Type: Improvement
>          Components: Event
>            Reporter: Thomas Mueller
>            Priority: Major
>
> The method [JobManagerImpl.findJobs|https://github.com/apache/sling-org-apache-sling-event/blob/master/src/main/java/org/apache/sling/event/impl/jobs/JobManagerImpl.java#L373]
runs a JCR query to find all jobs for a topic.
> It is possible that such a query is running while the repository isn't initialized yet,
meaning while the index isn't available yet. What is happening in this case is that the query
is traversing all nodes below that path, triggering a warning that the query doesn't use an
index. It is sometimes happening when a health check is running before the repository is initialized
(ReplicationQueueHealthCheck and DistributionQueueHealthCheck).
> It doesn't make sense that the query traverses the nodes. It should use an index. If
the index isn't available yet, it should fail. Therefore, the query should use "option(traversal
fail)". That would result in an exception that can be caught.  I will log a related issue
to change the health checks to process this exception and return HEALTH_CHECK_ERROR for this
case.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message