Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure compaction queue max size is at least 1 #5068

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1065,8 +1065,8 @@ private void cleanUpEmptyCompactorPathInZK() {
}
CompactionJobPriorityQueue queue = getJobQueues().getQueue(cgid);
if (queue != null) {
queue.setMaxSize(
Math.min((int) (aliveCompactorsForGroup * queueSizeFactor), Integer.MAX_VALUE));
queue.setMaxSize(Math.min(
Math.max(1, (int) (aliveCompactorsForGroup * queueSizeFactor)), Integer.MAX_VALUE));
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ public synchronized int getMaxSize() {
}

public synchronized void setMaxSize(int maxSize) {
Preconditions.checkArgument(maxSize > 0,
"Maximum size of the Compaction job priority queue must be greater than 0");
this.maxSize.set(maxSize);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.util.ArrayList;
Expand Down Expand Up @@ -345,6 +346,10 @@ public void testChangeMaxSize() {
assertEquals(100, queue.getMaxSize());
queue.setMaxSize(50);
assertEquals(50, queue.getMaxSize());
assertThrows(IllegalArgumentException.class, () -> queue.setMaxSize(0));
assertThrows(IllegalArgumentException.class, () -> queue.setMaxSize(-1));
// Make sure previous value was not changed after invalid setting
assertEquals(50, queue.getMaxSize());
}

}