You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/12/23 00:32:17 UTC

[GitHub] [iceberg] szehon-ho commented on a diff in pull request #6451: Hive: Lock hardening

szehon-ho commented on code in PR #6451:
URL: https://github.com/apache/iceberg/pull/6451#discussion_r1055950865


##########
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java:
##########
@@ -617,9 +624,27 @@ long acquireLock() throws UnknownHostException, TException, InterruptedException
             Lists.newArrayList(lockComponent),
             System.getProperty("user.name"),
             InetAddress.getLocalHost().getHostName());
-    LockResponse lockResponse = metaClients.run(client -> client.lock(lockRequest));
-    AtomicReference<LockState> state = new AtomicReference<>(lockResponse.getState());
-    long lockId = lockResponse.getLockid();
+
+    // Only works in Hive 2 or later.
+    if (MetastoreVersion.min(MetastoreVersion.HIVE_2)) {
+      lockRequest.setAgentInfo(agentInfo);
+    }
+
+    Pair<Long, LockState> lockResult;

Review Comment:
   I also think we could have number of retries configurable, (and optionally backoff) otherwise it doesnt match how everything else is configurable.



##########
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java:
##########
@@ -617,9 +624,27 @@ long acquireLock() throws UnknownHostException, TException, InterruptedException
             Lists.newArrayList(lockComponent),
             System.getProperty("user.name"),
             InetAddress.getLocalHost().getHostName());
-    LockResponse lockResponse = metaClients.run(client -> client.lock(lockRequest));
-    AtomicReference<LockState> state = new AtomicReference<>(lockResponse.getState());
-    long lockId = lockResponse.getLockid();
+
+    // Only works in Hive 2 or later.
+    if (MetastoreVersion.min(MetastoreVersion.HIVE_2)) {
+      lockRequest.setAgentInfo(agentInfo);
+    }
+
+    Pair<Long, LockState> lockResult;

Review Comment:
   Can we re-use the Tasks.retry().shouldRetryTest().run(...) like the rest of retries?
   
   That way we get backoff and configurable number of retries.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org