[ https://issues.apache.org/jira/browse/HIVE-26426?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Abhay updated HIVE-26426: ------------------------- Description: The call to canHandleQbForCbo() can result in an StringIndexOutOfBoundsException. The assumption in the code is that the msg can only be null and we handle that but the msg can also be an empty string if the *verbose* is set to false. This can happen if INFO Logging is not enabled. We need to handle that case. [https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java#L913] Here is the stack trace for reference: {noformat} FAILED: StringIndexOutOfBoundsException String index out of range: -2 15:10:24.192 [HiveServer2-Background-Pool: Thread-305] ERROR org.apache.hadoop.hive.ql.Driver - FAILED: StringIndexOutOfBoundsException String index out of range: -2 java.lang.StringIndexOutOfBoundsException: String index out of range: -2 at java.lang.String.substring(String.java:1967) at org.apache.hadoop.hive.ql.parse.CalcitePlanner.canCBOHandleAst(CalcitePlanner.java:996) at org.apache.hadoop.hive.ql.parse.CalcitePlanner.genOPTree(CalcitePlanner.java:572) at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal(SemanticAnalyzer.java:13063) at org.apache.hadoop.hive.ql.parse.CalcitePlanner.analyzeInternal(CalcitePlanner.java:472) at org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:314) at org.apache.hadoop.hive.ql.Compiler.analyze(Compiler.java:223) at org.apache.hadoop.hive.ql.Compiler.compile(Compiler.java:105) at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:201) at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:650) at org.apache.hadoop.hive.ql.Driver.compileAndRespond(Driver.java:596) at org.apache.hadoop.hive.ql.Driver.compileAndRespond(Driver.java:590) at org.apache.hadoop.hive.ql.reexec.ReExecDriver.compileAndRespond(ReExecDriver.java:127) at org.apache.hive.service.cli.operation.SQLOperation.prepare(SQLOperation.java:206) at org.apache.hive.service.cli.operation.SQLOperation$BackgroundWork$1.run(SQLOperation.java:336) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:422) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1899) at org.apache.hive.service.cli.operation.SQLOperation$BackgroundWork.run(SQLOperation.java:358) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:750){noformat} was: The call to canHandleQbForCbo() can result in an StringIndexOutOfBoundsException. The assumption in the code is that the msg can only be null and we handle that but the msg can also be an empty string if the *verbose* is set to false. This can happen if INFO Logging is not enabled. We need to handle that case. [https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java#L913] {noformat} Here is the stack trace for reference: FAILED: StringIndexOutOfBoundsException String index out of range: -2 15:10:24.192 [HiveServer2-Background-Pool: Thread-305] ERROR org.apache.hadoop.hive.ql.Driver - FAILED: StringIndexOutOfBoundsException String index out of range: -2 java.lang.StringIndexOutOfBoundsException: String index out of range: -2 at java.lang.String.substring(String.java:1967) at org.apache.hadoop.hive.ql.parse.CalcitePlanner.canCBOHandleAst(CalcitePlanner.java:996) at org.apache.hadoop.hive.ql.parse.CalcitePlanner.genOPTree(CalcitePlanner.java:572) at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal(SemanticAnalyzer.java:13063) at org.apache.hadoop.hive.ql.parse.CalcitePlanner.analyzeInternal(CalcitePlanner.java:472) at org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:314) at org.apache.hadoop.hive.ql.Compiler.analyze(Compiler.java:223) at org.apache.hadoop.hive.ql.Compiler.compile(Compiler.java:105) at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:201) at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:650) at org.apache.hadoop.hive.ql.Driver.compileAndRespond(Driver.java:596) at org.apache.hadoop.hive.ql.Driver.compileAndRespond(Driver.java:590) at org.apache.hadoop.hive.ql.reexec.ReExecDriver.compileAndRespond(ReExecDriver.java:127) at org.apache.hive.service.cli.operation.SQLOperation.prepare(SQLOperation.java:206) at org.apache.hive.service.cli.operation.SQLOperation$BackgroundWork$1.run(SQLOperation.java:336) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:422) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1899) at org.apache.hive.service.cli.operation.SQLOperation$BackgroundWork.run(SQLOperation.java:358) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:750){noformat} > Avoid StringIndexOutOfBoundsException in canCBOHandleAst() method. > ------------------------------------------------------------------ > > Key: HIVE-26426 > URL: https://issues.apache.org/jira/browse/HIVE-26426 > Project: Hive > Issue Type: Bug > Components: HiveServer2 > Reporter: Abhay > Assignee: Abhay > Priority: Minor > Labels: pull-request-available > Time Spent: 1h 10m > Remaining Estimate: 0h > > The call to canHandleQbForCbo() can result in an > StringIndexOutOfBoundsException. The assumption in the code is that the msg > can only be null and we handle that but the msg can also be an empty string > if the *verbose* is set to false. This can happen if INFO Logging is not > enabled. We need to handle that case. > [https://github.com/apache/hive/blob/master/ql/src/java/org/apache/hadoop/hive/ql/parse/CalcitePlanner.java#L913] > Here is the stack trace for reference: > {noformat} > FAILED: StringIndexOutOfBoundsException String index out of range: -2 > 15:10:24.192 [HiveServer2-Background-Pool: Thread-305] ERROR > org.apache.hadoop.hive.ql.Driver - FAILED: StringIndexOutOfBoundsException > String index out of range: -2 > java.lang.StringIndexOutOfBoundsException: String index out of range: -2 > at java.lang.String.substring(String.java:1967) > at > org.apache.hadoop.hive.ql.parse.CalcitePlanner.canCBOHandleAst(CalcitePlanner.java:996) > > at > org.apache.hadoop.hive.ql.parse.CalcitePlanner.genOPTree(CalcitePlanner.java:572) > > at > org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal(SemanticAnalyzer.java:13063) > at > org.apache.hadoop.hive.ql.parse.CalcitePlanner.analyzeInternal(CalcitePlanner.java:472) > > at > org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:314) > at org.apache.hadoop.hive.ql.Compiler.analyze(Compiler.java:223) > at org.apache.hadoop.hive.ql.Compiler.compile(Compiler.java:105) > at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:201) > at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:650) > at org.apache.hadoop.hive.ql.Driver.compileAndRespond(Driver.java:596) > at org.apache.hadoop.hive.ql.Driver.compileAndRespond(Driver.java:590) > at > org.apache.hadoop.hive.ql.reexec.ReExecDriver.compileAndRespond(ReExecDriver.java:127) > at > org.apache.hive.service.cli.operation.SQLOperation.prepare(SQLOperation.java:206) > at > org.apache.hive.service.cli.operation.SQLOperation$BackgroundWork$1.run(SQLOperation.java:336) > at java.security.AccessController.doPrivileged(Native Method) > at javax.security.auth.Subject.doAs(Subject.java:422) > at > org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1899) > at > org.apache.hive.service.cli.operation.SQLOperation$BackgroundWork.run(SQLOperation.java:358) > at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) > at java.util.concurrent.FutureTask.run(FutureTask.java:266) > at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) > at java.util.concurrent.FutureTask.run(FutureTask.java:266) > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) > at java.lang.Thread.run(Thread.java:750){noformat} -- This message was sent by Atlassian Jira (v8.20.10#820010)