Matthew Sharp created HIVE-26831:
------------------------------------
Summary: Random temp ID for lock enqueue and commitTxn is not
guaranteed negative
Key: HIVE-26831
URL: https://issues.apache.org/jira/browse/HIVE-26831
Project: Hive
Issue Type: Bug
Affects Versions: 4.0.0-alpha-2, 4.0.0-alpha-1
Reporter: Matthew Sharp
HIVE-23283 mentions the goal of generating a negative number to avoid any
potential conflicts, but the current random number generation is not guaranteed
to produce only negative values.
>From the TxnHandler class:
{code:java}
private long generateTemporaryId() {
return -1 * ThreadLocalRandom.current().nextLong();
} {code}
If the nextLong returns a negative value we will see a positive temporary ID.
The odds of this conflicting may be low and with retries it may be hidden from
users, but this should be fixed to ensure only negative values are returned.
Something like this may be best:
{code:java}
private long generateTemporaryId() {
return ThreadLocalRandom.current().nextLong(Long.MIN_VALUE, 0);
}{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)