feat: hot-reload provision releases instead of restarting - #8
Merged
Conversation
ApplyMetaproxyProvision used to freeze the periodic option and channel syncs after committing and hand a RestartRequired flag back to the host, which then put nginx into maintenance mode and restarted the process. Every price, model or channel change was a user-visible 503 window. The transaction now reloads the in-process state itself, still under the provision runtime write lock: options and ratios first, then the channel cache, so a model is never routable before its ratio exists. Periodic syncs take the read lock, so they cannot interleave with a reload. An idempotent retry of the already-active digest skips the reload. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Every provision release (price, model or channel change) currently ends in a process restart with nginx returning 503 on
/v1and/apifor the duration, becauseApplyMetaproxyProvisionfreezes the periodic syncs and reportsrestart_required.This change makes the apply reload the in-process state itself after the transaction commits, still holding the provision runtime write lock:
loadOptionsFromDatabase()first, thenInitChannelCache(), so a model is never routable before its ratio exists. Periodic syncs run under the read lock and cannot interleave with a reload. Idempotent retries of the active digest skip the reload. The freeze flag,IsMetaproxyProvisionRuntimeFrozenandrestart_requiredare removed.Verification:
gofmt,go build ./...,go vet,go test ./model/ ./controller/ -count=1all pass; new tests cover reload ordering, idempotent-retry skip, in-memory digest activation and routability of the new channel without a restart.Implemented by GLM-5.3 (opencode) from a spec, reviewed line by line by Claude Fable 5.1 (Claude Code).
馃 Generated with Claude Code