Rehash only the samples an older smda escaper hashed (#142) - #180
Conversation
|
Live verification on a MongoDB 7 instance (4 samples, 418 hashed functions, 8360 band entries) with the branch deployed to server and worker:
After the first repair every sample carries |
) recalculateMinHashes drops every band collection and rehashes the whole corpus, so an escaper change in smda costs a full outage of the index. Record on each sample which smda version escaped its minhashes, report via /status how many samples are stale against smda's escaper compatibility threshold, and add POST /repair_minhashes (McritClient .repairMinHashes) that pulls just those samples' band entries and rehashes them one sample at a time, keeping the index serving. - StorageInterface/MongoDbStorage/MemoryStorage: deleteMinHashesForSample, setMinHashVersionForSamples, getSamplesWithStaleMinHashes, countSamplesWithStaleMinHashes; deleteSample shares _pullBandEntries - MemoryStorage gains the deleteAllMinHashes the interface declares - Worker: updateMinHashesForSample and recalculateMinHashes record the running smda version; repairMinHashes job with a progress reporter - tests for both storage backends, the worker job, route and client Refs danielplohmann#142
…rsion field A sample whose disassembly is gone (STORAGE_DROP_DISASSEMBLY) cannot be rehashed; the repair now computes the new minhashes first and only then pulls the old band entries, skipping and counting the samples it cannot hash instead of leaving them without any. The stale-sample count on /status is a distinct plus a count over samples.minhash_smda_version, which now has an index.
|
Rebased onto How the conflicts were resolved, since two of them were not purely additive:
A welcome consequence of the ordering: since #171 landed first, Verified after the rebase: Worth a glance at the 🤖 Generated with Claude Code |
d9fd711 to
3363dd4
Compare
Closes #142 (the "escaper change" gaps). Gaps 1 and 3 of that issue are already handled by mcrit 1.7.0 and maintainer PR #143; this covers the remaining one: a full
recalculateMinHashesdrops every band collection and rehashes the whole corpus, so an escaper change costs a full outage of the index.What changes
minhash_smda_version, set byupdateMinHashesForSampleand by the full recalculation)./statusreportsminhash_compatibility_threshold(smda'sESCAPER_DOWNWARD_COMPATIBILITY, falling back to its version) andnum_samples_with_stale_minhashes. Samples with no recorded version count as stale, so an existing database shows its whole corpus as stale until one repair or full recalculation has run.POST /repair_minhashes(McritClientrepairMinHashes()) schedules a job that walks only the stale samples, pulls their band entries, rehashes them one sample at a time and records the running version. The index keeps serving throughout, and a killed run costs one sample. The job result is a report with the threshold, smda version, samples stale/repaired and functions dropped/rehashed.deleteMinHashesForSample,setMinHashVersionForSamples,getSamplesWithStaleMinHashes,countSamplesWithStaleMinHasheson both backends.deleteSampleshares the new_pullBandEntrieshelper. The Mongo stale query compares the few distinct recorded versions instead of scanning every sample document.MemoryStoragegains thedeleteAllMinHashesthe interface declares (its absence made the local-queue full recalculation fail silently).Verification
tests/testMinHashRepair.py(worker job on the local queue, route, client) and storage tests for both backends; full suite: 211 passed.