Skip to content

Commit

Permalink
Log cnode to sp id map when determining replica set updates (#3550)
Browse files Browse the repository at this point in the history
* await baby

* logs
  • Loading branch information
vicky-g authored Jul 26, 2022
1 parent bd76c8e commit 87c4f2c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { logger } = require('../../logging')
const { logger: genericLogger } = require('../../logging')

/**
* Queries to periodically keep the mapping of (Content Node endpoint -> SP ID)
Expand Down Expand Up @@ -29,7 +29,9 @@ class CNodeToSpIdMapManager {
cNodeEndpointToSpIdMap[cn.endpoint] = cn.spID
})
} catch (e) {
logger.error(`updateCnodeEndpointToSpIdMap Error: ${e.message}`)
genericLogger.error(
`CNodeToSpIdMapManager - Could not fetch content nodes: ${e.message}`
)
}

if (Object.keys(cNodeEndpointToSpIdMap).length > 0) {
Expand All @@ -39,12 +41,14 @@ class CNodeToSpIdMapManager {
const mapLength = Object.keys(this.cNodeEndpointToSpIdMap).length
if (mapLength === 0) {
const errorMessage =
'updateCnodeEndpointToSpIdMap() Unable to initialize cNodeEndpointToSpIdMap'
logger.error(errorMessage)
'CNodeToSpIdMapManager - Unable to initialize cNodeEndpointToSpIdMap'
genericLogger.error(errorMessage)
throw new Error(errorMessage)
}

logger.info(`updateEndpointToSpIdMap Success. Size: ${mapLength}`)
genericLogger.info(
`CNodeToSpIdMapManager - updateCnodeEndpointToSpIdMap Success. Size: ${mapLength}`
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const NodeToSpIdManager = require('../CNodeToSpIdMapManager')
module.exports = async function ({ logger }) {
let errorMsg = ''
try {
NodeToSpIdManager.updateCnodeEndpointToSpIdMap(
await NodeToSpIdManager.updateCnodeEndpointToSpIdMap(
QueueInterfacer.getAudiusLibs().ethContracts
)
} catch (e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,18 @@ const _findReplicaSetUpdatesForUser = async (
secondaryInfo.spId
}, found ${
CNodeToSpIdMapManager.getCNodeEndpointToSpIdMap()[secondary]
}. Marking replica as unhealthy.`
}. Marking replica as unhealthy. Endpoint to spID mapping: ${JSON.stringify(
CNodeToSpIdMapManager.getCNodeEndpointToSpIdMap()
)}`
)
unhealthyReplicas.add(secondary)

// Error case 2 - already marked unhealthy
} else if (unhealthyPeersSet.has(secondary)) {
logger.error(
`_findReplicaSetUpdatesForUser(): Secondary ${secondary} for user ${wallet} in unhealthy peer set. Marking replica as unhealthy.`
`_findReplicaSetUpdatesForUser(): Secondary ${secondary} for user ${wallet} in unhealthy peer set. Marking replica as unhealthy. Endpoint to spID mapping: ${JSON.stringify(
CNodeToSpIdMapManager.getCNodeEndpointToSpIdMap()
)}`
)
unhealthyReplicas.add(secondary)

Expand All @@ -245,7 +249,9 @@ const _findReplicaSetUpdatesForUser = async (
successRate < minSecondaryUserSyncSuccessPercent
) {
logger.error(
`_findReplicaSetUpdatesForUser(): Secondary ${secondary} for user ${wallet} has userSyncSuccessRate of ${successRate}, which is below threshold of ${minSecondaryUserSyncSuccessPercent}. ${successCount} Successful syncs vs ${failureCount} Failed syncs. Marking replica as unhealthy.`
`_findReplicaSetUpdatesForUser(): Secondary ${secondary} for user ${wallet} has userSyncSuccessRate of ${successRate}, which is below threshold of ${minSecondaryUserSyncSuccessPercent}. ${successCount} Successful syncs vs ${failureCount} Failed syncs. Marking replica as unhealthy. Endpoint to spID mapping: ${JSON.stringify(
CNodeToSpIdMapManager.getCNodeEndpointToSpIdMap()
)}`
)
unhealthyReplicas.add(secondary)
}
Expand Down

0 comments on commit 87c4f2c

Please sign in to comment.