New CRON function in HA environment?

In reading your new blogpost about Lua triggering “CRONs” in KeyDB, i had a question about a multi master cluster. How do you or can you ensure only 1 server executes the command at each interval? Example, i have a master master instance, but only 1 execution needs to happen at every minute, which server would execute it? 1 or both? Or would we still need to use something like a keepalived check in the lua script for master / standby determination? Thoughts?

Thanks!

Hi @artusmode,

I am trying to understand a bit clearer what you are looking for/your concern… Do you have specific concerns regarding data integrity? If you don’t mind sharing, what kind of task are you doing that’s specific to only one server?

To try to add a bit of clarity regarding replication, the KEYDB.CRON functionality in this regards is similar to that of EXPIRE. If you are running regular master/replica set up, only the master node runs the Cron command. If you are running active replication, then both nodes will run the Cron command. Data however should not have issues (ie. will not increment a counter twice)
Are you looking to do something like this?

local info_server = redis.call('INFO', 'SERVER')
local tcp_port = (info_server:match("tcp_port:([^/]%d+)"))
if tcp_port == "7000" then
        --do something...
end

Or a different functionality? (as an FYI we are looking at an issue with KEYDB.CRON probing INFO as it seems to have an issue currently)