Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…into 175-handle-requests-going-to-replicas-with-no-sentinel-running
  • Loading branch information
MuhammadQadora committed Nov 25, 2024
2 parents 6035801 + 0258faa commit 2e602eb
Show file tree
Hide file tree
Showing 7 changed files with 163 additions and 41 deletions.
39 changes: 39 additions & 0 deletions chaos/cluster-load.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import redis from 'k6/experimental/redis';
import { check } from 'k6';
import exec from 'k6/execution';


const client = new redis.Client({
socket: {
dialTimeout: 5000,
readTimeout: 5000,
writeTimeout: 5000,
poolTimeout: 5000,
},
cluster: {
// Cluster options
maxRedirects: 3,
readOnly: true,
routeByLatency: true,
routeRandomly: true,
nodes: [
// Nodes URLs
]
},
});

export const options = {
stages: [
{ duration: '120s', target: 100 },
]
};

async function callServer() {
const vuId = exec.vu.idInTest;
const ok = await client.set(`a-${vuId}`, `${vuId}`).then(() => true).catch(() => false);
check(ok, { 'set command succeeded': (ok) => ok });
}

export default function () {
callServer();
}
38 changes: 38 additions & 0 deletions falkordb-cluster/node.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,45 @@
loadmodule /FalkorDB/bin/src/falkordb.so CACHE_SIZE $FALKORDB_CACHE_SIZE NODE_CREATION_BUFFER $FALKORDB_NODE_CREATION_BUFFER MAX_QUEUED_QUERIES $FALKORDB_MAX_QUEUED_QUERIES TIMEOUT_MAX $FALKORDB_TIMEOUT_MAX TIMEOUT_DEFAULT $FALKORDB_TIMEOUT_DEFAULT RESULTSET_SIZE $FALKORDB_RESULT_SET_SIZE QUERY_MEM_CAPACITY $FALKORDB_QUERY_MEM_CAPACITY
loglevel $LOG_LEVEL

#Enable tls for Redis Cluster Bus
tls-cluster no

# For maximum availability, it is possible to set the cluster-replica-validity-factor
# to a value of 0, which means, that replicas will always try to failover the
# master regardless of the last time they interacted with the master.
# (However they'll always try to apply a delay proportional to their
# offset rank).
#
# Zero is the only value able to guarantee that when all the partitions heal
# the cluster will always be able to continue.
#
cluster-replica-validity-factor 0
#Allows replicas to migrate to orphaned masters (masters with no replicas left)
# only if their masters remain with at least one replica
cluster-allow-replica-migration yes
cluster-migration-barrier 1
# If a hash slot is uncovered (no node serving it) the whole cluster
# becomes unhealthy and stops accepting queries.
cluster-require-full-coverage yes
# This prevents replicas from failing their masters
# can be forced by manual failover. (Replica should never be promoted to master)
cluster-replica-no-failover no
# Allows replicas to serve read queries in a cluster down state.
cluster-allow-reads-when-down no
# This feature should be kept as yes.
cluster-allow-pubsubshard-when-down yes
# Cluster link send buffer limit is the limit on the memory usage of an individual
# cluster bus link's send buffer in bytes. Cluster links would be freed if they exceed
# this limit. This is to primarily prevent send buffers from growing unbounded on links
# toward slow peers (E.g. PubSub messages being piled up).
# This limit is disabled by default. Enable this limit when 'mem_cluster_links' INFO field
# and/or 'send-buffer-allocated' entries in the 'CLUSTER LINKS` command output continuously increase.
# Minimum limit of 1gb is recommended so that cluster link buffer can fit in at least a single
# PubSub message by default. (client-query-buffer-limit default value is 1gb)
cluster-link-sendbuf-limit 0
# optional nodename to be used in addition to the node ID for
# debugging and admin information
cluster-announce-human-nodename ""
cluster-preferred-endpoint-type hostname
cluster-port 16379
cluster-enabled yes
Expand Down
9 changes: 9 additions & 0 deletions falkordb-node/node-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ FALKORDB_RESULT_SET_SIZE=${FALKORDB_RESULT_SET_SIZE:-10000}
FALKORDB_QUERY_MEM_CAPACITY=${FALKORDB_QUERY_MEM_CAPACITY:-0}
FALKORDB_TIMEOUT_MAX=${FALKORDB_TIMEOUT_MAX:-0}
FALKORDB_TIMEOUT_DEFAULT=${FALKORDB_TIMEOUT_DEFAULT:-0}
FALKORDB_VKEY_MAX_ENTITY_COUNT=${FALKORDB_VKEY_MAX_ENTITY_COUNT:-4611686000000000000}
MEMORY_LIMIT=${MEMORY_LIMIT:-''}
# If vars are <nil>, set it to 0
if [[ "$FALKORDB_QUERY_MEM_CAPACITY" == "<nil>" ]]; then
Expand Down Expand Up @@ -354,12 +355,19 @@ create_user() {
config_rewrite
}


config_rewrite() {
# Config rewrite
echo "Rewriting config"
redis-cli -p $NODE_PORT -a $ADMIN_PASSWORD --no-auth-warning $TLS_CONNECTION_STRING CONFIG REWRITE
}

set_configs() {
echo "Setting configs"
redis-cli -p $NODE_PORT -a $ADMIN_PASSWORD --no-auth-warning $TLS_CONNECTION_STRING GRAPH.CONFIG set VKEY_MAX_ENTITY_COUNT $FALKORDB_VKEY_MAX_ENTITY_COUNT
redis-cli -p $NODE_PORT -a $ADMIN_PASSWORD --no-auth-warning $TLS_CONNECTION_STRING GRAPH.CONFIG get VKEY_MAX_ENTITY_COUNT
}

if [ -f $NODE_CONF_FILE ]; then
# Get current admin password
CURRENT_ADMIN_PASSWORD=$(cat $NODE_CONF_FILE | grep -oP '(?<=requirepass ).*' | sed 's/\"//g')
Expand Down Expand Up @@ -443,6 +451,7 @@ if [ "$RUN_NODE" -eq "1" ]; then
sleep 10

create_user
set_configs

# If node should be master, add it to sentinel
if [[ $IS_REPLICA -eq 0 && $RUN_SENTINEL -eq 1 ]]; then
Expand Down
8 changes: 8 additions & 0 deletions omnistrate.enterprise.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,8 @@ services:
instanceTypes:
- cloudProvider: gcp
name: e2-small
- cloudProvider: aws
name: t3a.small
environment:
- RUN_NODE=0
- RUN_SENTINEL=1
Expand Down Expand Up @@ -1624,6 +1626,8 @@ services:
instanceTypes:
- cloudProvider: gcp
name: e2-small
- cloudProvider: aws
name: t3a.small
environment:
- RUN_NODE=0
- RUN_SENTINEL=1
Expand Down Expand Up @@ -1946,6 +1950,8 @@ services:
instanceTypes:
- cloudProvider: gcp
name: e2-small
- cloudProvider: aws
name: t3a.small
<<: *rebalanceparam
environment:
- IS_MULTI_ZONE=0
Expand Down Expand Up @@ -2251,6 +2257,8 @@ services:
instanceTypes:
- cloudProvider: gcp
name: e2-small
- cloudProvider: aws
name: t3a.small
<<: *rebalanceparam
environment:
- IS_MULTI_ZONE=1
Expand Down
8 changes: 8 additions & 0 deletions omnistrate.pro.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,8 @@ services:
instanceTypes:
- cloudProvider: gcp
name: e2-small
- cloudProvider: aws
name: t3a.small
environment:
- RUN_NODE=0
- RUN_SENTINEL=1
Expand Down Expand Up @@ -2218,6 +2220,8 @@ services:
instanceTypes:
- cloudProvider: gcp
name: e2-small
- cloudProvider: aws
name: t3a.small
environment:
- RUN_NODE=0
- RUN_SENTINEL=1
Expand Down Expand Up @@ -2566,6 +2570,8 @@ services:
instanceTypes:
- cloudProvider: gcp
name: e2-small
- cloudProvider: aws
name: t3a.small
<<: *rebalanceparam
environment:
- NODE_HOST=$sys.network.node.externalEndpoint
Expand Down Expand Up @@ -2877,6 +2883,8 @@ services:
instanceTypes:
- cloudProvider: gcp
name: e2-small
- cloudProvider: aws
name: t3a.small
<<: *rebalanceparam
environment:
- IS_MULTI_ZONE=1
Expand Down
Loading

0 comments on commit 2e602eb

Please sign in to comment.