Skip to content

Commit 5775e71

Browse files
eldernewbornAli Poursamadi
andauthored
[server][da-vinci]: Raise disk health check thread priority (linkedin#2911)
Run the disk health check background thread at priority 8 so it stays responsive when other server components are under load without using max priority. Add test coverage to verify the created health check thread priority. Testing: ./gradlew :clients:da-vinci-client:test --tests com.linkedin.davinci.storage.DiskHealthCheckServiceTest Co-authored-by: Ali Poursamadi <apoursamadi@linkedin.com>
1 parent 781b496 commit 5775e71

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

clients/da-vinci-client/src/main/java/com/linkedin/davinci/storage/DiskHealthCheckService.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ public class DiskHealthCheckService extends AbstractVeniceService {
4646
// Visible for testing
4747
static final String TMP_FILE_NAME = ".health_check_file";
4848
private static final int TMP_FILE_SIZE_IN_BYTES = 64 * 1024; // 64KB
49+
// Keep the disk health check responsive even when other components are under heavy load, without using max priority.
50+
static final int HEALTH_CHECK_THREAD_PRIORITY = 8;
4951

5052
// lock object protects diskHealthy and lastStatusUpdateTimeInNS.
5153
private final Lock lock = new ReentrantLock();
@@ -118,7 +120,8 @@ public boolean startInner() {
118120
setLastStatusUpdateTimeInNS(System.nanoTime());
119121
healthCheckTask = new DiskHealthCheckTask();
120122
runner =
121-
new DaemonThreadFactory("Storage Disk Health Check Background Thread", logContext).newThread(healthCheckTask);
123+
new DaemonThreadFactory("Storage Disk Health Check Background Thread", HEALTH_CHECK_THREAD_PRIORITY, logContext)
124+
.newThread(healthCheckTask);
122125
runner.start();
123126

124127
return true;
@@ -161,6 +164,11 @@ DiskHealthCheckTask getHealthCheckTask() {
161164
return healthCheckTask;
162165
}
163166

167+
// Only for testing
168+
Thread getHealthCheckThread() {
169+
return runner;
170+
}
171+
164172
// Visible for testing
165173
class DiskHealthCheckTask implements Runnable {
166174
private volatile boolean stop = false;

clients/da-vinci-client/src/test/java/com/linkedin/davinci/storage/DiskHealthCheckServiceTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public void testBasicFunctionality() {
2929
LogContext.forTests(VeniceComponent.SERVER.name()))) {
3030
diskHealthCheckService.start();
3131

32+
assertEquals(
33+
diskHealthCheckService.getHealthCheckThread().getPriority(),
34+
DiskHealthCheckService.HEALTH_CHECK_THREAD_PRIORITY);
3235
assertTrue(diskHealthCheckService.isDiskHealthy());
3336
assertNull(diskHealthCheckService.getErrorMessage());
3437
assertTrue(diskHealthCheckService.getDiskHealthy());

0 commit comments

Comments
 (0)