~ knotless Search/
↑↓ move↵ open⇧↵ all results
0
0

Records in the index jump to the top and get a new createdAt on each read

Closed
Closed chadtmiller.com opened this issue 0 comments

What happened

a whole read deletes every index_record row of the writer in the space and inserts them again, with new seq (AUTOINCREMENT) and indexed_at = now. listSpaceRecords orders by seq DESC and shows createdAt: iso(indexed_at). The note says this happens only when reading on fails. It is wider than that: a writer whose repo is here, which includes the group itself, is always read whole. So any write by the group in a space (a new role, a membership, an edited profile) gives all of its records there new sequence numbers and today's createdAt. Within one whole read the rows go in by path (BTreeMap), so "newest first" becomes reverse path order: collection name, then rkey. A remote writer gets the same after any failed read-on. No test checks the order or createdAt after a second write by a writer here. The only order assertions (tests/index.rs:108, 138) are for a remote writer read once whole and then read on.

How to see it

Read against docs/fresh at 4636e6d, the code at: index.rs:187-199 (sync_writer, a writer here), index.rs:356-363 (read_whole), store.rs:1420-1423 (index, UNINDEX_REPO then INDEX). Paths are under crates/group-host/src unless they say otherwise. Severity: medium.

What you expected

In a whole read, keep the rows whose path and CID are unchanged (update in place, or diff the old rows against the new set) and insert only new or changed paths. Better still, take createdAt from when the index first saw the path, not from the last read.

Where

The host, as built from 4636e6d. Found while checking the docs against the code.