Skip to content

Commit

Permalink
Fix dirty cluster config read
Browse files Browse the repository at this point in the history
  • Loading branch information
JackyWoo committed Jan 4, 2024
1 parent afd9d2d commit 1e811b0
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/Service/ConnectionHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ Coordination::OpNum ConnectionHandler::receiveHandshake(int32_t handshake_req_le
Coordination::ZooKeeperRequestPtr request = Coordination::ZooKeeperRequestFactory::instance().get(opnum);

/// Generate id for new session request and use session_id for update session request
auto id = opnum == OpNum::NewSession ? keeper_dispatcher->getNewSessionInternalId() : previous_session_id;
auto id = opnum == OpNum::NewSession ? keeper_dispatcher->getAndAddInternalId() : previous_session_id;

if (opnum == OpNum::NewSession)
{
Expand Down
11 changes: 0 additions & 11 deletions src/Service/ConnectionHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,6 @@ class ConnectionHandler
void resetStats();

private:
/// client hand shake result
struct HandShakeResult
{
/// handshake result
bool connect_success{};
bool session_expired{};

/// whether is reconnected request
bool is_reconnected{};
};

Coordination::OpNum receiveHandshake(int32_t handshake_length);
static bool isHandShake(Int32 & handshake_length);

Expand Down
1 change: 0 additions & 1 deletion src/Service/KeeperDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ KeeperDispatcher::KeeperDispatcher()
, request_processor(std::make_shared<RequestProcessor>(responses_queue))
, request_accumulator(request_processor)
, request_forwarder(request_processor)
, new_session_internal_id_counter(1)
{
}

Expand Down
8 changes: 4 additions & 4 deletions src/Service/KeeperDispatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,15 @@ class KeeperDispatcher : public std::enable_shared_from_this<KeeperDispatcher>
/// Request to be leader
bool requestLeader() { return server->requestLeader(); }

/// return process start time in us.
/// Return process start time in us.
int64_t uptimeFromStartup() { return Poco::Timestamp() - uptime; }

/// My server id
int32_t myId() const { return server->myId(); }

/// When user create new session, we use this id as request id.
/// Note that the internal id for different nodes can be same.
int64_t getNewSessionInternalId() { return new_session_internal_id_counter.fetch_add(server->getClusterNodeCount()); }
/// When user creating new session, we use this id as fake session id.
/// Note that the internal id for different nodes can not be same.
int64_t getAndAddInternalId() { return new_session_internal_id_counter.fetch_add(server->getClusterNodeCount()); }
};

}
1 change: 1 addition & 0 deletions src/Service/NuRaftStateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ ConfigUpdateActions NuRaftStateManager::getConfigurationDiff(const Poco::Util::A

size_t NuRaftStateManager::getClusterNodeCount() const
{
std::lock_guard<std::mutex> lock(cluster_config_mutex);
return cur_cluster_config->get_servers().size();
}

Expand Down

0 comments on commit 1e811b0

Please sign in to comment.