From 80d12345de1ff8456685ef33ca0a281aeb47c8fa Mon Sep 17 00:00:00 2001 From: Theo Ilie Date: Wed, 10 Aug 2022 02:48:15 +0000 Subject: [PATCH 1/3] Fix TypeError for userSecondarySyncMetrics --- .../makeOnCompleteCallback.ts | 7 +++++-- .../findSyncRequests.jobProcessor.ts | 20 ++++++++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/creator-node/src/services/stateMachineManager/makeOnCompleteCallback.ts b/creator-node/src/services/stateMachineManager/makeOnCompleteCallback.ts index c6a2b55d45c..b8160a5eb79 100644 --- a/creator-node/src/services/stateMachineManager/makeOnCompleteCallback.ts +++ b/creator-node/src/services/stateMachineManager/makeOnCompleteCallback.ts @@ -53,8 +53,11 @@ module.exports = function ( prometheusRegistry: any ) { return async function (jobId: string, resultString: string) { - // Create a logger so that we can filter logs by the tag `jobId` = - const logger = createChildLogger(baseLogger, { jobId }) + // Create a logger so that we can filter logs by the tags `queue` and `jobId` = + const logger = createChildLogger(baseLogger, { + queue: nameOfQueueWithCompletedJob, + jobId + }) // update-replica-set jobs need enabledReconfigModes as an array. // `this` comes from the function being bound via .bind() to ./index.js diff --git a/creator-node/src/services/stateMachineManager/stateMonitoring/findSyncRequests.jobProcessor.ts b/creator-node/src/services/stateMachineManager/stateMonitoring/findSyncRequests.jobProcessor.ts index eb542bf063c..394d9b08547 100644 --- a/creator-node/src/services/stateMachineManager/stateMonitoring/findSyncRequests.jobProcessor.ts +++ b/creator-node/src/services/stateMachineManager/stateMonitoring/findSyncRequests.jobProcessor.ts @@ -78,9 +78,23 @@ module.exports = async function ({ for (const user of users) { const { wallet, primary, secondary1, secondary2 } = user - const userSecondarySyncMetrics = userSecondarySyncMetricsMap[wallet] || { - [secondary1]: { successRate: 1, failureCount: 0 }, - [secondary2]: { successRate: 1, failureCount: 0 } + const userSecondarySyncMetrics = userSecondarySyncMetricsMap[wallet] || {} + logger.info( + `Finding sync requests for user ${JSON.stringify( + user + )} with secondarySyncMetrics ${JSON.stringify(userSecondarySyncMetrics)}` + ) + userSecondarySyncMetrics[secondary1] = userSecondarySyncMetrics[ + secondary1 + ] || { + successRate: 1, + failureCount: 0 + } + userSecondarySyncMetrics[secondary2] = userSecondarySyncMetrics[ + secondary2 + ] || { + successRate: 1, + failureCount: 0 } const { From d7036ab58c38241fec448357cecf6f30ab1808ba Mon Sep 17 00:00:00 2001 From: Theo Ilie Date: Wed, 10 Aug 2022 03:05:44 +0000 Subject: [PATCH 2/3] Clean up the way we default --- .../findSyncRequests.jobProcessor.ts | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/creator-node/src/services/stateMachineManager/stateMonitoring/findSyncRequests.jobProcessor.ts b/creator-node/src/services/stateMachineManager/stateMonitoring/findSyncRequests.jobProcessor.ts index 394d9b08547..79fd6a0cbaa 100644 --- a/creator-node/src/services/stateMachineManager/stateMonitoring/findSyncRequests.jobProcessor.ts +++ b/creator-node/src/services/stateMachineManager/stateMonitoring/findSyncRequests.jobProcessor.ts @@ -78,24 +78,16 @@ module.exports = async function ({ for (const user of users) { const { wallet, primary, secondary1, secondary2 } = user - const userSecondarySyncMetrics = userSecondarySyncMetricsMap[wallet] || {} + const userSecondarySyncMetrics = { + [secondary1]: { successRate: 1, failureCount: 0 }, + [secondary2]: { successRate: 1, failureCount: 0 }, + ...userSecondarySyncMetricsMap[wallet] + } logger.info( `Finding sync requests for user ${JSON.stringify( user )} with secondarySyncMetrics ${JSON.stringify(userSecondarySyncMetrics)}` ) - userSecondarySyncMetrics[secondary1] = userSecondarySyncMetrics[ - secondary1 - ] || { - successRate: 1, - failureCount: 0 - } - userSecondarySyncMetrics[secondary2] = userSecondarySyncMetrics[ - secondary2 - ] || { - successRate: 1, - failureCount: 0 - } const { syncReqsToEnqueue: userSyncReqsToEnqueue, From 47ee4b17d5581b7c2c3886e0a98715f84e1dabc1 Mon Sep 17 00:00:00 2001 From: Theo Ilie Date: Wed, 10 Aug 2022 03:07:35 +0000 Subject: [PATCH 3/3] Make types happy --- .../stateMonitoring/findSyncRequests.jobProcessor.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/creator-node/src/services/stateMachineManager/stateMonitoring/findSyncRequests.jobProcessor.ts b/creator-node/src/services/stateMachineManager/stateMonitoring/findSyncRequests.jobProcessor.ts index 79fd6a0cbaa..5fe37eda1f5 100644 --- a/creator-node/src/services/stateMachineManager/stateMonitoring/findSyncRequests.jobProcessor.ts +++ b/creator-node/src/services/stateMachineManager/stateMonitoring/findSyncRequests.jobProcessor.ts @@ -79,8 +79,8 @@ module.exports = async function ({ const { wallet, primary, secondary1, secondary2 } = user const userSecondarySyncMetrics = { - [secondary1]: { successRate: 1, failureCount: 0 }, - [secondary2]: { successRate: 1, failureCount: 0 }, + [secondary1]: { successRate: 1, failureCount: 0, successCount: 0 }, + [secondary2]: { successRate: 1, failureCount: 0, successCount: 0 }, ...userSecondarySyncMetricsMap[wallet] } logger.info(