memorix icon indicating copy to clipboard operation
memorix copied to clipboard

Startup migrateProjectIds never runs on large corpora (largeCorpusLazyMode empties the corpus first)

Open chenshuangci opened this issue 1 month ago • 1 comments

Environment

  • memorix 1.9.9, store with ~40k observations (above resolveOramaHydrationThreshold, 1e4)

What happens

The startup block that auto-merges project identities (autoMergeByBaseName + migrateProjectIds(group.aliases, group.canonical) for every multi-alias group) iterates the in-memory observation corpus. But initObservations sets largeCorpusLazyMode = true when durableCount >= 1e4 and a lexical index exists, leaving that corpus empty — so on large stores the automatic projectId migration never touches a single row.

Evidence in my data:

  • Small groups were migrated when they were small: local/twitter-web-exporter-main (6 rows) and local/zcode (3 rows) had their projectIds rewritten to their canonicals.
  • Everything at/above the hydration threshold (a 15k-observation family of worktree aliases under one canonical) was never migrated, across weeks of restarts and maintenance runs — the rows kept their old projectIds until I rewrote them by hand.

Expected

Migration should operate on SQLite (UPDATE ... WHERE projectId IN (...)) rather than the hydrated in-memory array, or hydrate a minimal (id, projectId) projection for the migration pass.

Related

Even once rows are migrated, records stored under old alias ids stay unreadable as long as canReadObservation doesn't honor the alias fan-out (companion report). The two together mean "merge projects via aliases" silently does nothing on large stores.

chenshuangci avatar Oct 08 '26 04:10 chenshuangci

The large-corpus migration regression is fixed in PR #331.

Startup project-id migration now obtains project IDs from the durable store and rewrites aliases through SQLite, rather than depending on a fully hydrated in-memory observation corpus. The regression test forces lazy mode and verifies migration without loading all observations.

AVIDS2 avatar Oct 12 '26 15:10 AVIDS2