Skip to content

Conversation

@raulojeda22
Copy link
Contributor

@raulojeda22 raulojeda22 commented Dec 31, 2025

Description

This PR fixes a bug where DataReader was incorrectly using history.depth instead of max_samples_per_instance when depth > max_samples_per_instance.

Current Behavior (Bug)

When a DataReader is configured with:

  • history.depth = 10
  • max_samples_per_instance = 5

The QoS validation correctly warns:

HISTORY DEPTH '10' is inconsistent with max_samples_per_instance: '5'. 
Effectively using max_samples_per_instance as depth.

However, the DataReader was actually storing 10 samples (using depth) instead of 5 (using max_samples_per_instance), making the warning misleading.

Root Cause

The bug existed in three locations:

  1. DataReaderHistory constructor: For NO_KEY topics, max_samples_per_instance was being overwritten with max_samples, destroying the user's QoS setting
  2. DataReaderHistory::received_change_keep_last: Was checking instance_changes.size() < depth instead of instance_changes.size() < min(depth, max_samples_per_instance)
  3. DataReaderHistory::completed_change_keep_last: Same issue for fragmented samples

Changes

  • Fixed all three locations to use min(history.depth, max_samples_per_instance) as the effective limit
  • Updated DataWriterHistory::to_history_attributes for consistency in memory allocation
  • Added unit tests covering:
    • NO_KEY topics (critical case where constructor was overwriting QoS)
    • WITH_KEY topics

Impact

This fix ensures the DataReader behavior matches the documented QoS warning message. Applications relying on max_samples_per_instance to limit memory usage will now work correctly.

@Mergifyio backport 3.4.x 3.3.x 3.2.x 2.14.x

Contributor Checklist

  • Commit messages follow the project guidelines.
  • The code follows the style guidelines of this project.
  • Tests that thoroughly check the new feature have been added/Regression tests checking the bug and its fix have been added; the added tests pass locally
  • Any new/modified methods have been properly documented using Doxygen.
  • N/A Any new configuration API has an equivalent XML API (with the corresponding XSD extension)
  • Changes are backport compatible: they do NOT break ABI nor change library core behavior.
  • Changes are API compatible.
  • N/A New feature has been added to the versions.md file (if applicable).
  • N/A New feature has been documented/Current behavior is correctly described in the documentation.
  • Applicable backports have been included in the description.

Reviewer Checklist

  • The PR has a milestone assigned.
  • The title and description correctly express the PR's purpose.
  • Check contributor checklist is correct.
  • If this is a critical bug fix, backports to the critical-only supported branches have been requested.
  • Check CI results: changes do not issue any warning.
  • Check CI results: failing tests are unrelated with the changes.

@github-actions github-actions bot added the ci-pending PR which CI is running label Dec 31, 2025
@mergify
Copy link
Contributor

mergify bot commented Dec 31, 2025

🧪 CI Insights

Here's what we observed from your CI run for d7266a4.

❌ Job Failures

Pipeline Job Health on 3.4.x Retries 🔍 CI Insights 📄 Logs
Fast DDS MacOS CI mac-ci / fastdds_test () Unknown 0 View View
Fast DDS Ubuntu CI ubuntu-ci / fastdds_docs_test (RelWithDebInfo) Unknown 0 View View
ubuntu-ci / fastdds_test (RelWithDebInfo) Unknown 0 View View
Fast DDS Windows CI windows-ci / fastdds_test (RelWithDebInfo, blackbox), v142 Unknown 0 View View
windows-ci / fastdds_test (RelWithDebInfo, blackbox), v143 Unknown 0 View View
windows-ci / fastdds_test (RelWithDebInfo, unittest-II), v143 Unknown 0 View View

@raulojeda22 raulojeda22 force-pushed the hotfix/depth_vs_max_spi branch from 37561c7 to 5259203 Compare January 7, 2026 15:30
@rsanchez15 rsanchez15 requested review from juanlofer-eprosima and removed request for juanlofer-eprosima January 8, 2026 08:02
@MiguelCompany MiguelCompany added this to the v3.5.0 milestone Jan 12, 2026
@rsanchez15 rsanchez15 changed the base branch from master to 3.4.x January 20, 2026 08:08
@rsanchez15 rsanchez15 modified the milestones: v3.5.0, v3.4.2 Jan 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-pending PR which CI is running

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants