{"record":{"id":"d9f6a95367df80eb","repo":"redis/redis-rb","slug":"mapped-mset-cannot-be-used-in-redis-distributed-b","errorCode":null,"errorMessage":"MAPPED_MSET cannot be used in Redis::Distributed because the keys involved need to be on the same server or because we cannot guarantee that the operation will be atomic.","messagePattern":"MAPPED_MSET cannot be used in Redis::Distributed because the keys involved need to be on the same server or because we cannot guarantee that the operation will be atomic\\.","errorType":"exception","errorClass":"Redis::Distributed::CannotDistribute","httpStatus":null,"severity":"error","filePath":"lib/redis/distributed.rb","lineNumber":331,"sourceCode":"    end\n\n    # Set the time to live in milliseconds of a key.\n    def psetex(key, ttl, value)\n      node_for(key).psetex(key, ttl, value)\n    end\n\n    # Set the value of a key, only if the key does not exist.\n    def setnx(key, value)\n      node_for(key).setnx(key, value)\n    end\n\n    # Set multiple keys to multiple values.\n    def mset(*)\n      raise CannotDistribute, :mset\n    end\n\n    def mapped_mset(_hash)\n      raise CannotDistribute, :mapped_mset\n    end\n\n    # Set multiple keys to multiple values, only if none of the keys exist.\n    def msetnx(*)\n      raise CannotDistribute, :msetnx\n    end\n\n    def mapped_msetnx(_hash)\n      raise CannotDistribute, :mapped_msetnx\n    end\n\n    # Get the value of a key.\n    def get(key)\n      node_for(key).get(key)\n    end\n\n    # Get the value of a key and delete it.\n    def getdel(key)","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/redis/redis-rb/blob/2ba9010b91dab9e0fde1fbae3a9aae003f8bc307/lib/redis/distributed.rb#L313-L349","documentation":"Error \"MAPPED_MSET cannot be used in Redis::Distributed because the keys involved need to be on the same server or because we cannot guarantee that the operation will be atomic.\" thrown in redis/redis-rb.","triggerScenarios":"Thrown at lib/redis/distributed.rb:331 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Do not use mapped_mset on Redis::Distributed; the keys may hash to different servers.","Iterate the hash and call set for each key/value pair so routing stays per-key."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2ba9010b91dab9e0fde1fbae3a9aae003f8bc307","analyzedAt":"2026-08-23T03:54:57.017Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}