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 <hengfei.yang@gmail.com>
This commit is contained in:
Rafael Mendonça
2026-07-03 01:26:52 +00:00
committed by GitHub
co-authored by Hengfei Yang
parent a234806ed9
commit e27ce93a5a
+1 -1
View File
@@ -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