mirror of
https://github.com/fosrl/pangolin.git
synced 2026-04-02 03:39:09 +00:00
Prevent increase in writes on reconnect
This commit is contained in:
@@ -77,7 +77,8 @@ export const handleHealthcheckStatusMessage: MessageHandler = async (
|
||||
const [targetCheck] = await db
|
||||
.select({
|
||||
targetId: targets.targetId,
|
||||
siteId: targets.siteId
|
||||
siteId: targets.siteId,
|
||||
hcStatus: targetHealthCheck.hcHealth
|
||||
})
|
||||
.from(targets)
|
||||
.innerJoin(
|
||||
@@ -85,6 +86,7 @@ export const handleHealthcheckStatusMessage: MessageHandler = async (
|
||||
eq(targets.resourceId, resources.resourceId)
|
||||
)
|
||||
.innerJoin(sites, eq(targets.siteId, sites.siteId))
|
||||
.innerJoin(targetHealthCheck, eq(targets.targetId, targetHealthCheck.targetId))
|
||||
.where(
|
||||
and(
|
||||
eq(targets.targetId, targetIdNum),
|
||||
@@ -101,6 +103,14 @@ export const handleHealthcheckStatusMessage: MessageHandler = async (
|
||||
continue;
|
||||
}
|
||||
|
||||
// check if the status has changed
|
||||
if (targetCheck.hcStatus === healthStatus.status) {
|
||||
logger.debug(
|
||||
`Health status for target ${targetId} is already ${healthStatus.status}, skipping update`
|
||||
);
|
||||
continue;
|
||||
}
|
||||
|
||||
// Update the target's health status in the database
|
||||
await db
|
||||
.update(targetHealthCheck)
|
||||
|
||||
Reference in New Issue
Block a user