You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@orc.apache.org by GitBox <gi...@apache.org> on 2021/10/19 11:34:01 UTC

[GitHub] [orc] guiyanakuang opened a new pull request #940: ORC-1029: ServiceLoader is not thread-safe, avoid concurrent calls

guiyanakuang opened a new pull request #940:
URL: https://github.com/apache/orc/pull/940


   <!--
   Thanks for sending a pull request!  Here are some tips for you:
     1. File a JIRA issue first and use it as a prefix of your PR title, e.g., `ORC-001: Fix ABC`.
     2. Use your PR title to summarize what this PR proposes instead of describing the problem.
     3. Make PR title and description complete because these will be the permanent commit log.
     4. If possible, provide a concise and reproducible example to reproduce the issue for a faster review.
     5. If the PR is unfinished, use GitHub PR Draft feature.
   -->
   
   ### What changes were proposed in this pull request?
   <!--
   Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue. 
   If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
     1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
     2. If there is a discussion in the mailing list, please add the link.
   -->
   The previous code reuses LOADER to build DataMask, but the ServiceLoader class is not thread-safe and will cause an exception if called concurrently.
   Checking the source code, I found that ServiceLoader.load is a lazy method, which is relatively lightweight and only records the relevant information until the iterator starts reading before loading the class, so I think it is acceptable not to reuse it.
   
   ### Why are the changes needed?
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you propose a new API, clarify the use case for a new API.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   Avoid concurrent calls leading to exceptions.
   
   ### How was this patch tested?
   <!--
   If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
   If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
   If tests were not added, please describe why they were not added and/or why it was difficult to add.
   -->
   Add UT.


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org

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



[GitHub] [orc] guiyanakuang commented on a change in pull request #940: ORC-1029: ServiceLoader is not thread-safe, avoid concurrent calls

Posted by GitBox <gi...@apache.org>.
guiyanakuang commented on a change in pull request #940:
URL: https://github.com/apache/orc/pull/940#discussion_r732552415



##########
File path: java/core/src/test/org/apache/orc/impl/TestEncryption.java
##########
@@ -140,4 +145,43 @@ public void testPushDownReadEncryption() throws IOException {
     read(true);
   }
 
+  @Test
+  @SuppressWarnings("unchecked")
+  public void testConcurrentCreation() throws InterruptedException {

Review comment:
       @dongjoon-hyun. After reading some guides, it is common to increase the number of concurrency and test the number of repetitions of the method to achieve the goal. But it still does not guarantee 100% failure. I agree merge without test cases. 🤔 




-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org

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



[GitHub] [orc] dongjoon-hyun commented on a change in pull request #940: ORC-1029: ServiceLoader is not thread-safe, avoid concurrent calls

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #940:
URL: https://github.com/apache/orc/pull/940#discussion_r732475780



##########
File path: java/core/src/test/org/apache/orc/impl/TestEncryption.java
##########
@@ -140,4 +145,43 @@ public void testPushDownReadEncryption() throws IOException {
     read(true);
   }
 
+  @Test
+  @SuppressWarnings("unchecked")
+  public void testConcurrentCreation() throws InterruptedException {

Review comment:
       If it's too hard, we can merge without test cases. Please let me know if this is the case.




-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org

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



[GitHub] [orc] dongjoon-hyun commented on a change in pull request #940: ORC-1029: ServiceLoader is not thread-safe, avoid concurrent calls

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #940:
URL: https://github.com/apache/orc/pull/940#discussion_r732475228



##########
File path: java/core/src/test/org/apache/orc/impl/TestEncryption.java
##########
@@ -140,4 +145,43 @@ public void testPushDownReadEncryption() throws IOException {
     read(true);
   }
 
+  @Test
+  @SuppressWarnings("unchecked")
+  public void testConcurrentCreation() throws InterruptedException {

Review comment:
       Thanks!




-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org

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



[GitHub] [orc] dongjoon-hyun commented on a change in pull request #940: ORC-1029: ServiceLoader is not thread-safe, avoid concurrent calls

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun commented on a change in pull request #940:
URL: https://github.com/apache/orc/pull/940#discussion_r732470615



##########
File path: java/core/src/test/org/apache/orc/impl/TestEncryption.java
##########
@@ -140,4 +145,43 @@ public void testPushDownReadEncryption() throws IOException {
     read(true);
   }
 
+  @Test
+  @SuppressWarnings("unchecked")
+  public void testConcurrentCreation() throws InterruptedException {

Review comment:
       This seems to succeed without the patch in my environment. Do I need to set something to make this fail consistently?
   
   ```
   [INFO] ------------------------------------------------------------------------
   [INFO] Reactor Summary for Apache ORC 1.8.0-SNAPSHOT:
   [INFO]
   [INFO] Apache ORC ......................................... SUCCESS [  1.138 s]
   [INFO] ORC Shims .......................................... SUCCESS [  1.346 s]
   [INFO] ORC Core ........................................... SUCCESS [01:21 min]
   [INFO] ORC MapReduce ...................................... SUCCESS [ 25.150 s]
   [INFO] ORC Tools .......................................... SUCCESS [  9.765 s]
   [INFO] ORC Examples ....................................... SUCCESS [  2.684 s]
   [INFO] ------------------------------------------------------------------------
   [INFO] BUILD SUCCESS
   [INFO] ------------------------------------------------------------------------
   [INFO] Total time:  02:02 min
   [INFO] Finished at: 2021-10-20T00:04:03-07:00
   [INFO] ------------------------------------------------------------------------
   m1 java:ORC-1029 ✗ $ git diff main --stat
    java/core/src/test/org/apache/orc/impl/TestEncryption.java | 44 ++++++++++++++++++++++++++++++++++++++++++++
    1 file changed, 44 insertions(+)
   ```

##########
File path: java/core/src/test/org/apache/orc/impl/TestEncryption.java
##########
@@ -140,4 +145,43 @@ public void testPushDownReadEncryption() throws IOException {
     read(true);
   }
 
+  @Test
+  @SuppressWarnings("unchecked")
+  public void testConcurrentCreation() throws InterruptedException {

Review comment:
       This test case seems to succeed without the patch in my environment. Do I need to set something to make this fail consistently?
   
   ```
   [INFO] ------------------------------------------------------------------------
   [INFO] Reactor Summary for Apache ORC 1.8.0-SNAPSHOT:
   [INFO]
   [INFO] Apache ORC ......................................... SUCCESS [  1.138 s]
   [INFO] ORC Shims .......................................... SUCCESS [  1.346 s]
   [INFO] ORC Core ........................................... SUCCESS [01:21 min]
   [INFO] ORC MapReduce ...................................... SUCCESS [ 25.150 s]
   [INFO] ORC Tools .......................................... SUCCESS [  9.765 s]
   [INFO] ORC Examples ....................................... SUCCESS [  2.684 s]
   [INFO] ------------------------------------------------------------------------
   [INFO] BUILD SUCCESS
   [INFO] ------------------------------------------------------------------------
   [INFO] Total time:  02:02 min
   [INFO] Finished at: 2021-10-20T00:04:03-07:00
   [INFO] ------------------------------------------------------------------------
   m1 java:ORC-1029 ✗ $ git diff main --stat
    java/core/src/test/org/apache/orc/impl/TestEncryption.java | 44 ++++++++++++++++++++++++++++++++++++++++++++
    1 file changed, 44 insertions(+)
   ```




-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org

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



[GitHub] [orc] dongjoon-hyun merged pull request #940: ORC-1029: ServiceLoader is not thread-safe, avoid concurrent calls

Posted by GitBox <gi...@apache.org>.
dongjoon-hyun merged pull request #940:
URL: https://github.com/apache/orc/pull/940


   


-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org

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



[GitHub] [orc] guiyanakuang commented on a change in pull request #940: ORC-1029: ServiceLoader is not thread-safe, avoid concurrent calls

Posted by GitBox <gi...@apache.org>.
guiyanakuang commented on a change in pull request #940:
URL: https://github.com/apache/orc/pull/940#discussion_r732474540



##########
File path: java/core/src/test/org/apache/orc/impl/TestEncryption.java
##########
@@ -140,4 +145,43 @@ public void testPushDownReadEncryption() throws IOException {
     read(true);
   }
 
+  @Test
+  @SuppressWarnings("unchecked")
+  public void testConcurrentCreation() throws InterruptedException {

Review comment:
       Although the ServiceLoader is not thread-safe, there is a chance that concurrent access will work, so I'll investigate if there's a better way to reproduce it




-- 
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.

To unsubscribe, e-mail: dev-unsubscribe@orc.apache.org

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