Skip to content

Commit b115c85

Browse files
HIVE-29237: Addendum: Hive: Refactor commit lock mechanism from HiveTableOperations (#6112)
Note: this isn’t a full port — it brings over some missing changes from the previous port, mainly related to tests. (cherry picked from commit 333227fbd13821365cec1bdbfcb9314a239bea0f)
1 parent d46d900 commit b115c85

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

iceberg/iceberg-catalog/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -304,16 +304,6 @@ public ClientPool<IMetaStoreClient, TException> metaClients() {
304304
return metaClients;
305305
}
306306

307-
void doUnlock(HiveLock lock) {
308-
if (lock != null) {
309-
try {
310-
lock.unlock();
311-
} catch (Exception e) {
312-
LOG.warn("Failed to unlock {}.{}", database, tableName, e);
313-
}
314-
}
315-
}
316-
317307
/**
318308
* Returns if the hive engine related values should be enabled on the table, or not.
319309
* <p>

iceberg/iceberg-catalog/src/test/java/org/apache/iceberg/hive/TestHiveCommitLocks.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,6 @@ public void testLockAcquisitionAfterFailedNotFoundLock() throws TException, Inte
281281
.doReturn(acquiredLockResponse)
282282
.when(spyClient)
283283
.checkLock(eq(dummyLockId));
284-
doNothing().when(spyOps).doUnlock(any());
285284
doNothing().when(spyClient).heartbeat(eq(0L), eq(dummyLockId));
286285

287286
spyOps.doCommit(metadataV2, metadataV1);
@@ -307,7 +306,6 @@ public void testLockAcquisitionAfterFailedAndFoundLock() throws TException, Inte
307306

308307
doReturn(showLocksResponse).when(spyClient).showLocks(any());
309308
doReturn(acquiredLockResponse).when(spyClient).checkLock(eq(dummyLockId));
310-
doNothing().when(spyOps).doUnlock(any());
311309
doNothing().when(spyClient).heartbeat(eq(0L), eq(dummyLockId));
312310

313311
spyOps.doCommit(metadataV2, metadataV1);
@@ -569,11 +567,11 @@ public void testTableLevelProcessLockBlocksConcurrentHMSRequestsForSameTable() t
569567
}
570568

571569
@Test
572-
public void testLockHeartbeat() throws TException {
570+
public void testLockHeartbeat() throws TException, InterruptedException {
573571
doReturn(acquiredLockResponse).when(spyClient).lock(any());
574572
doAnswer(AdditionalAnswers.answersWithDelay(2000, InvocationOnMock::callRealMethod))
575-
.when(spyClient)
576-
.getTable(any(), any());
573+
.when(spyOps)
574+
.loadHmsTable();
577575
doNothing().when(spyClient).heartbeat(eq(0L), eq(dummyLockId));
578576

579577
spyOps.doCommit(metadataV2, metadataV1);

0 commit comments

Comments
 (0)