From 1038c5cd0d3735f17ff331137f42dcf90aed027d Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Mon, 8 Jul 2019 11:53:42 +0100 Subject: [PATCH 1/2] send health check to pubsub channel and use different var name --- services/real-time/app.coffee | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/real-time/app.coffee b/services/real-time/app.coffee index 0ddfe406e9..ab45c525b4 100644 --- a/services/real-time/app.coffee +++ b/services/real-time/app.coffee @@ -134,15 +134,15 @@ if Settings.forceDrainMsDelay? if Settings.continualPubsubTraffic console.log "continualPubsubTraffic enabled" - redisClients = [redis.createClient(Settings.redis.documentupdater), redis.createClient(Settings.redis.realtime)] + redisClients = [redis.createClient(Settings.redis.documentupdater), redis.createClient(Settings.redis.pubsub)] publishJob = (channel, callback)-> checker = new HealthCheckManager(channel) logger.debug {channel:channel}, "sending pub to keep connection alive" json = JSON.stringify({health_check:true, key: checker.id, date: new Date().toString()}) - jobs = _.map redisClients, (rclient)-> + jobs = _.map redisClients, (checkRclient)-> return (cb)-> - rclient.publish channel, json, (err)-> + checkRclient.publish channel, json, (err)-> if err? logger.err {err, channel}, "error publishing pubsub traffic to redis" return cb(err) From 520857cf7aed04f3324a84b1801dded1bb5af00d Mon Sep 17 00:00:00 2001 From: Henry Oswald Date: Mon, 8 Jul 2019 12:07:28 +0100 Subject: [PATCH 2/2] simplify redis continual traffic we can't send double health check events to same redis, it causes health check duplicate errors. Commit just sends health check data to pub sub pair and then sends non health check traffic to cluster to keep the connection open --- services/real-time/app.coffee | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/services/real-time/app.coffee b/services/real-time/app.coffee index ab45c525b4..4effc386df 100644 --- a/services/real-time/app.coffee +++ b/services/real-time/app.coffee @@ -134,20 +134,18 @@ if Settings.forceDrainMsDelay? if Settings.continualPubsubTraffic console.log "continualPubsubTraffic enabled" - redisClients = [redis.createClient(Settings.redis.documentupdater), redis.createClient(Settings.redis.pubsub)] + pubsubClient = redis.createClient(Settings.redis.pubsub) + clusterClient = redis.createClient(Settings.redis.websessions) publishJob = (channel, callback)-> checker = new HealthCheckManager(channel) logger.debug {channel:channel}, "sending pub to keep connection alive" json = JSON.stringify({health_check:true, key: checker.id, date: new Date().toString()}) - jobs = _.map redisClients, (checkRclient)-> - return (cb)-> - checkRclient.publish channel, json, (err)-> - if err? - logger.err {err, channel}, "error publishing pubsub traffic to redis" - return cb(err) + pubsubClient.publish channel, json, (err)-> + if err? + logger.err {err, channel}, "error publishing pubsub traffic to redis" + clusterClient.publish "cluster-continual-traffic", {keep: "alive"}, callback - async.series jobs, callback runPubSubTraffic = -> async.map ["applied-ops", "editor-events"], publishJob, (err)->