Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/cluster/RedisDatastore.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class RedisDatastore {
.then(() => {
if (!this._disconnecting) {
this.heartbeat = setInterval(() => {
return this.runScript("heartbeat", []).catch((e) => {
return this.runScript("heartbeat", [this.instance.queued()]).catch((e) => {
if (!this._disconnecting) {
this.instance.Events.trigger("error", e);
}
Expand Down Expand Up @@ -135,7 +135,12 @@ class RedisDatastore {
e.message.match(/^(.*\s)?SETTINGS_KEY_NOT_FOUND$/) !== null
) {
if (name === "heartbeat") {
return undefined;
if (this.instance.queued() > 0) {
await this.runScript("init", this.prepareInitSettings(false));
await this.runScript("register_client", [this.instance.queued()]);
await this.instance._drainAll();
}
return;
}
await this.runScript("init", this.prepareInitSettings(false));
return this.runScript(name, args);
Expand Down
2 changes: 1 addition & 1 deletion src/cluster/Scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const templates = {
heartbeat: {
keys: exports.allKeys,
headers: ["validate_keys", "validate_client", "process_tick"],
refresh_expiration: false,
refresh_expiration: true,
code: lua["heartbeat.lua"],
},
update_settings: {
Expand Down
7 changes: 7 additions & 0 deletions src/cluster/lua/heartbeat.lua
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
local queued = tonumber(ARGV[num_static_argv + 1])

local groupTimeout = tonumber(redis.call('hget', settings_key, 'groupTimeout'))
if groupTimeout ~= nil and queued > 0 then
refresh_expiration(now, now, groupTimeout)
end

process_tick(now, true)