From e083f3276c42a0015285bf00790d5c223920407b Mon Sep 17 00:00:00 2001 From: Dom Dwyer Date: Tue, 20 Dec 2022 15:13:58 +0100 Subject: [PATCH] feat(persist): accept concurrent matching updates As an optimisation, allow a persist task to progress if it observes a concurrent catalog sort key update that exactly matches the sort key it was committing. --- ingester2/src/persist/context.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ingester2/src/persist/context.rs b/ingester2/src/persist/context.rs index 3e1ffec53f..c6f0726ad4 100644 --- a/ingester2/src/persist/context.rs +++ b/ingester2/src/persist/context.rs @@ -340,6 +340,31 @@ impl Context { { Ok(_) => ControlFlow::Break(Ok(())), Err(CasFailure::QueryError(e)) => ControlFlow::Continue(e), + Err(CasFailure::ValueMismatch(observed)) + if observed == new_sort_key_str => + { + // A CAS failure occurred because of a concurrent + // sort key update, however the new catalog sort key + // exactly matches the sort key this node wants to + // commit. + // + // This is the sad-happy path, and this task can + // continue. + info!( + %object_store_id, + namespace_id = %self.namespace_id, + namespace_name = %self.namespace_name, + table_id = %self.table_id, + table_name = %self.table_name, + partition_id = %self.partition_id, + partition_key = %self.partition_key, + expected=?old_sort_key, + ?observed, + update=?new_sort_key_str, + "detected matching concurrent sort key update" + ); + ControlFlow::Break(Ok(())) + } Err(CasFailure::ValueMismatch(observed)) => { // Another ingester concurrently updated the sort // key.