diff --git a/src/cluster.cpp b/src/cluster.cpp index a28a1ddcc..e8eec9ee9 100644 --- a/src/cluster.cpp +++ b/src/cluster.cpp @@ -2182,27 +2182,14 @@ void clusterWriteHandler(connection *conn) { clusterLink *link = (clusterLink*)connGetPrivateData(conn); ssize_t nwritten; - // We're about to release the lock, so the link's sndbuf needs to be owned fully by us - // allocate a new one in case anyone tries to write while we're waiting - sds sndbuf = link->sndbuf; - link->sndbuf = sdsempty(); - - aeReleaseLock(); nwritten = connWrite(conn, link->sndbuf, sdslen(link->sndbuf)); - aeAcquireLock(); - if (nwritten <= 0) { serverLog(LL_DEBUG,"I/O error writing to node link: %s", (nwritten == -1) ? connGetLastError(conn) : "short write"); - sdsfree(sndbuf); handleLinkIOError(link); return; } - sdsrange(sndbuf,nwritten,-1); - // Restore our send buffer, ensuring any unsent data is first - sndbuf = sdscat(sndbuf, link->sndbuf); - sdsfree(link->sndbuf); - link->sndbuf = sndbuf; + sdsrange(link->sndbuf,nwritten,-1); if (sdslen(link->sndbuf) == 0) connSetWriteHandler(link->conn, NULL); } @@ -2324,7 +2311,11 @@ void clusterReadHandler(connection *conn) { void clusterSendMessage(clusterLink *link, unsigned char *msg, size_t msglen) { serverAssert(GlobalLocksAcquired()); if (sdslen(link->sndbuf) == 0 && msglen != 0) - connSetWriteHandlerWithBarrier(link->conn, clusterWriteHandler, 1); + { + aePostFunction(g_pserver->rgthreadvar[IDX_EVENT_LOOP_MAIN].el, [link] { + connSetWriteHandlerWithBarrier(link->conn, clusterWriteHandler, 1); + }); + } link->sndbuf = sdscatlen(link->sndbuf, msg, msglen); diff --git a/utils/create-cluster/README b/utils/create-cluster/README index 2ecce53db..c5d883b2e 100644 --- a/utils/create-cluster/README +++ b/utils/create-cluster/README @@ -15,13 +15,8 @@ To create a cluster, follow these steps: 1. Edit create-cluster and change the start / end port, depending on the number of instances you want to create. 2. Use "./create-cluster start" in order to run the instances. -<<<<<<< HEAD 3. Use "./create-cluster create" in order to execute keydb-cli --cluster create, so that -an actual Redis cluster will be created. -======= -3. Use "./create-cluster create" in order to execute redis-cli --cluster create, so that -an actual Redis cluster will be created. (If you're accessing your setup via a local container, ensure that the CLUSTER_HOST value is changed to your local IP) ->>>>>>> redis/6.0 +an actual KeyDB cluster will be created. (If you're accessing your setup via a local container, ensure that the CLUSTER_HOST value is changed to your local IP) 4. Now you are ready to play with the cluster. AOF files and logs for each instances are created in the current directory. In order to stop a cluster: diff --git a/utils/create-cluster/create-cluster b/utils/create-cluster/create-cluster index 67fbfcb58..ce1f0cc52 100755 --- a/utils/create-cluster/create-cluster +++ b/utils/create-cluster/create-cluster @@ -25,11 +25,7 @@ then while [ $((PORT < ENDPORT)) != "0" ]; do PORT=$((PORT+1)) echo "Starting $PORT" -<<<<<<< HEAD - ../../src/keydb-server --port $PORT --cluster-enabled yes --cluster-config-file nodes-${PORT}.conf --cluster-node-timeout $TIMEOUT --appendonly yes --appendfilename appendonly-${PORT}.aof --dbfilename dump-${PORT}.rdb --logfile ${PORT}.log --daemonize yes -======= - ../../src/redis-server --port $PORT --protected-mode $PROTECTED_MODE --cluster-enabled yes --cluster-config-file nodes-${PORT}.conf --cluster-node-timeout $TIMEOUT --appendonly yes --appendfilename appendonly-${PORT}.aof --dbfilename dump-${PORT}.rdb --logfile ${PORT}.log --daemonize yes ${ADDITIONAL_OPTIONS} ->>>>>>> redis/6.0 + ../../src/keydb-server --port $PORT --protected-mode $PROTECTED_MODE --cluster-enabled yes --cluster-config-file nodes-${PORT}.conf --cluster-node-timeout $TIMEOUT --appendonly yes --appendfilename appendonly-${PORT}.aof --dbfilename dump-${PORT}.rdb --logfile ${PORT}.log --daemonize yes ${ADDITIONAL_OPTIONS} done exit 0 fi