From 2ff2a77465646c2e1553418d258477c294c9ae91 Mon Sep 17 00:00:00 2001 From: Bartosz Sypytkowski Date: Tue, 25 Jun 2024 07:22:38 +0200 Subject: [PATCH] fix: do not throw errors if indexer found document before workspace was created --- .../src/index/collab_embeddings_ops.rs | 22 ++++++++++++++----- services/appflowy-indexer/src/consumer.rs | 2 +- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/libs/database/src/index/collab_embeddings_ops.rs b/libs/database/src/index/collab_embeddings_ops.rs index a96b5ca0..79f53c32 100644 --- a/libs/database/src/index/collab_embeddings_ops.rs +++ b/libs/database/src/index/collab_embeddings_ops.rs @@ -2,7 +2,7 @@ use std::ops::DerefMut; use collab_entity::CollabType; use pgvector::Vector; -use sqlx::{Executor, Postgres, Transaction}; +use sqlx::{Error, Executor, Postgres, Transaction}; use uuid::Uuid; use database_entity::dto::AFCollabEmbeddingParams; @@ -27,11 +27,23 @@ WHERE c.oid = $1"#, oid ) .fetch_one(tx.deref_mut()) - .await?; - if result.disable_search_indexing.unwrap_or(false) { - return Ok(None); + .await; + match result { + Ok(row) => { + if row.disable_search_indexing.unwrap_or(false) { + return Ok(None); + } + Ok(Some(row.has_index.unwrap_or(false))) + }, + Err(Error::RowNotFound) => { + tracing::warn!( + "open-collab event for {} arrived before its workspace was created", + oid + ); + Ok(Some(false)) + }, + Err(e) => Err(e), } - Ok(Some(result.has_index.unwrap_or(false))) } pub async fn upsert_collab_embeddings( diff --git a/services/appflowy-indexer/src/consumer.rs b/services/appflowy-indexer/src/consumer.rs index d2a59495..4ea3b76f 100644 --- a/services/appflowy-indexer/src/consumer.rs +++ b/services/appflowy-indexer/src/consumer.rs @@ -240,8 +240,8 @@ impl OpenCollabConsumer { Err(e) => { tracing::error!( "failed to open handle for {}/{}: {}", - object_id, workspace_id, + object_id, e ); },