You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(kb): the embedding-switch settle script recreates a vanished state record as 'settling' with no owner #19849
Raised in the code review of PR #19641 (#19379). _SETTLE_UNLESS_CANCELLED_LUA (embedding_switch.py:66-80) runs HSET on the state key even when the hash has expired. The record comes back as state=settling with no owner. _finish then refuses it, because the owner doesn't match, so the stale record stays until its TTL.
The settle script returns a distinct value when the state key does not exist and writes nothing.
The caller treats that as a lost run and does not cut over.
A fakeredis Lua test with an expired state key shows no record is recreated.
Landed via the merge train (PR #19988), main 0881619.
All three criteria verified on main and ticked:
Settle script: _SETTLE_UNLESS_CANCELLED_LUA in autobot-backend/knowledge/embedding_switch.py returns -1 (_SETTLE_LOST_RECORD) before its only HSET when HGET owner differs from this run's owner. A missing key reads as no owner, so nothing is written.
Caller: _cut_over checks settled == _SETTLE_LOST_RECORD, calls _finish(run, "failed", ...) and returns before set_embedding_model_override.
Test: test_settling_a_vanished_or_foreign_record_writes_nothing in embedding_switch_test.py uses fakeredis and asserts -1 and exists("s") == 0. test_a_state_record_lost_during_convergence_never_cuts_over covers the whole run.
Remaining behaviour, outside these criteria: _heartbeat runs just before the script and its HSET still leaves an ownerless hash on a vanished record. It holds only heartbeat, with no state field. PR #19967 states this as not changed.
Activity
mrveiss commentedon Oct 30, 2026
Landed via the merge train (PR #19988), main 0881619.
All three criteria verified on main and ticked:
_SETTLE_UNLESS_CANCELLED_LUAinautobot-backend/knowledge/embedding_switch.pyreturns-1(_SETTLE_LOST_RECORD) before its onlyHSETwhenHGET ownerdiffers from this run's owner. A missing key reads as no owner, so nothing is written._cut_overcheckssettled == _SETTLE_LOST_RECORD, calls_finish(run, "failed", ...)and returns beforeset_embedding_model_override.test_settling_a_vanished_or_foreign_record_writes_nothinginembedding_switch_test.pyusesfakeredisand asserts-1andexists("s") == 0.test_a_state_record_lost_during_convergence_never_cuts_overcovers the whole run.Remaining behaviour, outside these criteria:
_heartbeatruns just before the script and itsHSETstill leaves an ownerless hash on a vanished record. It holds onlyheartbeat, with nostatefield. PR #19967 states this as not changed.Closing: every criterion has code evidence.