Skip to content

DAOS-19955 client: fix teardown races between drain, completion and re-init - #19524

Closed
potatogim wants to merge 1 commit into
daos-stack:release/2.6from
potatogim:fix/daos-19955-client-teardown
Closed

potatogim wants to merge 1 commit into
daos-stack:release/2.6from
potatogim:fix/daos-19955-client-teardown

Conversation

@potatogim

Copy link
Copy Markdown

Fixes DAOS-19955
Fixes DAOS-19962

The client aborts or hangs intermittently when dfs_fini() teardown races in-flight operations and an immediate re-initialization. This was reproduced with a standalone Go/cgo reproducer (connect, concurrent dfs I/O, teardown after 200 ms without joining the workers, re-init, repeat) against a 2.6.5 single-node docker deployment; 21 of 40 versitygw DAOS-backend suite runs aborted at the same tse_task_decref assertion during cleanup.

Two independent layers were involved. First, daos_eq_lib_fini() destroyed the CaRT context before draining the global scheduler, so in-flight tasks could no longer make progress: completion callbacks re-entered a half-torn-down scheduler, 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 progress, before the context is destroyed. Second, the global scheduler is a single static object reused across library generations, so a worker still inside daos_event_priv_wait() raced the next daos_eq_lib_init() re-initializing it in place, which showed up as destroyed-mutex aborts, EBUSY mutex destroy, or a permanent epoll spin. Each generation now gets its own scheduler object; the previous generation's object is kept allocated so stale waiters still see a valid, cancelled scheduler and bail out through a generation check in daos_event_priv_wait(). Submissions racing the final fini are rejected, and thread-private events from a previous generation are re-initialized.

The drain also exposed two smaller issues that are addressed here: an RPC did not hold a CaRT group reference for its lifetime, and the transaction path dereferenced a handle after -DER_NO_HDL.

With these changes the reproducer completes 50 teardown/reinit cycles repeatedly with no abort and no hang, where previously every run aborted or hung within tens of cycles.

Steps for the author:

  • Commit message follows the guidelines.
  • Appropriate Features or Test-tag pragmas were used.
  • Appropriate Functional Test Stages were run.
  • At least two positive code reviews including at least one code owner from each category referenced in the PR.
  • Testing is complete. If necessary, forced-landing label added and a reason added in a comment.

After all prior steps are complete:

  • Gatekeeper requested (daos-gatekeeper added as a reviewer).

…e-init

Destroying the client 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: the drain lost task
references, cancelled tasks were unlinked without completing, and
late bulk completions hit freed shards. Cancel and drain the global
scheduler while the context can still run, then destroy the context.

The remaining aborts came from the scheduler itself: it is a single
static object reused across library generations, so a worker still
waiting in daos_event_priv_wait() raced the next daos_eq_lib_init()
re-initializing it in place. Give each generation its own scheduler
object, keep the previous one allocated for stale waiters, reject
submissions that race the final fini, and make the private event wait
bail out when its scheduler was cancelled or the library generation
changed underneath it.

Also hold a CaRT group reference for the lifetime of an RPC and
return -DER_NO_HDL instead of dereferencing a stale object handle in
the transaction path, both of which the drain exposed.

Fixes DAOS-19955, DAOS-19962

Signed-off-by: Jihyeon Gim <potatogim@potatogim.net>
@potatogim
potatogim requested review from a team as code owners November 13, 2026 04:47
@github-actions

Copy link
Copy Markdown

Ticket title is 'Intermittent client abort at tse_task_decref assertion during dfs_fini teardown'
Status is 'Open'
https://daosio.atlassian.net/browse/DAOS-19955

@potatogim

Copy link
Copy Markdown
Author

Closing in favor of a split: the drain-races layer (DAOS-19955) and the generation-scheduler layer (DAOS-19962) will be submitted as two stacked PRs, starting with #19525's base branch.

@potatogim potatogim closed this Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant