#392·sonic

`document_count` is incorrect after a `FLUSHO`

Author: RemiBardonCreated Aug 15, 2026Updated Aug 15, 2026
Labelsbugfeat:searchfeat:ingest

document_count is derived from IIDIncr:

rust
let document_count = match kv_action.get_meta_to_value(StoreMetaKey::IIDIncr)? {
    Some(StoreMetaValue::IIDIncr(last_iid)) => u64::from(last_iid) + 1,
    None => 0,
};

If we remove an object (FLUSHO), the document count should decrease by one but IIDIncr does not (logically).

It’s not that big of a deal but I suggest at some point we introduce a proper atomic count.