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

A way to increase replication factor for a group of streams (like rabbitmq-queues grow for QQs) #9536

Closed
zlepper opened this issue Sep 26, 2023 · 3 comments

Comments

@zlepper
Copy link

zlepper commented Sep 26, 2023

Is your feature request related to a problem? Please describe.

We had a rabbitmq system of 1 node with existing Streams running. To increase the availability of the system we expanded it to 3 nodes. Howeve we had to manually increase the replication factor of the existing streams (as per the docs). However i haven't been able to find an "easy" way of doing it, short of some creative bash scripting.

Someone on Discord recommended i made an issue here on GitHub, both to help other people in the future and maybe to highlight something missing :)

Describe the solution you'd like

A command on rabbitmq-streams to increase replication factor of a stream/all streams, without having to list the nodes to replicate to.

Describe alternatives you've considered

I have hacked together a possibly very bad and horrible bash script to do it:

#!/bin/bash

set -e

nodes=("rabbit@digi-rabbitmq-cluster-server-0.digi-rabbitmq-cluster-nodes.rabbitmq" "rabbit@digi-rabbitmq-cluster-server-1.digi-rabbitmq-cluster-nodes.rabbitmq" "rabbit@digi-rabbitmq-cluster-server-2.digi-rabbitmq-cluster-nodes.rabbitmq")

mapfile -t vhosts < <(rabbitmqctl list_vhosts name --silent | grep "digizuite-" )
 
for vhost in "${vhosts[@]}"
do
    echo "Fixing vhost $vhost"
    mapfile -t fanout_queues < <(rabbitmqctl list_queues -p "$vhost" members,name --silent | grep -E ".fanout$")
    
    for queue in "${fanout_queues[@]}"
    do
      queue_name=$(echo "$queue" | grep -o -E "\\S+$")
      
      echo "Fixing queue $queue_name"
      for node in "${nodes[@]}"
      do
        
        if [[ "$queue" != *"$node"* ]]
        then
          echo "Adding replica for $queue_name on $node"
          rabbitmq-streams add_replica --vhost "$vhost" "$queue_name" "$node"
        fi
      done
      
    done
done

I couldn't find a way to get the list of the nodes in the cluster from the cli, so had to hardcode the names for now.

Note this script will sometimes give the following warnings:

Error:
{:disallowed, :out_of_sync_replica}

Apparently you can just try again until they stop appearing.

Additional context

No response

@michaelklishin
Copy link
Member

So you are looking for a rabbitmq-queues grow alternative for streams?

@michaelklishin michaelklishin changed the title Easier way to increase replication factor of existing streams A way to increase replication factor for a group of streams (like rabbitmq-queues grow for QQs) Sep 26, 2023
@zlepper
Copy link
Author

zlepper commented Sep 26, 2023

So you are looking for a rabbitmq-queues grow alternative for streams?

Yup, if I read the docs correctly :)

@michaelklishin
Copy link
Member

michaelklishin commented Apr 19, 2024

Closing as not currently planned because there is no consensus on the team about this feature and highly dynamic replica management for streams, see #10830.

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

No branches or pull requests

2 participants