Repository navigation
Conversation
|
Ticket title is 'Client abort or hang when teardown races re-initialization: global scheduler object is reused across library generations' |
643380f to
14167c7
Compare
14167c7 to
4dbf65a
Compare
| /* the RPC can outlive the group view detach (e.g. an | ||
| * in-flight request aborted during crt_context_destroy); | ||
| * release the reference taken when crp_grp_priv was set */ | ||
| if (rpc_priv->crp_grp_priv != NULL) | ||
| crt_grp_priv_decref(rpc_priv->crp_grp_priv); | ||
|
|
There was a problem hiding this comment.
Either this decref needs to be bypassed for corpcs, or corpc_create needs to also take a ref when assigning grp_priv:
in crt_corpc.c:
387 crt_rpc_priv_init(rpc_priv, crt_ctx, false /* srv_flag */);
388 << ADD addref here >>
389 rpc_priv->crp_grp_priv = grp_priv;
There was a problem hiding this comment.
@frostedcmos I believe the current head already covers this: crt_corpc_req_create() now takes a group reference when assigning crp_grp_priv, so it pairs with the decref in crt_rpc_priv_free() the same way the regular request path does. This landed in the update I posted after the revision you looked at, so the asymmetry should be gone - thanks for pointing it out, it was easy to miss with the collective path being the less common one.
97a8bd4 to
24575a4
Compare
|
This branch also moved past its first posted revision. Beyond the rebase, the generation machinery changed in two ways, driven by the same reproducer runs that hardened the DAOS-19955 branch:
The note from the original description still holds for the updated pair of branches: 50 teardown/reinit cycles complete cleanly, over consecutive runs, where every run previously aborted or hung within tens of cycles. |
Destroying the CaRT context at the top of daos_eq_lib_fini() left in-flight tasks with no way to make progress, so their completion callbacks re-entered a half-torn-down scheduler during teardown: the drain lost task references, cancelled tasks were unlinked without completing, and late bulk completions touched freed shards. The drain now runs while the context can still make progress, before the context is destroyed. In-flight task and scheduler references are tracked across the drain so completion callbacks hold the objects they re-enter: a task-based RPC holds a task reference for its own lifetime (the completion callback arrives as a raw pointer, and without the reference a scheduler cancel could free the task before the late callback ran and re-entered tse_task_complete() on freed memory). Task completion ownership is decided before the callbacks run: tse_task_complete() moves the task into a callbacks-executing state under the scheduler lock, and the drain skips tasks in that state, so it can never free callback nodes a concurrent traversal still advances to; a task claimed by the drain is left entirely to it. Dependency links unwind the same way tse_task_post_process() does, dropping each dependent's dependency count under the dependent's own scheduler lock (kept held for same-scheduler dependents), without completing the dependent itself - the drain or the completing worker owns that. The drain loop holds one scheduler reference for its whole duration and releases it together with the initial reference at the end. A bulk completion landing after the drain gave up on the transfer is tolerated. The drain also exposed two smaller issues: an RPC did not hold a CaRT group reference for its lifetime (including the collective root path in crt_corpc_req_create()), and the transaction path dereferenced a handle after -DER_NO_HDL. Both are addressed here. Fixes: DAOS-19955 Signed-off-by: Jihyeon Gim <potatogim@potatogim.net>
Give each daos_eq_lib_init() generation its own heap-allocated global scheduler instead of reusing one static object, so a stale thread-private event from a previous generation keeps a valid (cancelled) scheduler. The finalizer drains in-flight tasks on the global scheduler while the CaRT context can still make progress, and holds one extra scheduler reference across the drain so late completion paths - including the RPC completion callback, which receives the task as a raw pointer and now pins the task for the RPC lifetime - always find a live scheduler and dsp_lock. Also track the waiter count for threads inside daos_event_priv_wait(): the finalizer waits (bounded) for them to leave before destroying the context, and the wait itself aborts when the scheduler is cancelled or the library generation changed. Fixes: DAOS-19962 Signed-off-by: Jihyeon Gim <potatogim@potatogim.net>
24575a4 to
69936f7
Compare
|
Closing in favor of #19542. Following the review on DAOS-19962, the layer this PR addressed, the global scheduler object being reused across library generations, is covered by #19542 through the eq_gen counter and the thread-private event reinit, which reads like the more targeted fix. A no-overlap variant of the reproducer, with the workers joined before teardown, completed two 500-cycle runs against a master build with #19542 without a crash, hang, or assert. The drain-race hardening this PR carried on top of #19526 is being closed by the same review, and the CaRT group reference piece from #19526 will come back as its own PR with a test case. |
Fixes DAOS-19962
Builds on #19526 (DAOS-19955 drain fixes; merge that first)
The global scheduler is a single static object reused across library generations. A worker still inside
daos_event_priv_wait()from the previous generation can race the nextdaos_eq_lib_init()re-initializing the object in place: the memset clears the cancellation flag and invalidates the mutex and refcount state while the stale worker is mid-callback. With the DAOS-19955 drain fixes in place this layer surfaces on its own, as anEBUSYmutex destroy intse_sched_fini, a destroyed-mutex assertion intse_sched_priv_decref, or a permanent epoll spin in the private event wait. All three were captured under gdb with the standalone reproducer from DAOS-19955 (teardown racing in-flight operations, then immediate re-initialization).Each
daos_eq_lib_init()now allocates a fresh scheduler object and the previous generation's object is kept allocated, so stale waiters still see a valid, cancelled scheduler and unwind instead of touching memory the new generation owns. Waiters bail out when the library generation changed underneath them or the scheduler was cancelled, submissions racing the final fini are rejected, and thread-private events created under a previous generation are re-initialized.With both this and the DAOS-19955 layer in place, the reproducer completed 50 teardown/reinit cycles back-to-back in my testing with no abort and no hang, both on a 2.6.5 single-node deployment (where the failures were first reproduced) and on a master single-node deployment; previously every run aborted or hung within tens of cycles. I am also keeping a release/2.6 backport branch ready in my fork, and will request the 2.6/2.8 backports once this lands on master.