pub struct BulkInterrupted {
pub written: usize,
pub cause: DbError,
}Expand description
A chunked bulk write that stopped partway, and how much of it landed (0.13.8, W7.6, D-181).
The four chunked paths — crate::Database::bulk_import,
write_concepts, upsert_embeddings and
write_analytics_annotations — are atomic per chunk and not overall, so a
failure at row 19,000 of 20,000 leaves the first 18,000-odd rows committed.
Until 0.13.8 they returned a bare DbError and the caller was told only
that it failed: the count was computed, used to size the next chunk, and
dropped on the floor at the ?. A caller who then retried the whole batch
re-wrote everything that had already landed, and one who skipped it lost the
tail.
This is why those four return Result<usize, BulkInterrupted> rather than
Result. From<BulkInterrupted> for DbError exists so ? still works in
a function returning Result — that conversion is how a caller says the
count does not interest them, and it says so at the call site instead of
silently.
Fields§
§written: usizeRows the chunks that finished before the stop committed, and which are still committed. Zero is an ordinary value: the first chunk can fail.
cause: DbErrorWhy it stopped. DbError::BulkCancelled if the caller asked;
otherwise whatever the failing chunk raised, unchanged — this is not a
new error, it is the same one with the count attached.
Implementations§
Source§impl BulkInterrupted
impl BulkInterrupted
Sourcepub fn was_cancelled(&self) -> bool
pub fn was_cancelled(&self) -> bool
Whether the stop was the caller’s own cancellation rather than a fault.
Trait Implementations§
Source§impl Debug for BulkInterrupted
impl Debug for BulkInterrupted
Source§impl Display for BulkInterrupted
impl Display for BulkInterrupted
Source§impl Error for BulkInterrupted
impl Error for BulkInterrupted
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<BulkInterrupted> for DbError
impl From<BulkInterrupted> for DbError
Source§fn from(e: BulkInterrupted) -> Self
fn from(e: BulkInterrupted) -> Self
Discards written. That is the point: a caller writing ? into a
function returning Result has decided the partial count is not
something they will act on, and this puts that decision at the place it
is taken rather than inside the crate.
Auto Trait Implementations§
impl !RefUnwindSafe for BulkInterrupted
impl !UnwindSafe for BulkInterrupted
impl Freeze for BulkInterrupted
impl Send for BulkInterrupted
impl Sync for BulkInterrupted
impl Unpin for BulkInterrupted
impl UnsafeUnpin for BulkInterrupted
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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