Skip to content

Multiple DFOs: ignore TriggerDecisions for completed triggers, and fix the DFO assignment loop - #527

Open
wesketchum wants to merge 23 commits into
developfrom
wketchum/fix-late-duplicate-trigger-decisions
Open

wesketchum wants to merge 23 commits into
developfrom
wketchum/fix-late-duplicate-trigger-decisions

Conversation

@wesketchum

Copy link
Copy Markdown
Contributor

Description

See issue #526 for some details.

With several DFOs, each DFO receives every TriggerDecision from the MLT and sends its own TriggerDecision for that trigger to the DF app it selects. This PR fixes three problems that come from that, all seen in dfo_protocol_test:

  1. A late TriggerDecision is built and written a second time. The DF app ignored extra TriggerDecisions only while the trigger was in progress. One arriving after the record was written was built again, and the second write failed with Object already exists (1 to 3 times per run, also in the nightly extended tests).
    • DF app (2bb7d40): a TriggerDecision for a trigger in recently_completed_triggers is also a duplicate.
    • DFO (2bb7d40): keeps a bounded history of completed triggers and ignores a TriggerDecision for one of them. It records an assignment before dispatching it, so that a DataflowStatus that lists the trigger does not look unexpected.
  2. The DFO retries an assignment until the run stops. If the trigger completes while a DFO is waiting for status replies, the DFO finds no slot and retries forever, blocking its TriggerDecision callback. While it does, it reports busy and the MLT inhibits triggers for the whole system (seen in 2 of 15 runs).
    • DFO (069bc27): checks for a completed or already assigned trigger under the same lock as the slot search, and stops if the trigger has completed.
  3. A trigger is written in two files. A DFO that was stopped (SIGSTOP) while waiting for replies can, once resumed, choose a DF app from replies that predate another DFO's choice (seen once in 10 stopped-dfo runs).
    • DFO (f0c6c32): replies older than three reply waits are discarded and requested again. A trigger that a DF app reports as building during the wait is sent to that DF app.

Also in the DFO:

  • f57aade: when a status request to a DF app cannot be sent, that DF app's status is marked stale, so it is not asked again until it sends a status (found with the killed-DF test below; without it the DFO waits a full reply wait for the dead DF app on every trigger).
  • 9cae0b3: "TriggerDecision N has been reported by X with no TriggerDecision message received" (INFO/WARNING, UnexpectedTriggerDecision) is now a debug message, "was reported as building/writing by X before this DFO assigned it". With several DFOs this is normal, and the check is on assignment, not receipt. The UnexpectedTriggerDecision issue is removed from the DFO (TRBModule has its own).
  • A TriggerDecision ignored because its trigger has completed is logged at debug level.

Tests

  • Unit tests, five new: DataflowStatusModule_test/LateDuplicateDecision, and in DFOModule_test LateDecisionAfterCompletion, CompletionDuringAssignment, CompletionReportedByAnotherDFApp and BuildingReportedDuringAssignment. The first four are also on [wketchum/test-late-duplicate-trigger-decisions](https://github.com/DUNE-DAQ/dfmodules/tree/wketchum/test-late-duplicate-trigger-decisions) without the fixes, where they fail.
  • integtest/dfo_protocol_test.py (configurations default, stopped-dfo, stopped-df):
    • The stop and continue signals are now really sent (they were not before integrationtest#176) and land while triggers are enabled: run_duration 30 s to 60 s, signal at 60 s from the start of the session, 5 s stop.
    • New check that no record is written to more than one file.
    • HSI fragment status bits allowed per trigger type (frag_bitmasks_by_TC_type); the fake HSI data is sparse, so these bits are expected.
    • The log check allows the errors that a stopped DFO or DF app causes and that are expected (listed in the test).
    • The killed-dfo and killed-df configurations are moved to their own modules, dfo_protocol_killed_dfo_test.py and dfo_protocol_killed_df_test.py. Once an application has been killed, run control refuses the transitions after it, so these modules exclude the dead application and include a surviving one before stopping the run (exclude also flips included on the parent controller). They test the dataflow with a dead application, not how run control copes with one.

Dependencies

Open questions for reviewers (some details in #526):

  1. Should a DFO still send its TriggerDecision when a DF app already reports the trigger as building? This branch sends it to that DF app. The alternative is to send nothing, which DFOProtocol_test/AllDFOsAgreeOnAssignments would then need to allow.
  2. Should a DFO choose a DF app before every DF app has replied? This branch keeps doing so and only discards replies that are too old.
  3. Is debug the right level for "reported before this DFO assigned it"?
  4. Should one failed status request mark a DF app's status stale (f57aade)?
  5. Is the 5 s stop in dfo_protocol_test meant to equal the DataflowStatus timeout? With it, the resumed DFO finds every status stale and logs "could not be assigned" once.

To test

# area with dfmodules (this branch), trigger (trigger#448) and daqsystemtest (daqsystemtest#364)
dbt-build --unittest dfmodules
cd sourcecode/dfmodules/integtest
pytest -s dfo_protocol_test.py
pytest -s dfo_protocol_killed_dfo_test.py
pytest -s dfo_protocol_killed_df_test.py

Type of change

  • Documentation (non-breaking change that adds or improves the documentation)
  • New feature or enhancement (non-breaking change which adds functionality)
  • Optimization (non-breaking change that improves code/performance)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (whatever its nature)

Testing checklist

  • Unit tests pass (e.g. dbt-build --unittest)
  • Minimal system quicktest passes (pytest -s minimal_system_quick_test.py)
  • Full set of integration tests pass (dunedaq_integtest_bundle.sh)
  • Python tests pass if applicable (e.g. python -m pytest)
  • Pre-commit hooks run successfully if applicable (e.g. pre-commit run --all-files)

On daq.fnal.gov, NFD_DEV_261117_A9, with this branch (a1ea174), trigger#448 and daqsystemtest#364:

  • Unit tests: dfmodules 7 of 7, trigger 1 of 1.
  • dfo_protocol_test: 6 of 6 runs pass every check. No Object already exists, no record in two files. The one "could not be assigned" of a resumed DFO (question 5) appeared in 3 of the 6 runs.
  • dfo_protocol_killed_dfo_test and dfo_protocol_killed_df_test: 1 of 1 each.
  • daqsystemtest core suite: 94 of 94 pass, the same as that nightly's own run (it includes the minimal system quicktest).
  • Earlier, on NFD_DEV_261109_A9 with the fixes at intermediate commits: 0 Object already exists in 15 runs (against 3 in 10 without the fix); the retry loop gone in 10 stopped-dfo runs; in 20 more stopped-dfo runs with f0c6c32's change, no trigger in two files.

These are tens of runs, so the rare races are "not seen" rather than proven fixed.

Further checks

wesketchum and others added 22 commits November 9, 2026 16:32
…ompleted

With multiple DFOs, each DFO sends its own TriggerDecision for every trigger to
the DF app it selects. Extra TriggerDecisions that reach a DF app while the
trigger is in progress are ignored, but nothing covers one that arrives after
the trigger record has been written.

- DataflowStatusModule_test/LateDuplicateDecision: TriggerDecision, TRB
  completion and token for trigger 5, then a second TriggerDecision for 5. The
  DF app forwards it to the TRB again, so the record is rebuilt (in
  dfo_protocol_test the second write fails with "Object already exists").
- DFOModule_test/LateDecisionAfterCompletion: trigger 7 is dispatched and
  reported completed, then a TriggerDecision for 7 arrives again. The DFO
  treats it as new and sends DataflowStatusRequests for it instead of ignoring
  it.

Both tests fail on current develop; they document the behaviour to fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With multiple DFOs, each DFO sends its own TriggerDecision for every trigger.
One that reached a DF app after the trigger record was written was built again,
and the second write failed with "Object already exists" (seen in
dfo_protocol_test).

- DataflowStatusModule: also treat a TriggerDecision for a trigger in
  recently_completed_triggers as a duplicate.
- DFOModule: remember triggers that DF apps report as completed (bounded set,
  cleared at stop) and ignore TriggerDecisions that arrive for them later,
  instead of sending status requests and retrying assignment.
- DFOModule: record the assignment before dispatching, and remove it if the send
  fails, so that a DataflowStatus arriving in between is not reported as an
  UnexpectedTriggerDecision by the DFO that sent it.

Makes DataflowStatusModule_test/LateDuplicateDecision and
DFOModule_test/LateDecisionAfterCompletion pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g it

CompletionDuringAssignment: the DF app reports the trigger completed while
the DFO waits for a slot. The DFO must give up and go on to the next trigger.
CompletionReportedByAnotherDFApp: one DF app reports the trigger completed
and another still offers a slot. The DFO must not send it there.

Co-Authored-By: Claude <noreply@anthropic.com>
…r a slot

With several DFOs, another DFO's TriggerDecision can reach a DF app, and be
completed, while this DFO is still in its assignment loop. The loop then
retried until the end of the run, keeping the DFO busy and the trigger
inhibited, or sent the trigger to a different DF app.

The loop now checks, under the same lock as the slot search, whether the
trigger is completed or already assigned, and stops if so. The wait for
status replies ends early in that case. The timing counters are only updated
for a TriggerDecision that was sent.

Co-Authored-By: Claude <noreply@anthropic.com>
… wait

Two changes to how a DFO picks the DF app for a TriggerDecision.

When a DF app reports the trigger as building while the DFO is waiting
for status replies, the DFO now sends its TriggerDecision to that DF app
instead of dropping it. The DF app discards the duplicate. This keeps the
number of TriggerDecisions each DFO sends as DFOProtocol_test expects
(AllDFOsAgreeOnAssignments failed now and then with 5 != 6). A trigger
reported as completed is still dropped.

When the wait for status replies took more than three reply waits, for
example because the DFO process was suspended, the replies are discarded
and requested again. They may predate another DFO's assignment, and
choosing from them sent one trigger to two DF apps in dfo_protocol_test
(stopped-dfo).

Co-Authored-By: Claude <noreply@anthropic.com>
The fake HSI data is sparse, so every HSI fragment in this test carries
kRequestWindowAfterBuffer, with kIncomplete for kTiming triggers and
kEmptyFragment for the others. These failed test_data_files in every run.
Mask them by trigger type.

Co-Authored-By: Claude <noreply@anthropic.com>
…opped

In the stopped-dfo configuration the DFO is stopped for 5 s, the same as
the DataflowStatus timeout. When it resumes it can find every DF app
status stale before it has read the queued status messages. It then
reports "No DataflowStatus received" and, for one pass, "could not be
assigned", and recovers within milliseconds. Ignore those two messages
in the log of the stopped DFO only.

Co-Authored-By: Claude <noreply@anthropic.com>
The signal delay is counted from the launch of the run control session.
At 25 s the signal landed on the conf, start or enable_triggers command
in about half of the runs, so the command timed out in run control and
the application was never stopped or killed while taking triggers. Move
the signals to 40 s, about halfway through the time with triggers
enabled.

Co-Authored-By: Claude <noreply@anthropic.com>
With several DFOs it is normal for a DFO to see a trigger in a DF app's
status before it has assigned that trigger itself: another DFO sent its
TriggerDecision first. This was an INFO if the DF app was building the
trigger and a WARNING if it was already writing it, and the WARNING
failed the log check of dfo_protocol_test now and then.

The text also said "with no TriggerDecision message received", which is
not what is checked: the DFO may have the TriggerDecision and still be
waiting for status replies. Say "before this DFO assigned it".

Co-Authored-By: Claude <noreply@anthropic.com>
The signal delay is counted from the launch of the run control session,
and boot takes between 25 s and 45 s depending on the load of the host.
With 30 s of triggers no fixed delay is safe: at 40 s the stop still hit
conf or enable_triggers in 4 of 6 runs on a busy host. Take triggers for
60 s and send the signals at 60 s, which leaves room for boot times
between 25 s and 55 s.

Co-Authored-By: Claude <noreply@anthropic.com>
With several DFOs a trigger must still be built by exactly one DF app.
Compare the record names (trigger number and sequence number) across the
output files of all DF apps and fail if one appears twice.

Co-Authored-By: Claude <noreply@anthropic.com>
…e run

Run control refuses the commands after the kill while the dead application
is part of the session, so the killed-dfo configuration of dfo_protocol_test
never stopped its run. This module kills dfo-02 during triggering, excludes
it with the run control 'exclude' command, and then stops the run as usual.

Co-Authored-By: Claude <noreply@anthropic.com>
… DFO

Run control, the MLT and the DF apps report the DFO that was killed. Ignore
those messages, each tied to the name of the killed application.

Co-Authored-By: Claude <noreply@anthropic.com>
…r the exclude

After 'exclude --target root-controller/df-controller/dfo-02' the root
controller sent no further commands to df-controller, so the DF apps and
the other DFOs were never stopped. Include a surviving application of the
segment after the exclude.

Co-Authored-By: Claude <noreply@anthropic.com>
The run cannot be stopped with the command list of this module once a DFO
has been killed; dfo_protocol_killed_dfo_test.py excludes the killed DFO
first.

Co-Authored-By: Claude <noreply@anthropic.com>
…the run

Same sequence as dfo_protocol_killed_dfo_test, for df-02. The two DF apps
that survive share the triggers after the kill, so each is expected to
write more than a third of the records.

Co-Authored-By: Claude <noreply@anthropic.com>
…rning

Co-Authored-By: Claude <noreply@anthropic.com>
…be sent

A DF app that has died keeps a fresh status until dataflow_status_timeout_ms
has passed. Until then every trigger cost a failed send and a full reply wait,
so TriggerDecisions queued in the DFO. A failed TriggerDecision dispatch
already marks the status stale; do the same for a failed status request, and
do not wait for a reply to a request that was not sent.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
… and the stale status error for a stopped DF app

A non-timing trigger close to a timing one gets that trigger's HSI frame.
A DF app stopped for as long as the status timeout may be reported as silent.

Co-Authored-By: Claude <noreply@anthropic.com>
…meout

A stop as long as the DataflowStatus timeout made stale-status errors a matter
of timing, so they had to be allowed. With a shorter stop they are not expected
and the allowances are removed.

Co-Authored-By: Claude <noreply@anthropic.com>
…tatus timeout"

The stop stays as long as the DataflowStatus timeout.

Co-Authored-By: Claude <noreply@anthropic.com>
… limit

As receive_dataflow_status does. The function was already 75 lines on
develop; splitting it is better done on its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant