dmtrKovalenko/fff · warning
Failed to get historical query
Error message
Failed to get historical query: {} What it means
fff_get_historical_query fetches a past query from the query tracker; if tracker.get_historical_query returns Err (a database read failure), this error message is returned. Note Ok(None) is not an error — it returns an empty result — so this fires only on actual DB errors.
Solutions
- Check the inner error payload for the database failure reason.
- Verify the query history DB files exist and are readable by the process.
- Recreate the query history database if it is corrupted (history is expendable).
- Retry after a short delay if a concurrent writer held the lock.
- Fall back to empty history in the UI instead of surfacing an error.
Example fix
null
Defensive patterns
Strategy: fallback
Try / catch
local res = fff.get_historical_query(inst, project, 0)
if res.is_err or res.is_empty then history = {} end -- degrade gracefully Prevention
- Guard the DB files against deletion/corruption between sessions.
- Verify DB directory permissions after deployment changes.
- Show empty history instead of an error when the DB read fails.
When it happens
Trigger: Calling fff_get_historical_query when the underlying query-history database read fails: corrupted LMDB file, I/O error, permission denied on the DB, or lock contention with a concurrent writer.
Common situations: Query history database deleted or corrupted between sessions; DB directory permissions changed; reading history while another process holds the LMDB write lock; disk I/O errors.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- Failed to track query
- Failed to init frecency db
- Failed to init query tracker db
- fff native library not found. Run `npx @ff-labs/fff-node…
- fff native library not found. Run `npx @ff-labs/fff-node…
AI-assisted analysis of dmtrKovalenko/fff@7f8537e70f (2026-09-10).
Data as JSON: /api/errors/e0a2178e45c265a2.
Report an issue: GitHub.
Appendix: source
Thrown at crates/fff-c/src/lib.rs:1150
Some(p) => p.base_path().to_path_buf(),
None => return FffResult::ok_empty(),
}
};
let qt_guard = match inst.query_tracker.read() {
Ok(q) => q,
Err(_) => return FffResult::ok_empty(),
};
let tracker = match qt_guard.as_ref() {
Some(t) => t,
None => return FffResult::ok_empty(),
};
match tracker.get_historical_query(&project_path, offset as usize) {
Ok(Some(query)) => FffResult::ok_string(&query),
Ok(None) => FffResult::ok_empty(),
Err(e) => FffResult::err(&format!("Failed to get historical query: {}", e)),
}
}
/// Get health check information.
///
/// ## Safety
/// * `fff_handle` must be a valid instance pointer from `fff_create_instance`, or null for
/// a limited health check (version + git only).
/// * `test_path` can be null or a valid null-terminated UTF-8 string.
#[unsafe(no_mangle)]
pub unsafe extern "C" fn fff_health_check(
fff_handle: *mut c_void,
test_path: *const c_char,
) -> *mut FffResult {
let test_path = unsafe { optional_cstr(test_path) }
.map(PathBuf::from)
.unwrap_or_else(|| std::env::current_dir().unwrap_or_default());
View on GitHub (pinned to 7f8537e70f)