Skip to content

[ReplicatedLoglet] Implement remote sequencer find tail #2017

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion crates/bifrost/src/loglet/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use std::fmt::Debug;
use std::sync::Arc;

use restate_core::ShutdownError;
use restate_core::{network::NetworkError, ShutdownError};
use restate_types::errors::{IntoMaybeRetryable, MaybeRetryableError};

#[derive(Debug, Clone, thiserror::Error)]
Expand Down Expand Up @@ -68,3 +68,13 @@ impl From<OperationError> for AppendError {
}
}
}

impl From<NetworkError> for OperationError {
fn from(value: NetworkError) -> Self {
match value {
NetworkError::Shutdown(err) => OperationError::Shutdown(err),
// todo(azmy): are all network errors retryable?
_ => OperationError::retryable(value),
}
}
}
4 changes: 4 additions & 0 deletions crates/bifrost/src/loglet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,10 @@ impl LogletCommitResolver {
pub fn offset(self, offset: LogletOffset) {
let _ = self.tx.send(Ok(offset));
}

pub fn error(self, err: AppendError) {
let _ = self.tx.send(Err(err));
}
}

pub struct LogletCommit {
Expand Down
20 changes: 12 additions & 8 deletions crates/bifrost/src/providers/replicated_loglet/loglet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ use crate::providers::replicated_loglet::tasks::SealTask;

use super::log_server_manager::RemoteLogServerManager;
use super::record_cache::RecordCache;
use super::remote_sequencer::RemoteSequencer;
use super::rpc_routers::{LogServersRpc, SequencersRpc};

#[derive(derive_more::Debug)]
Expand Down Expand Up @@ -95,7 +96,14 @@ impl<T: TransportConnect> ReplicatedLoglet<T> {
}
} else {
SequencerAccess::Remote {
sequencers_rpc: sequencers_rpc.clone(),
handle: RemoteSequencer::new(
log_id,
segment_index,
my_params.clone(),
networking.clone(),
known_global_tail.clone(),
sequencers_rpc.clone(),
),
}
};
Ok(Self {
Expand All @@ -116,7 +124,7 @@ impl<T: TransportConnect> ReplicatedLoglet<T> {
pub enum SequencerAccess<T> {
/// The sequencer is remote (or retired/preempted)
#[debug("Remote")]
Remote { sequencers_rpc: SequencersRpc },
Remote { handle: RemoteSequencer<T> },
/// We are the loglet leaders
#[debug("Local")]
Local { handle: Sequencer<T> },
Expand All @@ -143,18 +151,14 @@ impl<T: TransportConnect> Loglet for ReplicatedLoglet<T> {
async fn enqueue_batch(&self, payloads: Arc<[Record]>) -> Result<LogletCommit, OperationError> {
match self.sequencer {
SequencerAccess::Local { ref handle } => handle.enqueue_batch(payloads).await,
SequencerAccess::Remote { .. } => {
todo!("Access to remote sequencers is not implemented yet")
}
SequencerAccess::Remote { ref handle } => handle.append(payloads).await,
}
}

async fn find_tail(&self) -> Result<TailState<LogletOffset>, OperationError> {
match self.sequencer {
SequencerAccess::Local { .. } => Ok(*self.known_global_tail.get()),
SequencerAccess::Remote { .. } => {
todo!("find_tail() is not implemented yet")
}
SequencerAccess::Remote { ref handle } => handle.find_tail().await,
}
}

Expand Down
2 changes: 2 additions & 0 deletions crates/bifrost/src/providers/replicated_loglet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ mod network;
mod provider;
#[allow(dead_code)]
mod record_cache;
#[allow(dead_code)]
mod remote_sequencer;
pub mod replication;
mod rpc_routers;
#[allow(dead_code)]
Expand Down
Loading
Loading