Hive LPAD function hangs HS2 and its subsequent queries

Recently I have noticed an issue in Hive that running below query will hang HiveServer2 indefinitely until it got cancelled. And because HiveServer2’s global compilation lock, it prevents any further queries from submitted into Hive and all queries appear to be queued.

SELECT lpad("String",10,'');

After researching, I concluded that it was caused by a Hive’s upstream bug: HIVE-15792. This has been fixed in upstream Hive 2.3.0 and in CDH5.12.1 and CDH5.13.0 onwards.

Currently, the only workaround is to have a non-empty string passed into the third parameter of the function, so below query will work:

SELECT lpad("String",10,'v');

The issue is basically caused by a code logic that will run in a loop infinitely when an empty string is passed into the function. You can have a look at the Patch in the JIRA for details of the change.

Hope above information helps.

Leave a Reply

Your email address will not be published. Required fields are marked *