From e27ce93a5aa96e197ebfd02c6df5baba07032a10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a?= <111108755+rafambn@users.noreply.github.com> Date: Thu, 2 Jul 2026 22:26:52 -0300 Subject: [PATCH] fix: cast postgres compactor fast mode num to bigint (#13006) ## Summary Fixes a PostgreSQL type mismatch in compactor fast mode when `ZO_LOCAL_MODE=true` is used with `ZO_META_STORE=postgres`. The fast mode query returned `0 as num`, which PostgreSQL infers as `INT4`. The result is decoded into `MergeJobPendingRecord.num` as `i64` / `INT8`, causing sqlx to fail with: ```text ERROR openobserve::job::compactor: [COMPACTOR::JOB] run data merge error: SqlxError# error occurred while decoding column "num": mismatched types; Rust type `i64` (as SQL type `INT8`) is not compatible with SQL type `INT4` ``` This changes the literal to 0::BIGINT AS num. ## Reproduction Tested with: - ZO_META_STORE=postgres - ZO_LOCAL_MODE=true - ZO_COMPACT_ENABLED=true - ZO_COMPACT_INTERVAL=2 On openobserve/openobserve:v0.92.0-rc1, inserting a pending row into file_list_jobs reproduces the error repeatedly and leaves the job stuck at status = 0. I've also created an issue on this #13007 Co-authored-by: Hengfei Yang --- src/infra/src/file_list/postgres.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/infra/src/file_list/postgres.rs b/src/infra/src/file_list/postgres.rs index 7cdec603f2..12bbde5974 100644 --- a/src/infra/src/file_list/postgres.rs +++ b/src/infra/src/file_list/postgres.rs @@ -1422,7 +1422,7 @@ DO UPDATE SET // get pending jobs group by stream and order by num desc let sql = if fast_mode { - r#"SELECT stream, id, 0 as num FROM file_list_jobs WHERE status = $1 ORDER BY offsets DESC LIMIT $2;"# + r#"SELECT stream, id, 0::BIGINT AS num FROM file_list_jobs WHERE status = $1 ORDER BY offsets DESC LIMIT $2;"# } else { r#" SELECT stream, max(id) as id, COUNT(*)::BIGINT AS num