A handler notified by a task does not run immediately. Handlers are collected and executed once, in the order they are defined rather than the order they were notified, after all tasks in the play complete. If any task fails before that point, the play aborts and no handler runs at all.
This produces a half-applied state: a configuration file was rewritten, the service restart was notified, an unrelated later task failed, and the service is still running the old configuration. The next run does not re-notify, because the file task is now idempotent and reports ok.
--force-handlers on the command line, or force_handlers: true in the play, runs notified handlers even when the play fails, which repairs the mismatch. meta: flush_handlers as a task runs all pending handlers at that point, which is the way to restart a service mid-play before later tasks depend on it. Handlers deduplicate by name, so notifying the same handler from ten tasks runs it once, and a handler that is notified but whose name does not exist is an error only when error_on_missing_handler is left at its default of true.