Skip to content

Commit

Permalink
Ignore append locks for compaction when using concurrent locks (#16316)
Browse files Browse the repository at this point in the history
* Ignore append locks for compaction when using concurrent locks
  • Loading branch information
AmatyaAvadhanula authored Apr 22, 2024
1 parent 173a206 commit 08b5a8b
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -960,8 +960,19 @@ public Map<String, List<Interval>> getLockedIntervals(List<LockFilterPolicy> loc
}

final int priority = lockFilter.getPriority();
final boolean ignoreAppendLocks =
TaskLockType.REPLACE.name().equals(lockFilter.getContext().get(Tasks.TASK_LOCK_TYPE));
final boolean isReplaceLock = TaskLockType.REPLACE.name().equals(
lockFilter.getContext().getOrDefault(
Tasks.TASK_LOCK_TYPE,
Tasks.DEFAULT_TASK_LOCK_TYPE
)
);
final boolean isUsingConcurrentLocks = Boolean.TRUE.equals(
lockFilter.getContext().getOrDefault(
Tasks.USE_CONCURRENT_LOCKS,
Tasks.DEFAULT_USE_CONCURRENT_LOCKS
)
);
final boolean ignoreAppendLocks = isUsingConcurrentLocks || isReplaceLock;

running.get(datasource).forEach(
(startTime, startTimeLocks) -> startTimeLocks.forEach(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1325,6 +1325,34 @@ public void testGetLockedIntervalsForLowerPriorityReplaceLock()
Assert.assertTrue(conflictingIntervals.isEmpty());
}

@Test
public void testGetLockedIntervalsForLowerPriorityUseConcurrentLocks()
{
final Task task = NoopTask.ofPriority(50);
lockbox.add(task);
taskStorage.insert(task, TaskStatus.running(task.getId()));
tryTimeChunkLock(
TaskLockType.APPEND,
task,
Intervals.of("2017/2018")
);

LockFilterPolicy requestForReplaceLowerPriorityLock = new LockFilterPolicy(
task.getDataSource(),
25,
ImmutableMap.of(
Tasks.TASK_LOCK_TYPE,
TaskLockType.EXCLUSIVE.name(),
Tasks.USE_CONCURRENT_LOCKS,
true
)
);

Map<String, List<Interval>> conflictingIntervals =
lockbox.getLockedIntervals(ImmutableList.of(requestForReplaceLowerPriorityLock));
Assert.assertTrue(conflictingIntervals.isEmpty());
}


@Test
public void testExclusiveLockCompatibility()
Expand Down

0 comments on commit 08b5a8b

Please sign in to comment.