Repository navigation
Done
Labels
bugSomething isn't working
Description
Background
Found while fixing #1872. Line numbers are at 5a0420e8. Read from the code; not reproduced.
Schema::pending_reindex records the fields whose data a Destructive change discarded, so that GetSchema and laurus get schema show it (#1079). Engine::update_field removes a field from it after any Reindex (laurus/src/engine.rs:3376).
A Reindex does not bring back what an earlier Destructive change discarded. For example:
- A field is
stored: false, and a change of its type isDestructive: the documents written before it lose the field's data, and the field is recorded. storedis turned on, and documents are written with it.- An analyzer change is a lossless
Reindex, since no live document has the field's data without a stored value any more.
After step 3 the field is no longer in pending_reindex, though the documents of step 1 still have no data of it. They have no norms either, so the data does not tell them apart from documents written without the field.
Goal
pending_reindex keeps a field while documents that lost its data remain, or the docs say what removing it means.
Acceptance criteria
- The plan decides when a field leaves
pending_reindex: for example, only when the documents written before the loss are gone, or when the user clears it. - A test of the sequence above shows the field removed on the current code (T1 and T2 in
laurus/tests/engine_pending_reindex_test.rs, the investigation's lexical and vector sequences, fail with the old removal put back; the lexical one turnsindexedoff as the losslessReindex, since anIntegerfield has no analyzer). - The docs of
Schema::pending_reindexanddocs/src/concepts/schema_and_fields.md(en/ja) say when a field leaves it.
References
- fix(engine): a lexical Reindex drops the terms and points of the documents written while the field was not stored #1872, feat(engine): change classification + metadata-only update_field (Phase 1 of #1077) #1079, fix(engine): delete_field leaves the field's name in pending_reindex #1548 (
delete_fieldremoves the field frompending_reindex) laurus/src/engine.rs(update_field)laurus/src/engine/schema.rs(Schema::pending_reindex)
Tasks
- Investigate (comment below): reproduced for a lexical and a vector field
- Plan (comment below): keep the field while a live document is below the id recorded at the loss
- Tests: the lexical and vector sequences, when the field leaves, reopening, an old
schema.toml,may_hold_live_below, a field recorded twice, a change of kind,delete_field, a commit while a put holds the schema lock - Implementation: the id recorded with the field, the check after a commit, in a rebuild and at open, and one save lock for every save of the schema
- PR: fix(engine)!: keep a field in pending_reindex while a document that may have lost its data is live, instead of removing it after any lossless rebuild (#1890) #1898
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
mosuka commentedon Dec 4, 2026
Investigation
At
maince5f3baf, on evo-x2 (Linux).Reproduction
The Issue read this from the code; an integration test (not committed) runs it through
Engine, for a lexical field and for a vector field.update_fieldwas called withreindex: trueat each step.Lexical field
v:pending_reindexvfindsInteger,stored: false; puta1–a4{}Float,stored: falseDestructive{"v"}stored: true; putb1–b4MetadataOnly{"v"}indexed: falseReindex{}b1–b4)Vector field
v, HNSW:pending_reindexa1–a4{}Destructive{"v"}b1–b4; thenm16 to 8Reindex{}A destructive vector change recreates the field empty (#1535), so
a1–a4have no vector after step 1. I did not check that with a search.So the bug is the Issue's, and a vector field has it too.
Why
update_fieldrecords the field after a change that discarded data, and removes it after any other rebuild:if purge { insert } else { remove }(engine.rs:3453-3457). The branch is shared by the lexical and the vector rebuild.Which documents may have lost the data
DocumentLog::append_put,store/log.rs:773), and putting an id again deletes its old copy.DocumentLog::next_doc_id()at the time of the change. Once none of them is live (deleted, or put again), no document that lost the data remains.LexicalLiveness::live_upper_bound(perf(store): merge the document store's segments and drop deleted documents #1798,lexical/index/inverted/liveness.rs:111) bounds the live ids of a range without listing them. It overcounts, never under: a segment of unknown membership counts its whole range.How others do it
Read from the official docs by a subagent; I have not read them myself.
Options
delete_fielddoes.pending_reindexonce no document that may have lost its data is live.update_fieldand each commit remove the field once no live document is below that id.schema.tomlstill reads. A field pending in such a file gets the next id at open, which keeps it pending longer, never shorter.deny_unknown_fields, fix(schema): an analyzer component's unknown key is ignored #1700), andSchemagains a public field, so the title would carry!.Summary
pending_reindexforgets a field whose data an earlier destructive change discarded. This holds for both lexical and vector fields.The plan follows in a separate comment.
mosuka commentedon Dec 4, 2026
Plan
This follows the investigation and takes its option 2: a field stays in
pending_reindexwhile a document that may have lost its data is live. One PR.Shape
Engine, which already records a field inupdate_field.DocumentLog::append_put), so the recorded id covers every document that lost the data.LexicalLiveness::live_upper_bound(perf(store): merge the document store's segments and drop deleted documents #1798) can overcount and never undercount.Changes
laurus/src/engine/schema.rs:Schemagainspending_reindex_below: BTreeMap<String, u64>: for each field inpending_reindex, the next internal id at the change that recorded it. It is#[serde(default, skip_serializing_if = "BTreeMap::is_empty")], so an existingschema.tomlstill reads.laurus/src/lexical/index/inverted/liveness.rs:LexicalLiveness::may_hold_live_below(id) -> bool, built onlive_upper_bound.laurus/src/engine.rs:self.log.next_doc_id(). If the field already has an id, the larger one stays.release_pending_reindex: a new method that removes every field with no live document below its id, from both records.update_field, afterEngine::commit, and at the end ofEngineBuilder::build.CommitPolicy::Interval's background commits do not touch the schema, so the field leaves at the next of these instead; the docs say so.pending_reindexwithout an id, written before this change, gets thenext_doc_id()after recovery. That covers every document there is.delete_fieldremoves the field from both records.laurus-server/src/convert/schema.rsandlaurus-cli/src/commands/create.rs: their struct literals get the new field, empty. The proto and the HTTP gateway keep listing names only.pending_reindexparagraphs ofschema_and_fields.mdandlaurus-cli/commands.md(en/ja) say when a field leaves.!:Schemagains a public field.schema.tomlthat holds the new key, while a field is pending (deny_unknown_fields, fix(schema): an analyzer component's unknown key is ignored #1700).fix(engine)!: keep a field in pending_reindex while a document that may have lost its data is live, instead of removing it after any lossless rebuild (#1890)Tests
All but T6 are in
laurus/tests/engine_pending_reindex_test.rs.Reindexof step 3.mchange.a1-a4is put again.schema.tomlwritten before this change:pending_reindexholds the field and there is no id.liveness.rs):may_hold_live_belowagrees withlive_upper_boundover ranges, memberships and deletions.pending_reindex(such asengine.rs:7922) and fix(engine): a lexical Reindex drops the terms and points of the documents written while the field was not stored #1872's run. Any whose meaning changes is updated, and the PR says which.may_hold_live_belowignores deletions (T3 or T6).Measurements
The check runs only while a field is pending, once per explicit commit, and takes one liveness snapshot. Its time on T3's index goes in the PR; no benchmark is planned.
Checks before the PR
On CPUs 8-15:
cargo fmt --check;embeddings-all, and onwasm32;laurus,laurus-server,laurus-mcpandlaurus-cli.The bindings are left to CI, after checking that their jobs start.
Out of scope
Destructive) stays separate. It is the next candidate.fix(engine): classify a lexical rebuild by the data it discards, so t…
fix(engine): classify a change of a vector field, or between a lexica…