Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[22658] Reliable volatile change dropped when all history acked (backport #5606) #5613

Merged
merged 1 commit into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/cpp/rtps/writer/StatefulWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1516,7 +1516,9 @@ void StatefulWriter::check_acked_status()

if (min_low_mark >= get_seq_num_min())
{
may_remove_change_ = 1;
// get_seq_num_min() returns SequenceNumber_t::unknown() when the history is empty.
// Thus, it is set to 2 to indicate that all samples have been removed.
may_remove_change_ = (get_seq_num_min() == SequenceNumber_t::unknown()) ? 2 : 1;
}

min_readers_low_mark_ = min_low_mark;
Expand Down
9 changes: 9 additions & 0 deletions test/blackbox/api/dds-pim/PubSubWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,15 @@ class PubSubWriter
return *this;
}

PubSubWriter& reliability(
const eprosima::fastdds::dds::ReliabilityQosPolicyKind kind,
eprosima::fastdds::dds::Duration_t max_blocking_time)
{
datawriter_qos_.reliability().kind = kind;
datawriter_qos_.reliability().max_blocking_time = max_blocking_time;
return *this;
}

PubSubWriter& mem_policy(
const eprosima::fastdds::rtps::MemoryManagementPolicy mem_policy)
{
Expand Down
40 changes: 40 additions & 0 deletions test/blackbox/common/DDSBlackboxTestsListeners.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3436,6 +3436,46 @@ TEST(DDSStatus, keyed_reliable_positive_acks_disabled_on_unack_sample_removed)
delete dummy_data;
}

/*!
* Regression Test for 22658: when the entire history is acked in volatile, given that the entries are deleted from the
* history, check_acked_status satisfies min_low_mark >= get_seq_num_min() because seq_num_min is unknown. This makes
* try_remove to fail, because it tries to remove changes but there were none. This causes prepare_change to not
* perform the changes, since the history was full and could not delete any changes.
*/

TEST(DDSStatus, entire_history_acked_volatile_unknown_pointer)
{
PubSubWriter<HelloWorldPubSubType> writer(TEST_TOPIC_NAME);
PubSubReader<HelloWorldPubSubType> reader(TEST_TOPIC_NAME);

writer.reliability(eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS, eprosima::fastdds::dds::Duration_t (200, 0))
.durability_kind(eprosima::fastdds::dds::VOLATILE_DURABILITY_QOS)
.history_kind(eprosima::fastdds::dds::KEEP_ALL_HISTORY_QOS)
.resource_limits_max_instances(1)
.resource_limits_max_samples(1)
.resource_limits_max_samples_per_instance(1)
.init();
ASSERT_TRUE(writer.isInitialized());

reader.reliability(eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS)
.durability_kind(eprosima::fastdds::dds::VOLATILE_DURABILITY_QOS)
.init();
ASSERT_TRUE(reader.isInitialized());

// Wait for discovery
writer.wait_discovery();
reader.wait_discovery();

auto data = default_helloworld_data_generator(2);
for (auto sample : data)
{
// A value of true means that the sample was sent successfully.
// This aligns with the expected behaviour of having the history
// acknowledged and emptied before the next message.
EXPECT_TRUE(writer.send_sample(sample));
}
}

/*!
* Test that checks with a writer of each type that having the same listener attached, the notified writer in the
* callback is the corresponding writer that has removed a sample unacknowledged.
Expand Down
Loading