Skip to content

Commit

Permalink
feat: refine meta election logic (risingwavelabs#7669)
Browse files Browse the repository at this point in the history
This PR refine a series of meta election related codes

1. meta's addr supports multiple addresses
2. meta client adds a meta address mode parameter to distinguish the behavior of election members found in loadbalance (kubernetes environment) and list (normal environment)

Approved-By: yezizp2012
  • Loading branch information
shanicky authored Feb 3, 2023
1 parent 496f7a9 commit 930b185
Show file tree
Hide file tree
Showing 21 changed files with 924 additions and 786 deletions.
13 changes: 8 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

157 changes: 87 additions & 70 deletions dashboard/proto/gen/meta.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 0 additions & 27 deletions proto/leader.proto

This file was deleted.

26 changes: 15 additions & 11 deletions proto/meta.proto
Original file line number Diff line number Diff line change
Expand Up @@ -255,17 +255,6 @@ service NotificationService {
rpc Subscribe(SubscribeRequest) returns (stream SubscribeResponse);
}

message MetaLeaderInfo {
string node_address = 1;
uint64 lease_id = 2;
}

message MetaLeaseInfo {
MetaLeaderInfo leader = 1;
uint64 lease_register_time = 2;
uint64 lease_expire_time = 3;
}

message PauseRequest {}

message PauseResponse {}
Expand Down Expand Up @@ -303,3 +292,18 @@ service ScaleService {
rpc GetClusterInfo(GetClusterInfoRequest) returns (GetClusterInfoResponse);
rpc Reschedule(RescheduleRequest) returns (RescheduleResponse);
}

message MembersRequest {}

message MetaMember {
common.HostAddress address = 1;
bool is_leader = 2;
}

message MembersResponse {
repeated MetaMember members = 1;
}

service MetaMemberService {
rpc Members(MembersRequest) returns (MembersResponse);
}
7 changes: 0 additions & 7 deletions src/common/src/util/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,9 @@ use std::net::SocketAddr;
use std::str::FromStr;

use risingwave_pb::common::HostAddress as ProstHostAddress;
use risingwave_pb::meta::MetaLeaderInfo;

use crate::error::{internal_error, Result};

pub fn leader_info_to_host_addr(mli: MetaLeaderInfo) -> HostAddr {
mli.node_address
.parse::<HostAddr>()
.expect("invalid leader addr")
}

/// General host address and port.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct HostAddr {
Expand Down
4 changes: 1 addition & 3 deletions src/meta/src/hummock/manager/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ use risingwave_pb::hummock::{
HummockVersionDelta, HummockVersionDeltas, HummockVersionStats, IntraLevelDelta, LevelType,
};
use risingwave_pb::meta::subscribe_response::{Info, Operation};
use risingwave_pb::meta::MetaLeaderInfo;
use tokio::sync::oneshot::Sender;
use tokio::sync::{Notify, RwLockReadGuard, RwLockWriteGuard};
use tokio::task::JoinHandle;
Expand Down Expand Up @@ -128,7 +127,7 @@ macro_rules! commit_multi_var {
$val_txn.apply_to_txn(&mut trx)?;
)*
// Commit to state store
$hummock_mgr.commit_trx($hummock_mgr.env.meta_store(), trx, $context_id, $hummock_mgr.env.get_leader_info())
$hummock_mgr.commit_trx($hummock_mgr.env.meta_store(), trx, $context_id)
.await?;
// Upon successful commit, commit the change to local in-mem state
$(
Expand Down Expand Up @@ -491,7 +490,6 @@ where
meta_store: &S,
trx: Transaction,
context_id: Option<HummockContextId>,
_info: MetaLeaderInfo,
) -> Result<()> {
if let Some(context_id) = context_id {
if context_id == META_NODE_ID {
Expand Down
Loading

0 comments on commit 930b185

Please sign in to comment.