Skip to content

fix(index): collapse per-node syncmer change record to one entry per position - #119

Merged
AlanZhangUCSC merged 3 commits into
mainfrom
fix/index-multitouch-dedup
Jul 15, 2026
Merged

fix(index): collapse per-node syncmer change record to one entry per position#119
AlanZhangUCSC merged 3 commits into
mainfrom
fix/index-multitouch-dedup

Conversation

@amkram

@amkram amkram commented Jul 13, 2026

Copy link
Copy Markdown
Owner

Fixes klebs_1000.panman crash:

  • placement / .idx (--stop index): error: syncmer position not found in refOnSyncmersMap when computing new k-min-mer ranges (fails identically at k=51 and k=19).
  • metagenomic / .midx (--meta): error: bad optional access.

When a node both edits a seed and deletes that seed's block, we recorded the same position twice in its per-node change record leading to crash.

Fix: collapse each node's change record to one net entry per position.

@amkram
amkram force-pushed the fix/index-multitouch-dedup branch from 2c63825 to 6a31daa Compare July 13, 2026 23:38
…position

A node can touch the same syncmer position more than once -- e.g. a nuc mutation
SUBs/ADDs a syncmer, then that syncmer's block is dropped, DEL'ing it. The change
record then carries a stale non-DEL entry whose position a later DEL already erased
from the map. Three consumers assume one entry per position:
  - index_single_mode::computeNewKminmerRanges: find() == end() -> "syncmer position
    not found" abort (the placement/.idx build).
  - mgsr::computeNewKminmerRanges: the found position's refOnSyncmers optional is empty
    -> std::bad_optional_access (the --meta/.midx build); mgsr's block-deletion loop
    also dereferences an already-deleted position's optional.
  - the backtrack restores the wrong pre-node value.

Collapse each node's change record to one NET entry per position (net type from final
map membership, restore rsyncmer from the first touch) before it is consumed, in both
the sequential and parallel index_single_mode builders and in mgsr; also guard mgsr's
block-deletion loop against already-deleted positions.

No-op for panmans where no position repeats (rsv/sars/tb/ecoli/HIV/mtDNA): all unit
tests pass and sars's .midx is byte-identical before/after. Fixes indexing of
klebs_1000 (both .idx at k=51 and --meta), which deterministically hit these crashes.
@amkram
amkram force-pushed the fix/index-multitouch-dedup branch from 6a31daa to 38b3703 Compare July 14, 2026 01:54
@amkram

amkram commented Jul 14, 2026

Copy link
Copy Markdown
Owner Author

@AlanZhangUCSC Could you review the changes to mgsr.cpp to see if this looks like a reasonable fix? Both modes currently broken on Klebsiella due to cases of a SNP followed by deleting that SNP's block.

@AlanZhangUCSC
AlanZhangUCSC merged commit 0293711 into main Jul 15, 2026
4 checks passed
@amkram
amkram deleted the fix/index-multitouch-dedup branch July 15, 2026 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants