Skip to content

Follow-up on `SCAN` command from "WIP: POC to fix multiprocess problem"

The following discussion from !2 (merged) should be addressed:

  • @mkozono started a discussion: (+1 comment)

    The scan_each line discussion is unrelated to the following, so I'm opening a separate discussion on the MR.

    the clean up is race-safe but the SCAN call is expensive

    Just some ideas since the SCAN is somewhat of a pain point. If it was cheap, we could clean working queues frequently without cost, and get rid of this method.

    Solution 1

    What if we registered a list of working queues? Then clean_working_queues! can test a limited number of keys, which is relatively very fast. This is added complexity, but the concept is pretty boring.

    Solution 2a

    What if we registered a list of processes? Then clean_working_queues! can check the heartbeat of all registered processes and clean all possible queues of dead processes. Also boring. But the list of queues can change per release so there's potential for losing orphans across a release, I'm not sure how to handle that.

    Solution 2b

    On heartbeat, instead of setting an expiring key, update a timestamp in a hash of processes and their last heartbeats. Then clean_working_queues! can find all processes whose timestamp is old, and clean all possible queues of those processes. This might potentially be less code than the other two because it doubles up the utility of the heartbeat. But maybe it's confusing.