Skip to content

fix(kb): the embedding-switch settle script recreates a vanished state record as 'settling' with no owner #19849

Closed
1 of 2 issues completed

Description

@mrveiss

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.

Activity

  1. mrveiss commented on Oct 30, 2026

    @mrveiss
    OwnerAuthor

    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.

    Closing: every criterion has code evidence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backendbugSomething isn't workingphase:M4.4One config source

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions