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

Eugene Koifman edited comment on HIVE-15181 at 11/22/16 1:43 AM:
-----------------------------------------------------------------

I think
{noformat}if (inList == null || inList.size() == 0) {
      return;
    }
{noformat}
should raise an error instead and force the caller to not call this at all with 
an empty list.  Such a call is certainly a mistake but as this bug indicates, 
returning an empty list of queries can cause really bad problems.

in TxnUtils.needNewQuery()  "sizeInBytes / 1024 > queryMemoryLimit" doesn't do 
the right thing.
If the user sets METASTORE_DIRECT_SQL_MAX_QUERY_LENGTH to 1K, they most likely 
want each SQL string to be at most 1K.
But if sizeInBytes=2047, this still returns false.
It should include length of "suffix" in computation of sizeInBytes

Along the same lines:  the check for max query length is done after each batch 
is already added to the query.  Suppose there are 1000 9-digit txn IDs in each 
IN(...).  That's, conservatively, 18KB of text.  So the length of each query is 
increasing in 18KB chunks.  
I think the check for query length should be done for each item in IN clause.
If some DB has a limit on query length of X, then any query > X will fail.  So 
I think this must ensure not to produce any queries > X, even by 1 char.




was (Author: ekoifman):
in TxnUtils.needNewQuery()  "sizeInBytes / 1024 > queryMemoryLimit" doesn't do 
the right thing.
If the user sets METASTORE_DIRECT_SQL_MAX_QUERY_LENGTH to 1K, they most likely 
want each SQL string to be at most 1K.
But if sizeInBytes=2047, this still returns false.
It should include length of "suffix" in computation of sizeInBytes

> buildQueryWithINClause didn't properly handle multiples of 
> ConfVars.METASTORE_DIRECT_SQL_MAX_ELEMENTS_IN_CLAUSE
> ---------------------------------------------------------------------------------------------------------------
>
>                 Key: HIVE-15181
>                 URL: https://issues.apache.org/jira/browse/HIVE-15181
>             Project: Hive
>          Issue Type: Bug
>          Components: Hive, Transactions
>    Affects Versions: 1.2.1, 2.1.0
>            Reporter: Wei Zheng
>            Assignee: Wei Zheng
>            Priority: Critical
>         Attachments: HIVE-15181.1.patch, HIVE-15181.2.patch
>
>
> As there is a bug, we can still work around the issue by using the settings 
> below (making sure the second setting is always at least 1000 times of the 
> first setting):
> set hive.direct.sql.max.query.length=1;
> set hive.direct.sql.max.elements.in.clause=1000;



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to