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

ASF GitHub Bot commented on DRILL-8283:
---------------------------------------

vvysotskyi commented on code in PR #2632:
URL: https://github.com/apache/drill/pull/2632#discussion_r954723117


##########
exec/java-exec/src/main/java/org/apache/drill/exec/util/FileSystemUtil.java:
##########
@@ -302,12 +332,32 @@ protected List<FileStatus> compute() {
       List<RecursiveListing> tasks = new ArrayList<>();
 
       try {
-        for (FileStatus status : fs.listStatus(path, filter)) {
+        FileStatus[] dirFs = fs.listStatus(path, filter);
+        if (recursiveListingMaxSize > 0 && fileCounter.addAndGet(dirFs.length) 
> recursiveListingMaxSize) {
+          throw UserException

Review Comment:
   This code is executed within fork join pool, and if error suppression flag 
is enabled, it will call task.fork(). Can we somehow stop executing all tasks 
for the case when count is reached?





> Add a configurable recursive file listing size limit
> ----------------------------------------------------
>
>                 Key: DRILL-8283
>                 URL: https://issues.apache.org/jira/browse/DRILL-8283
>             Project: Apache Drill
>          Issue Type: Improvement
>          Components: Storage - Other
>    Affects Versions: 1.20.2
>            Reporter: James Turton
>            Assignee: James Turton
>            Priority: Minor
>             Fix For: 1.20.3
>
>
> Currently a malicious or merely unwitting user can crash their Drill foreman 
> by sending
> {code:java}
> select * from dfs.huge_workspace limit 10
> {code}
> causing the query planner to recurse over every file in huge_workspace and 
> culminating in
> {code:java}
> 2022-08-09 15:13:22,251 [1d0da29f-e50c-fd51-43d9-8a5086d52c4e:foreman] ERROR 
> o.a.drill.common.CatastrophicFailure - Catastrophic Failure Occurred, 
> exiting. Information message: Unable to handle out of memory condition in 
> Foreman.java.lang.OutOfMemoryError: null {code}
> if there are enough files in huge_workspace. A SHOW FILES command can produce 
> the same effect. This issue proposes a new BOOT option named 
> drill.exec.storage.file.recursive_listing_max_size with a default value of, 
> say 10 000. If a file listing task exceeds this limit then the initiating 
> operation is terminated with a UserException preventing runaway resource 
> usage.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to