Struct mz_txn_wal::txn_write::Txn
source · pub struct Txn<K, V, T, D> {
pub(crate) writes: BTreeMap<ShardId, TxnWrite<K, V, T, D>>,
tidy: Tidy,
}
Expand description
An in-progress transaction.
Fields§
§writes: BTreeMap<ShardId, TxnWrite<K, V, T, D>>
§tidy: Tidy
Implementations§
source§impl<K, V, T, D> Txn<K, V, T, D>
impl<K, V, T, D> Txn<K, V, T, D>
pub(crate) fn new() -> Self
sourcepub async fn write(&mut self, data_id: &ShardId, key: K, val: V, diff: D)
pub async fn write(&mut self, data_id: &ShardId, key: K, val: V, diff: D)
Stage a write to the in-progress txn.
The timestamp will be assigned at commit time.
TODO: Allow this to spill to s3 (for bounded memory) once persist can make the ts rewrite op efficient.
sourcepub async fn commit_at<O, C>(
&mut self,
handle: &mut TxnsHandle<K, V, T, D, O, C>,
commit_ts: T,
) -> Result<TxnApply<T>, T>
pub async fn commit_at<O, C>( &mut self, handle: &mut TxnsHandle<K, V, T, D, O, C>, commit_ts: T, ) -> Result<TxnApply<T>, T>
Commit this transaction at commit_ts
.
This either atomically commits all staged writes or, if that’s no longer possible at the requested timestamp, returns an error with the least commit-able timestamp.
On success a token is returned representing apply work expected to be promptly performed by the caller. At this point, the txn is durable and it’s safe to bubble up success, but reads at the commit timestamp will block until this apply work finishes. In the event of a crash, neither correctness nor liveness require this followup be done.
Panics if any involved data shards were not registered before commit ts.
sourcepub fn tidy(&mut self, tidy: Tidy)
pub fn tidy(&mut self, tidy: Tidy)
Merges the work represented by given tidy into this txn.
If this txn commits, the tidy work will be written at the commit ts.
sourcepub fn take_tidy(&mut self) -> Tidy
pub fn take_tidy(&mut self) -> Tidy
Extracts any tidy work that has been merged into this txn with Self::tidy.
Trait Implementations§
Auto Trait Implementations§
impl<K, V, T, D> Freeze for Txn<K, V, T, D>
impl<K, V, T, D> !RefUnwindSafe for Txn<K, V, T, D>
impl<K, V, T, D> Send for Txn<K, V, T, D>
impl<K, V, T, D> Sync for Txn<K, V, T, D>
impl<K, V, T, D> Unpin for Txn<K, V, T, D>
impl<K, V, T, D> !UnwindSafe for Txn<K, V, T, D>
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
.source§impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
source§fn plus_equals(&mut self, rhs: &&'a S)
fn plus_equals(&mut self, rhs: &&'a S)
std::ops::AddAssign
, for types that do not implement AddAssign
.