Skip to content

CfdpManager: degrade instead of asserting when the message queue is full - #6418

Open
bitWarrior wants to merge 1 commit into
nasa:develfrom
bitWarrior:fix/cfdp-datain-queue-overflow
Open

bitWarrior wants to merge 1 commit into
nasa:develfrom
bitWarrior:fix/cfdp-datain-queue-overflow

Conversation

@bitWarrior

Copy link
Copy Markdown
Collaborator

Summary

CfdpManager asserts when its message queue fills. run1Hz, dataIn, dataReturnIn and all nine commands use the default queue-full behavior, so a message that arrives at a full queue hits FW_ASSERT(qStatus == Os::Queue::OP_OK) and the deployment aborts. Only pingIn declares drop.

Received PDUs arrive at the rate the link delivers them. If the upstream producer gets one queue depth ahead of the component thread (30 messages in the stock FileHandlingCfdp configuration), the next PDU ends the process that hosts CfdpManager. This is the same pattern #6389 addresses in Svc::CmdDispatcher.

Changing dataIn alone would not be enough. All of these inputs share one queue, so once received traffic keeps it full, the next 1 Hz tick, returned buffer or command reaches the same assertion.

Changes

  • CfdpManager.fpp / Commands.fppi: non-fatal queue-full policies. run1Hz gets drop; dataIn, dataReturnIn and every command get hook.
  • CfdpManager.cpp / .hpp: the overflow hooks.
    • dataIn: the PDU is dropped. The buffer goes back through dataInReturn, the drop is counted, and the new DataInQueueOverflow event is emitted. Class 2 recovers through NAK or timer retransmission; Class 1 loses the PDU.
    • dataReturnIn: the buffer is deallocated through bufferDeallocate directly. Nothing is lost, because that is all the handler does.
    • Commands: the command is not executed. It is answered with BUSY and the new CommandQueueOverflow event is emitted.
    • Threading: the hooks run on the caller's thread, so they use only output ports, events and atomic counters. The dataIn drop count is added to recvDropped on the component thread at the next run1Hz.
  • Events.fppi: DataInQueueOverflow and CommandQueueOverflow, both warning high and throttled to 5. Each is re-armed by the first run1Hz cycle with no overflow of its kind.
  • docs/sdd.md: a new Queue Overflow section, the port, event, telemetry and command tables, and requirement CFDP-016.
  • Unit tests (QueueOverflow.*), each filling the test queue before sending one more message:
    • DataIn: the buffer is returned at once, the event is emitted, and recvDropped rises at the next tick.
    • DataInEventThrottle: only 5 events for a longer burst, and the event fires again after a clean cycle.
    • DataReturnIn: the buffer is deallocated at once.
    • Run1Hz: the tick is dropped and the next one is handled normally.
    • Command: BUSY response and event for a command with and without arguments, and neither command runs.

Testing

CfdpManager UTs: 222/222 pass. The new tests cannot be built against the old model, since they use the new events; before this change the same sequence (fill the queue, send one more dataIn) aborts with the queue-full assertion. No deployment was built for this change.

Notes

  • A dropped run1Hz tick is silent. Protocol timers and telemetry slip one second per dropped tick. pingIn already drops, so a queue that stays full shows up through the health monitor.
  • Commands answer BUSY, where Svc/CmdDispatcher: drop instead of assert when compCmdStat or own commands overflow the queue #6389 leaves a dropped CmdDispatcher command without a response. Here the hook can respond, so the command does not stay pending.
  • The component connected to bufferDeallocate now also receives calls from the thread that drives dataReturnIn. Svc::BufferManager already handles this.
  • Dropping is a last resort. Queue depth, upstream buffer pool and thread priority should still be sized for the PDU rate the link can deliver.
  • CfdpManager: refuse to send a source file larger than FileSize can represent #6416 also adds a CFDP-016 requirement and touches the same test files, so whichever merges second needs renumbering and a small rebase.

AI Usage

Generative AI was used in this contribution: AI. The code change, unit tests, SDD text, and this description were written with Claude Code and reviewed by the contributor.

🤖 Generated with Claude Code

IAMAI

run1Hz, dataIn, dataReturnIn and every command used the default
queue-full behavior, so a message that arrived at a full queue raised a
FATAL assertion. Received PDUs arrive at the rate the link delivers
them, so a burst that gets ahead of the component thread could end the
process hosting CfdpManager.

Give each of these inputs a non-fatal queue-full policy:

- dataIn: drop the PDU, return its buffer through dataInReturn, count
  it in recvDropped and emit the throttled DataInQueueOverflow warning.
- dataReturnIn: deallocate the buffer directly, so nothing leaks.
- run1Hz: drop the tick.
- commands: respond BUSY and emit the throttled CommandQueueOverflow
  warning.

The hooks run on the caller's thread and use only output ports, events
and atomic counters. The dataIn drop count is folded into telemetry on
the component thread at the next run1Hz cycle, which also re-arms the
throttled events after a cycle with no overflow.

Add unit tests for each input and document the behaviour and
requirement CFDP-016 in the SDD.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Coverage report — base devel

Overall (line): 85.73% → 85.68% (-0.05)
Regression threshold: 0.50% (line).

Regressions

(none over threshold)

Modules changed

Module Line Δ Function Δ Branch Δ
Os/Generic 89.78 -0.50 89.13 +0.00 75.29 -0.19
Svc/Ccsds/CfdpManager 90.38 -0.42 95.24 -1.65 78.19 +0.09
Os/Posix 70.64 -0.39 87.50 +0.00 50.89 +0.00
Fw/DataStructures 97.69 -0.35 97.14 +0.00 82.30 -0.55
Os/Generic/Types 92.14 +0.35 92.86 +0.00 72.90 -2.80

New modules

Module Line Function Branch
Fw/Prm 0.00 0.00 0.00

Modules without UTs

CFDP/Checksum/GTest, Drv/LinuxGpioDriver, Drv/LinuxI2cDriver, Drv/LinuxSpiDriver, Drv/Ports/DataTypes, Drv/PosixUartDriver, FppTestProject/FppTest/topology/async, FppTestProject/FppTest/topology/components/Comp, FppTestProject/FppTest/topology/components/Framework, FppTestProject/FppTest/topology/components/Receiver, FppTestProject/FppTest/topology/components/Sender, FppTestProject/FppTest/topology/guarded, FppTestProject/FppTest/topology/sync, FppTestProject/FppTest/topology/top_ports, FppTestProject/FppTest/topology/types, Fw/Com, Fw/Comp, Fw/FilePacket/GTest, Fw/Fpy, Fw/Obj, Fw/Port, Fw/Sm, Fw/Test, Fw/Types/GTest, Os/Models, Svc/Ccsds/Types, Svc/Ccsds/Utils, Svc/FatalHandler, Svc/Subtopologies/CdhCore, Svc/Subtopologies/ComCcsds, Svc/Subtopologies/ComCcsdsSdls, Svc/Subtopologies/ComFprime, Svc/Subtopologies/ComLoggerTee, Svc/Subtopologies/DataProducts, Svc/Subtopologies/DpCompression, Svc/Subtopologies/FileHandling, Svc/Subtopologies/FileHandlingCfdp, Svc/Subtopologies/FileHandlingCfdp/FileHandlingCfdpConfig, TestDeploymentsProject/Ref/DpDemo, TestDeploymentsProject/Ref/PingReceiver, TestDeploymentsProject/Ref/RecvBuffApp, TestDeploymentsProject/Ref/SendBuffApp, TestDeploymentsProject/Ref/Top, TestDeploymentsProject/Ref/TypeDemo, cmake/test/data/TestConfigDeployment, cmake/test/data/TestDeployment/TestBuildAutocoder, cmake/test/data/TestDeployment/TestDuplicateDirective, cmake/test/data/TestDeployment/TestHeaderAutocoder, cmake/test/data/TestDeployment/TestLinkDepends, cmake/test/data/TestDeployment/TestRelative, cmake/test/data/test-fprime-library/TestLibrary/TestComponent, cmake/test/data/test-fprime-library2/TestLibrary2/TestComponent

@lestarch-autobot

Copy link
Copy Markdown
Collaborator

Hello @bitWarrior, and thank you for contributing to F´!

This pull request is signed IAMAI, indicating it was produced by an AI agent. Per the contributor guidelines, all code contributions begin with an issue that is reviewed and approved by the Change Control Board (CCB) before implementation work starts. This gate exists to keep limited maintainer review time focused on work that is in scope for F´.

At the moment this PR does not link to an issue that the CCB has reviewed.

Recommendation to maintainers: close this PR for now, and reopen it once the CCB has weighed in on the linked issue(s). If the CCB approves, the work here can be picked back up immediately.

This is an automated notice from lestarch-autobot. It is a process note, not a judgment on the quality of the contribution.

@thomas-bc

thomas-bc commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

A generic approach should be agreed upon at the framework level, not for every async port instance. Opened #6422 to discuss

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: CCB

Development

Successfully merging this pull request may close these issues.

4 participants