Skip to content

Commit 7395ac7

Browse files
committed
fix(distributed): persist per-model load info on dispatch
scheduleAndLoad now writes the (backendType, ModelOptions blob) pair to the new ModelLoadInfo table in addition to the existing per-replica NodeModel.model_opts_blob field. The per-replica blob still works for the hot path; the per-model row outlives every NodeModel row going away, which is what unblocks the reconciler on the read side. Both writes are best-effort with warn-level logging on failure: a write miss here just means the reconciler may need a fresh inference request to repopulate, which is the pre-fix behavior. Concurrency: two frontends loading the same model at the same time both fire UpsertModelLoadInfo; ON CONFLICT (model_name) makes the row converge to whichever commits last. Matches the existing per-replica blob semantics. Signed-off-by: Ettore Di Giacinto <mudler@localai.io> Assisted-by: Claude:claude-opus-4-7[1m]
1 parent 458c44d commit 7395ac7

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

core/services/nodes/router.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,18 @@ func (r *SmartRouter) scheduleAndLoad(ctx context.Context, backendType, tracking
156156
xlog.Warn("Failed to record model on node", "node", node.Name, "model", trackingKey, "replica", replicaIndex, "error", err)
157157
}
158158

159-
// Store load metadata for future replica scale-ups by the reconciler
159+
// Store load metadata for future replica scale-ups by the reconciler.
160+
// Writes both per-replica (NodeModel.model_opts_blob) for backward compat
161+
// and per-model (ModelLoadInfo table) so the reconciler can recover after
162+
// every replica row has been removed (Bug-1).
160163
if modelOpts != nil {
161164
if optsBlob, marshalErr := proto.Marshal(modelOpts); marshalErr == nil {
162165
if storeErr := r.registry.SetNodeModelLoadInfo(ctx, node.ID, trackingKey, replicaIndex, backendType, optsBlob); storeErr != nil {
163166
xlog.Warn("Failed to store model load info", "node", node.Name, "model", trackingKey, "replica", replicaIndex, "error", storeErr)
164167
}
168+
if storeErr := r.registry.UpsertModelLoadInfo(ctx, trackingKey, backendType, optsBlob); storeErr != nil {
169+
xlog.Warn("Failed to upsert per-model load info", "model", trackingKey, "error", storeErr)
170+
}
165171
}
166172
}
167173

0 commit comments

Comments
 (0)