fix(web): config RMW handlers hold the mutation lock — concurrent saves stop dropping writes - #90512
Open
teknium1 wants to merge 1 commit into
Open
fix(web): config RMW handlers hold the mutation lock — concurrent saves stop dropping writes#90512teknium1 wants to merge 1 commit into
teknium1 wants to merge 1 commit into
Conversation
…t saves stop dropping writes Only PUT /api/config took the span lock; model.set, moa, custom-endpoint create/activate/delete, memory-provider saves, and the profile-dir model write ran load→mutate→save unlocked in worker threads. The desktop fires these concurrently with its debounced autosave — whichever save landed second silently dropped the other's mutation (#88913/#89184 lost-write flavor). Race test with slowed save proves both writes now survive.
Contributor
૮ >ﻌ< ა ci reviewran on 803e295 — fix(web): config RMW handlers hold _CONFIG_MUTATION_LOCK so
|
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Model assignment, MoA saves, custom-endpoint create/activate/delete, memory-provider saves, and the profile-dir model write no longer race the desktop's config autosave — every config read-modify-write span in web_server.py now holds
_CONFIG_MUTATION_LOCK.The lock existed precisely for this (its comment: off-loop handlers interleave load→mutate→save and silently drop one another's writes), but only
PUT /api/configtook it. All the other writers run in worker threads (sync-def endpoints /asyncio.to_thread), and the desktop makes the race real:applyMainModelfiresPOST /api/model/setwhile the settings page's debouncedPUT /api/configautosave is in flight — whicheversave_configlanded second dropped the other's mutation (the lost-write flavor of #88913/#89184).Changes
hermes_cli/web_server.py:_CONFIG_MUTATION_LOCK(RLock, worker-thread-only) now wraps the RMW spans in:_apply_model_assignment_sync(main + auxiliary scopes, via a thin locked wrapper)set_moa_modelsupsert_custom_endpoint/activate_custom_endpoint/delete_custom_endpoint_update_memory_provider_config+ the memory-provider activate saveset_hermes_home_overridepath)tests/hermes_cli/test_config_rmw_lock.py: a real two-thread race with a slowedsave_configasserting BOTH mutations survive, plus a source-contract tripwire that each flagged handler still holds the lock.Validation
From the settings-pipeline audit (Bug 4, MED). No event-loop blocking: the lock is only ever held in worker threads.
Infographic