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
Containers expose nothing to a worker about which worker it is; the
Child::Instance handed to the run block carries only `name`. Code that
needs a stable per-worker identifier (e.g. a prometheus-client-mmap
pid_provider, which keys mmap files per process) has nothing to key on,
and under Falcon/async-service the app never holds the run block itself.
Such an identifier needs to be both durable across a restart (so metrics
survive a re-fork instead of fragmenting) and bounded in cardinality
(drawn from 0..N-1 rather than the open-ended PID space, so the file and
series count stays constant). A recycled worker ordinal satisfies both.
Add a container-scoped `num` allocated by Generic (a counter plus a Set
free-list; idempotent release), captured in the spawn closure so it is
unchanged when a `restart: true` worker re-enters `start`. Expose `num`
and `kind` on Child::Instance, `instance_num` on the parent-side Child,
and a `parent` link plus a `context` Frame stack built from the object
graph. Hybrid links each inner thread worker to its fork, so a Hybrid
thread can reach its durable process num via `instance.parent.num` with
no process- or thread-global state.
# Container-scoped allocation of worker ordinals (`instance_num`): a monotonic
58
+
# counter plus a free set, so a num released by a permanently exited worker is
59
+
# recycled, keeping the range compact (e.g. for multiprocess metric files).
60
+
@next_instance_num=0
61
+
@free_instance_nums=Set.new
57
62
end
58
63
59
64
# @attribute [Group] The group of running children instances.
@@ -213,21 +218,27 @@ def stop(timeout = true)
213
218
# @parameter key [Symbol] A key used for reloading child instances.
214
219
# @parameter health_check_timeout [Numeric | Nil] The maximum time a child instance can run without updating its state, before it is terminated as unhealthy.
215
220
# @parameter startup_timeout [Numeric | Nil] The maximum time a child instance can run without becoming ready, before it is terminated as unhealthy.
0 commit comments