Skip to content

Commit 59c1cd4

Browse files
committed
fix: breaker findings — stale placeholder cleanup, search fallback, backfill resilience
1 parent d1dff22 commit 59c1cd4

3 files changed

Lines changed: 26 additions & 10 deletions

File tree

crates/cli/src/commands/search.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ pub(crate) async fn run_backfill_metadata(batch_size: usize) -> Result<()> {
149149
let mut total_failed = 0_usize;
150150
let mut skipped_ids: Vec<String> = Vec::new();
151151
let placeholder = opencode_mem_core::ObservationMetadata::placeholder();
152+
let mut consecutive_no_progress: u32 = 0;
153+
const MAX_CONSECUTIVE_STALLS: u32 = 3;
152154

153155
loop {
154156
let observations = storage
@@ -205,7 +207,15 @@ pub(crate) async fn run_backfill_metadata(batch_size: usize) -> Result<()> {
205207
}
206208

207209
if !batch_progress {
208-
break;
210+
consecutive_no_progress += 1;
211+
if consecutive_no_progress >= MAX_CONSECUTIVE_STALLS {
212+
eprintln!(
213+
"Warning: {MAX_CONSECUTIVE_STALLS} consecutive batches with zero progress, stopping"
214+
);
215+
break;
216+
}
217+
} else {
218+
consecutive_no_progress = 0;
209219
}
210220
}
211221

crates/service/src/search_service/hybrid_ops.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,18 @@ impl SearchService {
9999
.storage
100100
.guarded(|| self.storage.hybrid_search_v2(query, &query_vec, limit))
101101
.await;
102-
self.with_cb(result)
103-
} else {
104-
let result = self
105-
.storage
106-
.guarded(|| self.storage.hybrid_search(query, limit))
107-
.await;
108-
self.with_cb(result)
102+
match self.with_cb(result) {
103+
Ok(results) => return Ok(results),
104+
Err(e) => {
105+
tracing::warn!(error = %e, "hybrid_search_v2 failed, falling back to text-only hybrid_search");
106+
}
107+
}
109108
}
109+
let result = self
110+
.storage
111+
.guarded(|| self.storage.hybrid_search(query, limit))
112+
.await;
113+
self.with_cb(result)
110114
}
111115

112116
async fn run_search_with_filters(
@@ -172,10 +176,10 @@ impl SearchService {
172176
self.with_cb(res)
173177
}
174178
Err(e) => {
175-
tracing::warn!(error = %e, "Semantic search failed, falling back to hybrid");
179+
tracing::warn!(error = %e, "Semantic search failed, falling back to text-only hybrid");
176180
let res = self
177181
.storage
178-
.guarded(|| self.storage.hybrid_search_v2(query, &query_vec, limit))
182+
.guarded(|| self.storage.hybrid_search(query, limit))
179183
.await;
180184
self.with_cb(res)
181185
}

crates/storage/src/pg_storage/summaries.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ impl SummaryStore for PgStorage {
225225
AND NOT EXISTS (
226226
SELECT 1 FROM session_summaries ss
227227
WHERE ss.session_id = o.session_id
228+
AND NOT (ss.learned = 'processing'
229+
AND ss.created_at < NOW() - INTERVAL '10 minutes')
228230
)
229231
GROUP BY o.session_id
230232
HAVING MAX(o.created_at) < NOW() - INTERVAL '1 hour' AND COUNT(*) >= 2

0 commit comments

Comments
 (0)