You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by "yuanlihan (via GitHub)" <gi...@apache.org> on 2023/09/14 03:26:16 UTC

[PR] Fix invalid segment path when using hdfs as the intermediate deepstore (druid)

yuanlihan opened a new pull request, #14984:
URL: https://github.com/apache/druid/pull/14984

   <!-- Thanks for trying to help us make Apache Druid be the best it can be! Please fill out as much of the following information as is possible (where relevant, and remove it when irrelevant) to help make the intention and scope of this PR clear in order to ease review. -->
   
   <!-- Please read the doc for contribution (https://github.com/apache/druid/blob/master/CONTRIBUTING.md) before making this PR. Also, once you open a PR, please _avoid using force pushes and rebasing_ since these make it difficult for reviewers to see what you've changed in response to their reviews. See [the 'If your pull request shows conflicts with master' section](https://github.com/apache/druid/blob/master/CONTRIBUTING.md#if-your-pull-request-shows-conflicts-with-master) for more details. -->
   
   Fixes #14972.
   
   <!-- Replace XXXX with the id of the issue fixed in this PR. Remove this section if there is no corresponding issue. Don't reference the issue in the title of this pull-request. -->
   
   <!-- If you are a committer, follow the PR action item checklist for committers:
   https://github.com/apache/druid/blob/master/dev/committer-instructions.md#pr-and-issue-action-item-checklist-for-committers. -->
   
   ### Description
   
   <!-- Describe the goal of this PR, what problem are you fixing. If there is a corresponding issue (referenced above), it's not necessary to repeat the description here, however, you may choose to keep one summary sentence. -->
   
   <!-- Describe your patch: what did you change in code? How did you fix the problem? -->
   
   <!-- If there are several relatively logically separate changes in this PR, create a mini-section for each of them. For example: -->
   
   This PR fixes the invalid segment path when enabling `druid_processing_intermediaryData_storage_type: "deepstore"` and using `hdfs` as the deep store. 
   
   <!--
   In each section, please describe design decisions made, including:
    - Choice of algorithms
    - Behavioral aspects. What configuration values are acceptable? How are corner cases and error conditions handled, such as when there are insufficient resources?
    - Class organization and design (how the logic is split between classes, inheritance, composition, design patterns)
    - Method organization and design (how the logic is split between methods, parameters and return types)
    - Naming (class, method, API, configuration, HTTP endpoint, names of emitted metrics)
   -->
   
   
   <!-- It's good to describe an alternative design (or mention an alternative name) for every design (or naming) decision point and compare the alternatives with the designs that you've implemented (or the names you've chosen) to highlight the advantages of the chosen designs and names. -->
   
   <!-- If there was a discussion of the design of the feature implemented in this PR elsewhere (e. g. a "Proposal" issue, any other issue, or a thread in the development mailing list), link to that discussion from this PR description and explain what have changed in your final design compared to your original proposal or the consensus version in the end of the discussion. If something hasn't changed since the original discussion, you can omit a detailed discussion of those aspects of the design here, perhaps apart from brief mentioning for the sake of readability of this PR description. -->
   
   <!-- Some of the aspects mentioned above may be omitted for simple and small changes. -->
   
   #### Release note
   <!-- Give your best effort to summarize your changes in a couple of sentences aimed toward Druid users. 
   
   If your change doesn't have end user impact, you can skip this section.
   
   For tips about how to write a good release note, see [Release notes](https://github.com/apache/druid/blob/master/CONTRIBUTING.md#release-notes).
   
   -->
   
   
   <hr>
   
   ##### Key changed/added classes in this PR
    * `HdfsDataSegmentPusher`
   
   <hr>
   
   <!-- Check the items by putting "x" in the brackets for the done things. Not all of these items apply to every PR. Remove the items which are not done or not relevant to the PR. None of the items from the checklist below are strictly necessary, but it would be very helpful if you at least self-review the PR. -->
   
   This PR has:
   
   - [X] been self-reviewed.
   - [ ] added documentation for new or modified features or behaviors.
   - [ ] a release note entry in the PR description.
   - [ ] added Javadocs for most classes and all non-trivial methods. Linked related entities via Javadoc links.
   - [ ] added or updated version, license, or notice information in [licenses.yaml](https://github.com/apache/druid/blob/master/dev/license.md)
   - [ ] added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
   - [x] added unit tests or modified existing tests to cover new code paths, ensuring the threshold for [code coverage](https://github.com/apache/druid/blob/master/dev/code-review/code-coverage.md) is met.
   - [ ] added integration tests.
   - [x] been tested in a test Druid cluster.
   


-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix invalid segment path when using hdfs as the intermediate deepstore (druid)

Posted by "abhishekagarwal87 (via GitHub)" <gi...@apache.org>.
abhishekagarwal87 commented on code in PR #14984:
URL: https://github.com/apache/druid/pull/14984#discussion_r1338377313


##########
extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsDataSegmentPusher.java:
##########
@@ -124,8 +124,18 @@ public DataSegment pushToPath(File inDir, DataSegment segment, String storageDir
         fullyQualifiedStorageDirectory.get(),
         storageDirSuffix
     );
-
-    final String storageDir = StringUtils.format("%s/%s", fullyQualifiedStorageDirectory.get(), storageDirSuffix);
+    
+    final String outIndexFilePath;
+    if (storageDirSuffix.endsWith("index.zip")) {

Review Comment:
   Oh, I was suggesting refactoring just the HDFSDataSegmentPusher so you don't need to do that "endsWith" check in this class. 



-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix invalid segment path when using hdfs as the intermediate deepstore (druid)

Posted by "yuanlihan (via GitHub)" <gi...@apache.org>.
yuanlihan commented on code in PR #14984:
URL: https://github.com/apache/druid/pull/14984#discussion_r1340857787


##########
extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsDataSegmentPusher.java:
##########
@@ -124,8 +124,18 @@ public DataSegment pushToPath(File inDir, DataSegment segment, String storageDir
         fullyQualifiedStorageDirectory.get(),
         storageDirSuffix
     );
-
-    final String storageDir = StringUtils.format("%s/%s", fullyQualifiedStorageDirectory.get(), storageDirSuffix);
+    
+    final String outIndexFilePath;
+    if (storageDirSuffix.endsWith("index.zip")) {

Review Comment:
   @abhishekagarwal87 Oh I see. Updated.



-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix invalid segment path when using hdfs as the intermediate deepstore (druid)

Posted by "yuanlihan (via GitHub)" <gi...@apache.org>.
yuanlihan commented on code in PR #14984:
URL: https://github.com/apache/druid/pull/14984#discussion_r1336581289


##########
extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsDataSegmentPusher.java:
##########
@@ -124,8 +124,18 @@ public DataSegment pushToPath(File inDir, DataSegment segment, String storageDir
         fullyQualifiedStorageDirectory.get(),
         storageDirSuffix
     );
-
-    final String storageDir = StringUtils.format("%s/%s", fullyQualifiedStorageDirectory.get(), storageDirSuffix);
+    
+    final String outIndexFilePath;
+    if (storageDirSuffix.endsWith("index.zip")) {

Review Comment:
   @kfaraz Friendly bump! 



-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix invalid segment path when using hdfs as the intermediate deepstore (druid)

Posted by "yuanlihan (via GitHub)" <gi...@apache.org>.
yuanlihan commented on code in PR #14984:
URL: https://github.com/apache/druid/pull/14984#discussion_r1338156758


##########
extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsDataSegmentPusher.java:
##########
@@ -124,8 +124,18 @@ public DataSegment pushToPath(File inDir, DataSegment segment, String storageDir
         fullyQualifiedStorageDirectory.get(),
         storageDirSuffix
     );
-
-    final String storageDir = StringUtils.format("%s/%s", fullyQualifiedStorageDirectory.get(), storageDirSuffix);
+    
+    final String outIndexFilePath;
+    if (storageDirSuffix.endsWith("index.zip")) {

Review Comment:
   @abhishekagarwal87 Thanks for your comment!
   
   > The function name is a bit confusing since storageDirSuffix is really a suffix to the filename.
   
   I think `storageDirSuffix` shouldn't be the suffix to the filename but instead as the prefix dir of file `index.zip`.
   
   I have concern that adding a third method will need to touch all implementations. I think it's ok to reuse `pushToPath` method inside `push` method as long as it complies with passing a storageDirSuffix not file path to method `pushToPath`.
   
   Currently, only two implementations, `HdfsDataSegmentPusher` and `AzureDataSegmentPusher`, violate to pass file path  to their method `pushToPath` methods. Other implementations only format `storageDirSuffix` and reuse method `pushToPath` to format file path with `index.zip` file.
   
   We can also enhance the method doc of `pushToPath`
   https://github.com/apache/druid/blob/3ae5e978012e7a553e6ad3007eb210ab8da5b6fc/processing/src/main/java/org/apache/druid/segment/loading/DataSegmentPusher.java#L70-L75



-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix invalid segment path when using hdfs as the intermediate deepstore (druid)

Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #14984:
URL: https://github.com/apache/druid/pull/14984#discussion_r1325502927


##########
extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsDataSegmentPusher.java:
##########
@@ -124,8 +124,18 @@ public DataSegment pushToPath(File inDir, DataSegment segment, String storageDir
         fullyQualifiedStorageDirectory.get(),
         storageDirSuffix
     );
-
-    final String storageDir = StringUtils.format("%s/%s", fullyQualifiedStorageDirectory.get(), storageDirSuffix);
+    
+    final String outIndexFilePath;
+    if (storageDirSuffix.endsWith("index.zip")) {

Review Comment:
   After taking a look at the linked issue #14972 , it seems that the method `pushToPath` is always being called with the directory name except in `DeepStorageIntermediaryDataManager` where it is called with the actual filename.
   
   So the problem is not specific to `HdfsDataSegmentPusher` and might occur for other deep stores as well.
   
   The right thing to do is either to fix up `DeepStorageIntermediaryDataManager` or add a new `push` method which takes the filename rather than directory.



-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix invalid segment path when using hdfs as the intermediate deepstore (druid)

Posted by "yuanlihan (via GitHub)" <gi...@apache.org>.
yuanlihan commented on code in PR #14984:
URL: https://github.com/apache/druid/pull/14984#discussion_r1326796012


##########
extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsDataSegmentPusher.java:
##########
@@ -124,8 +124,18 @@ public DataSegment pushToPath(File inDir, DataSegment segment, String storageDir
         fullyQualifiedStorageDirectory.get(),
         storageDirSuffix
     );
-
-    final String storageDir = StringUtils.format("%s/%s", fullyQualifiedStorageDirectory.get(), storageDirSuffix);
+    
+    final String outIndexFilePath;
+    if (storageDirSuffix.endsWith("index.zip")) {

Review Comment:
   @kfaraz Thanks for looking into this! 
   
   My first intuition was also trying to fix `DeepStorageIntermediaryDataManager` by passing a file path contains `index.zip` suffix here
   https://github.com/apache/druid/blob/3ae5e978012e7a553e6ad3007eb210ab8da5b6fc/indexing-service/src/main/java/org/apache/druid/indexing/worker/shuffle/DeepStorageIntermediaryDataManager.java#L78
   
   But after checking other implementations of `DataSegmentPusher`, I found they all call method [pushToPath](https://github.com/apache/druid/blob/3ae5e978012e7a553e6ad3007eb210ab8da5b6fc/processing/src/main/java/org/apache/druid/segment/loading/DataSegmentPusher.java#L71) in their [push](https://github.com/apache/druid/blob/3ae5e978012e7a553e6ad3007eb210ab8da5b6fc/processing/src/main/java/org/apache/druid/segment/loading/DataSegmentPusher.java#L69) method. Some of them format segment file path contains `index.zip` suffix and pass it by parameter `storageDirSuffix` to method `pushToPath`, see below
   1. `AzureDataSegmentPusher`
   https://github.com/apache/druid/blob/3ae5e978012e7a553e6ad3007eb210ab8da5b6fc/extensions-core/azure-extensions/src/main/java/org/apache/druid/storage/azure/AzureDataSegmentPusher.java#L124-L125
   2. `HdfsDataSegmentPusher`
   https://github.com/apache/druid/blob/279b3818f0e02f6a2ff389532f1e6118598a7c24/extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsDataSegmentPusher.java#L108-L115
   
   Other implementations format `storageDirSuffix` by calling [getStorageDir](https://github.com/apache/druid/blob/279b3818f0e02f6a2ff389532f1e6118598a7c24/processing/src/main/java/org/apache/druid/segment/loading/DataSegmentPusher.java#L89) in their `push` methods.
   
   To fix the issue, I'd prefer to fix the inconsistent usages of `pushToPath` in method `AzureDataSegmentPusher#push` and `HdfsDataSegmentPusher#push`. We should always pass a dir to parameter `storageDirSuffix` of method `pushToPath` and format segment file path with suffix `index.zip` in method `pushToPath`. So, we don't need to change `DeepStorageIntermediaryDataManager` as it passes a dir to method `pushToPath`. Does it make sense to you?



-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix invalid segment path when using hdfs as the intermediate deepstore (druid)

Posted by "abhishekagarwal87 (via GitHub)" <gi...@apache.org>.
abhishekagarwal87 merged PR #14984:
URL: https://github.com/apache/druid/pull/14984


-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix invalid segment path when using hdfs as the intermediate deepstore (druid)

Posted by "abhishekagarwal87 (via GitHub)" <gi...@apache.org>.
abhishekagarwal87 commented on code in PR #14984:
URL: https://github.com/apache/druid/pull/14984#discussion_r1337040163


##########
extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsDataSegmentPusher.java:
##########
@@ -124,8 +124,18 @@ public DataSegment pushToPath(File inDir, DataSegment segment, String storageDir
         fullyQualifiedStorageDirectory.get(),
         storageDirSuffix
     );
-
-    final String storageDir = StringUtils.format("%s/%s", fullyQualifiedStorageDirectory.get(), storageDirSuffix);
+    
+    final String outIndexFilePath;
+    if (storageDirSuffix.endsWith("index.zip")) {

Review Comment:
   The function name is a bit confusing since storageDirSuffix is really a suffix to the filename. I looked at various implementations and this is what you can do to simplify the logic. Rather than `push` call `pushToPath` directly, both of these functions can call a separate third private function. `push` will create the right suffix by adding index.zip and so would `pushToPath`. `pushToPath` will add the suffix in the same way as org.apache.druid.storage.s3.S3Utils#constructSegmentPath
   
   How does that sound? 



-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix invalid segment path when using hdfs as the intermediate deepstore (druid)

Posted by "abhishekagarwal87 (via GitHub)" <gi...@apache.org>.
abhishekagarwal87 commented on PR #14984:
URL: https://github.com/apache/druid/pull/14984#issuecomment-1740427410

   thank you for your contribution @yuanlihan 


-- 
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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org


Re: [PR] Fix invalid segment path when using hdfs as the intermediate deepstore (druid)

Posted by "kfaraz (via GitHub)" <gi...@apache.org>.
kfaraz commented on code in PR #14984:
URL: https://github.com/apache/druid/pull/14984#discussion_r1325494397


##########
extensions-core/hdfs-storage/src/main/java/org/apache/druid/storage/hdfs/HdfsDataSegmentPusher.java:
##########
@@ -124,8 +124,18 @@ public DataSegment pushToPath(File inDir, DataSegment segment, String storageDir
         fullyQualifiedStorageDirectory.get(),
         storageDirSuffix
     );
-
-    final String storageDir = StringUtils.format("%s/%s", fullyQualifiedStorageDirectory.get(), storageDirSuffix);
+    
+    final String outIndexFilePath;
+    if (storageDirSuffix.endsWith("index.zip")) {

Review Comment:
   Could you please add some comments for both the if and else here? I am not sure why the `storageDirSuffix` would contain `index.zip` in 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: commits-unsubscribe@druid.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org