Skip to content

Commit

Permalink
blop2
Browse files Browse the repository at this point in the history
  • Loading branch information
fulmicoton committed May 24, 2024
1 parent f4835ea commit d5ea331
Show file tree
Hide file tree
Showing 3 changed files with 123 additions and 259 deletions.
36 changes: 8 additions & 28 deletions quickwit/quickwit-control-plane/src/control_plane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,23 +486,7 @@ fn convert_metastore_error<T>(
) -> Result<ControlPlaneResult<T>, ActorExitStatus> {
// If true, we know that the transactions has not been recorded in the Metastore.
// If false, we simply are not sure whether the transaction has been recorded or not.
let is_transaction_certainly_aborted = match &metastore_error {
MetastoreError::AlreadyExists(_)
| MetastoreError::FailedPrecondition { .. }
| MetastoreError::Forbidden { .. }
| MetastoreError::InvalidArgument { .. }
| MetastoreError::JsonDeserializeError { .. }
| MetastoreError::JsonSerializeError { .. }
| MetastoreError::NotFound(_)
| MetastoreError::TooManyRequests => true,

MetastoreError::Connection { .. }
| MetastoreError::Db { .. }
| MetastoreError::Internal { .. }
| MetastoreError::Io { .. }
| MetastoreError::Timeout { .. }
| MetastoreError::Unavailable(_) => false,
};
let is_transaction_certainly_aborted = metastore_error.is_transaction_certainly_aborted();
if is_transaction_certainly_aborted {
// If the metastore transaction is certain to have been aborted,
// this is actually a good thing.
Expand Down Expand Up @@ -781,29 +765,25 @@ impl Handler<GetOrCreateOpenShardsRequest> for ControlPlane {
request: GetOrCreateOpenShardsRequest,
ctx: &ActorContext<Self>,
) -> Result<Self::Reply, ActorExitStatus> {
// TODO This seems incorrect... Index creation could yield a metastore error... In that
// case, we end up with an inconsistent state.
if let Err(control_plane_error) = self
.auto_create_indexes(&request.subrequests, ctx.progress())
.await
{
return Ok(Err(control_plane_error));
}
let response = match self
match self
.ingest_controller
.get_or_create_open_shards(request, &mut self.model, ctx.progress())
.await
{
Ok(response) => response,
Err(ControlPlaneError::Metastore(metastore_error)) => {
return convert_metastore_error(metastore_error);
Ok(resp) => {
let _rebuild_plan_waiter = self.rebuild_plan_debounced(ctx);
Ok(Ok(resp))
}
Err(control_plane_error) => {
return Ok(Err(control_plane_error));
Err(metastore_error) => {
convert_metastore_error(metastore_error)
}
};
let _rebuild_plan_waiter = self.rebuild_plan_debounced(ctx);
Ok(Ok(response))
}
}
}

Expand Down
Loading

0 comments on commit d5ea331

Please sign in to comment.