From ee19f277dd7510c8b5bfe04fd864f5a06d0e647b Mon Sep 17 00:00:00 2001 From: Calvin Xiao Date: Fri, 31 Dec 2021 13:49:01 +0800 Subject: [PATCH] Update src/redis_connection.cc Co-authored-by: Wang Yuan --- src/redis_connection.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/redis_connection.cc b/src/redis_connection.cc index 3647ba44f8e..1dea7250d33 100644 --- a/src/redis_connection.cc +++ b/src/redis_connection.cc @@ -329,6 +329,10 @@ void Connection::ExecuteCommands(const std::vector &to_pro (config->cluster_enabled && cmd_name == "clusterx" && cmd_tokens.size() >= 2 && Cluster::SubCommandIsExecExclusive(cmd_tokens[1]))) { exclusivity = svr_->WorkExclusivityGuard(); + + // When executing lua script commands that have "exclusive" attribute, + // we need to know current connection, but we should set current connection + // after acquiring the WorkExclusivityGuard to make it thread-safe svr_->SetCurrentConnection(this); } else { concurrency = svr_->WorkConcurrencyGuard();