Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UNWATCH for redis cluster #955

Open
mdimas opened this issue Nov 2, 2020 · 1 comment
Open

UNWATCH for redis cluster #955

mdimas opened this issue Nov 2, 2020 · 1 comment

Comments

@mdimas
Copy link

mdimas commented Nov 2, 2020

Since watch takes a keys(s) it appears to be supported on redis cluster, but unwatch raises an AmbiguousNodeError since there is no key specified. Is there a reason why unwatch could not be implemented to get called on all nodes?

@supercaracal
Copy link
Contributor

supercaracal commented Nov 3, 2020

Hello,

I think that there is a performance issue if cluster has thousand of nodes. But certainly we can send the command to all nodes without errors.

when 'discard', 'exec', 'multi', 'unwatch'
raise AmbiguousNodeError, cmd

In client-side-distributed feature case, we can use unwatch command if we specified keys by watch command.

# Watch the given keys to determine execution of the MULTI/EXEC block.
def watch(*keys, &block)
ensure_same_node(:watch, keys) do |node|
@watch_key = key_tag(keys.first) || keys.first.to_s
begin
node.watch(*keys, &block)
rescue StandardError
@watch_key = nil
raise
end
end
end
# Forget about all watched keys.
def unwatch
raise CannotDistribute, :unwatch unless @watch_key
result = node_for(@watch_key).unwatch
@watch_key = nil
result
end

Also, redis-cluster-proxy supports unwatch command.

UNWATCH (disables multiplexing)

https://github.com/RedisLabs/redis-cluster-proxy/blob/f8dc227a07f4a738b5fd211501bd521f32f1fcbd/COMMANDS.md

So it seems that there is room for improvement for cluster mode in our gem.

def test_unwatch
assert_raises(Redis::Cluster::AmbiguousNodeError) do
redis.unwatch
end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants