From aefb235cea30f0e3ce52cec8b022869f2dece136 Mon Sep 17 00:00:00 2001 From: wphan Date: Fri, 24 Nov 2023 16:15:11 -0800 Subject: [PATCH] debug unhealthy SlotSubscriber --- src/core/metrics.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/core/metrics.ts b/src/core/metrics.ts index 6032d9e..bdeb495 100644 --- a/src/core/metrics.ts +++ b/src/core/metrics.ts @@ -126,9 +126,11 @@ const handleHealthCheck = async (req, res, next) => { if (req.url === '/health' || req.url === '/') { // check if a slot was received recently let healthySlotSubscriber = false; + let slotChanged = false; + let slotChangedRecently = false; await lastSlotReceivedMutex.runExclusive(async () => { - const slotChanged = lastSlotReceived > lastHealthCheckSlot; - const slotChangedRecently = + slotChanged = lastSlotReceived > lastHealthCheckSlot; + slotChangedRecently = Date.now() - lastHealthCheckSlotUpdated < healthCheckInterval; healthySlotSubscriber = slotChanged || slotChangedRecently; logger.debug( @@ -142,6 +144,9 @@ const handleHealthCheck = async (req, res, next) => { if (!healthySlotSubscriber) { healthStatus = HEALTH_STATUS.UnhealthySlotSubscriber; logger.error(`SlotSubscriber is not healthy`); + logger.error( + `Slotsubscriber health check: lastSlotReceived: ${lastSlotReceived}, lastHealthCheckSlot: ${lastHealthCheckSlot}, slotChanged: ${slotChanged}, slotChangedRecently: ${slotChangedRecently}` + ); res.writeHead(500); res.end(`SlotSubscriber is not healthy`);