You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by GitBox <gi...@apache.org> on 2020/07/22 13:56:38 UTC

[GitHub] [jackrabbit-oak] stefan-egli opened a new pull request #243: OAK-9149 : Use batch calls in backgroundSplit

stefan-egli opened a new pull request #243:
URL: https://github.com/apache/jackrabbit-oak/pull/243


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] Joscorbe commented on a change in pull request #243: OAK-9149 : Use batch calls in backgroundSplit

Posted by GitBox <gi...@apache.org>.
Joscorbe commented on a change in pull request #243:
URL: https://github.com/apache/jackrabbit-oak/pull/243#discussion_r461607090



##########
File path: oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
##########
@@ -3160,6 +3187,22 @@ private void signalClusterStateChange() {
         }
     }
 
+    /**
+     * FOR TESTING ONLY :
+     * stops the backgroundUpdateThread (by overwriting its
+     * isDisposed flag) and optionally waits for the thread to
+     * terminate.
+     * @param timeoutMillis optional amount of millis to wait for the thread to terminate at max
+     * @return true if thread is no longer running
+     */
+    boolean stopBackgroundUpdateThread(long timeoutMillis) throws InterruptedException {

Review comment:
       I tried to think about a more elegant way to do this, maybe using Reflection in the test, but after discussing with @stefan-egli this is probably the clearer way to do this.
   I think it would be interesting to have a second opinion here.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] mreutegg commented on a change in pull request #243: OAK-9149 : Use batch calls in backgroundSplit

Posted by GitBox <gi...@apache.org>.
mreutegg commented on a change in pull request #243:
URL: https://github.com/apache/jackrabbit-oak/pull/243#discussion_r464868820



##########
File path: oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
##########
@@ -3160,6 +3187,22 @@ private void signalClusterStateChange() {
         }
     }
 
+    /**
+     * FOR TESTING ONLY :
+     * stops the backgroundUpdateThread (by overwriting its
+     * isDisposed flag) and optionally waits for the thread to
+     * terminate.
+     * @param timeoutMillis optional amount of millis to wait for the thread to terminate at max
+     * @return true if thread is no longer running
+     */
+    boolean stopBackgroundUpdateThread(long timeoutMillis) throws InterruptedException {

Review comment:
       AFAICS the test simply wants to take control of when a background update happens. That means, the alternative is setting the asyncDelay of the DocumentNodeStore to zero in the test. See proposed changes in https://github.com/apache/jackrabbit-oak/pull/244




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] stefan-egli commented on pull request #243: OAK-9149 : Use batch calls in backgroundSplit

Posted by GitBox <gi...@apache.org>.
stefan-egli commented on pull request #243:
URL: https://github.com/apache/jackrabbit-oak/pull/243#issuecomment-665082364


   Thx for the review @Joscorbe !


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] stefan-egli commented on a change in pull request #243: OAK-9149 : Use batch calls in backgroundSplit

Posted by GitBox <gi...@apache.org>.
stefan-egli commented on a change in pull request #243:
URL: https://github.com/apache/jackrabbit-oak/pull/243#discussion_r462161347



##########
File path: oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
##########
@@ -3160,6 +3187,22 @@ private void signalClusterStateChange() {
         }
     }
 
+    /**
+     * FOR TESTING ONLY :
+     * stops the backgroundUpdateThread (by overwriting its
+     * isDisposed flag) and optionally waits for the thread to
+     * terminate.
+     * @param timeoutMillis optional amount of millis to wait for the thread to terminate at max
+     * @return true if thread is no longer running
+     */
+    boolean stopBackgroundUpdateThread(long timeoutMillis) throws InterruptedException {

Review comment:
       Nice, thx @fabriziofortino, I've added this now.

##########
File path: oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
##########
@@ -3160,6 +3187,22 @@ private void signalClusterStateChange() {
         }
     }
 
+    /**
+     * FOR TESTING ONLY :
+     * stops the backgroundUpdateThread (by overwriting its
+     * isDisposed flag) and optionally waits for the thread to
+     * terminate.
+     * @param timeoutMillis optional amount of millis to wait for the thread to terminate at max
+     * @return true if thread is no longer running
+     */
+    boolean stopBackgroundUpdateThread(long timeoutMillis) throws InterruptedException {

Review comment:
       @jsedding interesting approach indeed. I think this might be something we could look into. I'm wondering if it could be done in a separate ticket though, as I think it could involve quite a bit of changes and would meanwhile block progress on this? The concern I see with a thread-factory is that for gracefully stopping the 'BackgroundUpdateOperation' (or the 'NodeStoreTask' actually) one needs to hook into the 'NodeStoreTask.run' loop - and the current patch does that by overwriting the 'isDisposed' in 'forceStop()'. The thread-factory variant would still need to do that as well, one way or another, I guess. So something like the suggested 'forceStop()' would still be necessary I think. But the "ugly" 'stopBackgroundUpdateThread' would be gone, agreed. 
   
   Should I create a follow-up ticket for this (with the risk of that being prioritized lower though, agreed)?

##########
File path: oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
##########
@@ -3160,6 +3187,22 @@ private void signalClusterStateChange() {
         }
     }
 
+    /**
+     * FOR TESTING ONLY :
+     * stops the backgroundUpdateThread (by overwriting its
+     * isDisposed flag) and optionally waits for the thread to
+     * terminate.
+     * @param timeoutMillis optional amount of millis to wait for the thread to terminate at max
+     * @return true if thread is no longer running
+     */
+    boolean stopBackgroundUpdateThread(long timeoutMillis) throws InterruptedException {

Review comment:
       @jsedding interesting approach indeed. I think this might be something we could look into. I'm wondering if it could be done in a separate ticket though, as I think it could involve quite a bit of changes and would meanwhile block progress on this? The concern I see with a thread-factory is that for gracefully stopping the `BackgroundUpdateOperation` (or the `NodeStoreTask` actually) one needs to hook into the `NodeStoreTask.run` loop - and the current patch does that by overwriting the `isDisposed` in `forceStop()`. The thread-factory variant would still need to do that as well, one way or another, I guess. So something like the suggested `forceStop()` would still be necessary I think. But the "ugly" `stopBackgroundUpdateThread` would be gone, agreed. 
   
   Should I create a follow-up ticket for this (with the risk of that being prioritized lower though, agreed)?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] jsedding commented on a change in pull request #243: OAK-9149 : Use batch calls in backgroundSplit

Posted by GitBox <gi...@apache.org>.
jsedding commented on a change in pull request #243:
URL: https://github.com/apache/jackrabbit-oak/pull/243#discussion_r462359594



##########
File path: oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
##########
@@ -3160,6 +3187,22 @@ private void signalClusterStateChange() {
         }
     }
 
+    /**
+     * FOR TESTING ONLY :
+     * stops the backgroundUpdateThread (by overwriting its
+     * isDisposed flag) and optionally waits for the thread to
+     * terminate.
+     * @param timeoutMillis optional amount of millis to wait for the thread to terminate at max
+     * @return true if thread is no longer running
+     */
+    boolean stopBackgroundUpdateThread(long timeoutMillis) throws InterruptedException {

Review comment:
       Since @Joscorbe asked for a second opinion. I could imagine passing a thread-factory (could be a BiFunction<BackgroundUpdateOperation, String>) into a new `DocumentNodeStore` constructor. That way the tests could pass in a suitable factory and keep a reference to the thread and `BackgroundUpdateOperation` to be able to accomplish the desired behaviour. IMHO that would be more elegant, but that, as always, is in the eye of the beholder.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] stefan-egli commented on pull request #243: OAK-9149 : Use batch calls in backgroundSplit

Posted by GitBox <gi...@apache.org>.
stefan-egli commented on pull request #243:
URL: https://github.com/apache/jackrabbit-oak/pull/243#issuecomment-666184924


   Merged to SVN in [1880432](http://svn.apache.org/viewvc?rev=1880432&view=rev)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [jackrabbit-oak] stefan-egli commented on a change in pull request #243: OAK-9149 : Use batch calls in backgroundSplit

Posted by GitBox <gi...@apache.org>.
stefan-egli commented on a change in pull request #243:
URL: https://github.com/apache/jackrabbit-oak/pull/243#discussion_r461634945



##########
File path: oak-store-document/src/main/java/org/apache/jackrabbit/oak/plugins/document/DocumentNodeStore.java
##########
@@ -3160,6 +3187,22 @@ private void signalClusterStateChange() {
         }
     }
 
+    /**
+     * FOR TESTING ONLY :
+     * stops the backgroundUpdateThread (by overwriting its
+     * isDisposed flag) and optionally waits for the thread to
+     * terminate.
+     * @param timeoutMillis optional amount of millis to wait for the thread to terminate at max
+     * @return true if thread is no longer running
+     */
+    boolean stopBackgroundUpdateThread(long timeoutMillis) throws InterruptedException {

Review comment:
       Agreed it's not elegant, but without changing too much the advantage of this is that it's explicit and I think maintainable.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org