Struct mz_adapter::coord::timeline::DurableTimestampOracle
source · pub struct DurableTimestampOracle<T> {
timestamp_oracle: TimestampOracle<T>,
durable_timestamp: T,
persist_interval: T,
}
Expand description
A type that wraps a TimestampOracle
and provides durable timestamps. This allows us to
recover a timestamp that is larger than all previous timestamps on restart. The protocol
is based on timestamp recovery from Percolator https://research.google/pubs/pub36726/. We
“pre-allocate” a group of timestamps at once, and only durably store the largest of those
timestamps. All timestamps within that interval can be served directly from memory, without
going to disk. On restart, we re-initialize the current timestamp to a value one larger
than the persisted timestamp.
See TimestampOracle
for more details on the properties of the timestamps.
Fields§
§timestamp_oracle: TimestampOracle<T>
§durable_timestamp: T
§persist_interval: T
Implementations§
source§impl<T: TimestampManipulation> DurableTimestampOracle<T>
impl<T: TimestampManipulation> DurableTimestampOracle<T>
sourcepub(crate) async fn new<F, Fut>(
initially: T,
next: F,
persist_interval: T,
persist_fn: impl FnOnce(T) -> Fut
) -> Selfwhere
F: Fn() -> T + 'static,
Fut: Future<Output = Result<(), Error>>,
pub(crate) async fn new<F, Fut>( initially: T, next: F, persist_interval: T, persist_fn: impl FnOnce(T) -> Fut ) -> Selfwhere F: Fn() -> T + 'static, Fut: Future<Output = Result<(), Error>>,
Create a new durable timeline, starting at the indicated time. Timestamps will be
allocated in groups of size persist_interval
. Also returns the new timestamp that
needs to be persisted to disk.
See TimestampOracle::new
for more details.
sourceasync fn write_ts<Fut>(
&mut self,
persist_fn: impl FnOnce(T) -> Fut
) -> WriteTimestamp<T>where
Fut: Future<Output = Result<(), Error>>,
async fn write_ts<Fut>( &mut self, persist_fn: impl FnOnce(T) -> Fut ) -> WriteTimestamp<T>where Fut: Future<Output = Result<(), Error>>,
Acquire a new timestamp for writing. Optionally returns a timestamp that needs to be persisted to disk.
See TimestampOracle::write_ts
for more details.
sourceasync fn peek_write_ts(&self) -> T
async fn peek_write_ts(&self) -> T
Peek current write timestamp.
sourcepub async fn read_ts(&self) -> T
pub async fn read_ts(&self) -> T
Acquire a new timestamp for reading. Optionally returns a timestamp that needs to be persisted to disk.
See TimestampOracle::read_ts
for more details.
sourcepub async fn apply_write<Fut>(
&mut self,
lower_bound: T,
persist_fn: impl FnOnce(T) -> Fut
)where
Fut: Future<Output = Result<(), Error>>,
pub async fn apply_write<Fut>( &mut self, lower_bound: T, persist_fn: impl FnOnce(T) -> Fut )where Fut: Future<Output = Result<(), Error>>,
Mark a write at write_ts
completed.
See TimestampOracle::apply_write
for more details.
sourceasync fn maybe_allocate_new_timestamps<Fut>(
&mut self,
ts: &T,
persist_fn: impl FnOnce(T) -> Fut
)where
Fut: Future<Output = Result<(), Error>>,
async fn maybe_allocate_new_timestamps<Fut>( &mut self, ts: &T, persist_fn: impl FnOnce(T) -> Fut )where Fut: Future<Output = Result<(), Error>>,
Checks to see if we can serve the timestamp from memory, or if we need to durably store a new timestamp.
If ts
is less than the persisted timestamp then we can serve ts
from memory,
otherwise we need to durably store some timestamp greater than ts
.
Auto Trait Implementations§
impl<T> !RefUnwindSafe for DurableTimestampOracle<T>
impl<T> !Send for DurableTimestampOracle<T>
impl<T> !Sync for DurableTimestampOracle<T>
impl<T> Unpin for DurableTimestampOracle<T>where T: Unpin,
impl<T> !UnwindSafe for DurableTimestampOracle<T>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
source§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<P, R> ProtoType<R> for Pwhere
R: RustType<P>,
impl<P, R> ProtoType<R> for Pwhere R: RustType<P>,
source§fn into_rust(self) -> Result<R, TryFromProtoError>
fn into_rust(self) -> Result<R, TryFromProtoError>
RustType::from_proto
.source§fn from_rust(rust: &R) -> P
fn from_rust(rust: &R) -> P
RustType::into_proto
.