Skip to content

Commit 753ee21

Browse files
mergify[bot]juanjo4936EugenioCollado
authored
Reliable volatile change dropped when all history acked (#5606) (#5616)
* Reliable volatile change dropped when all history acked (#5606) * Refs #22658: Regression test Signed-off-by: Juanjo Garcia <[email protected]> * Refs #22658: Fix bug Signed-off-by: Juanjo Garcia <[email protected]> * Refs #22658: corrected failing CI Signed-off-by: Juanjo Garcia <[email protected]> * Refs #22658: Included reviewer suggestions Signed-off-by: Juanjo Garcia <[email protected]> --------- Signed-off-by: Juanjo Garcia <[email protected]> (cherry picked from commit 90790ce) * Fix namespace Signed-off-by: Eugenio Collado <[email protected]> --------- Signed-off-by: Juanjo Garcia <[email protected]> Signed-off-by: Eugenio Collado <[email protected]> Co-authored-by: juanjo4936 <[email protected]> Co-authored-by: Eugenio Collado <[email protected]>
1 parent 031752b commit 753ee21

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

src/cpp/rtps/writer/StatefulWriter.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1533,7 +1533,9 @@ void StatefulWriter::check_acked_status()
15331533

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

15391541
min_readers_low_mark_ = min_low_mark;

test/blackbox/api/dds-pim/PubSubWriter.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,15 @@ class PubSubWriter
833833
return *this;
834834
}
835835

836+
PubSubWriter& reliability(
837+
const eprosima::fastdds::dds::ReliabilityQosPolicyKind kind,
838+
eprosima::fastrtps::Duration_t max_blocking_time)
839+
{
840+
datawriter_qos_.reliability().kind = kind;
841+
datawriter_qos_.reliability().max_blocking_time = max_blocking_time;
842+
return *this;
843+
}
844+
836845
PubSubWriter& mem_policy(
837846
const eprosima::fastrtps::rtps::MemoryManagementPolicy mem_policy)
838847
{

test/blackbox/common/DDSBlackboxTestsListeners.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3388,6 +3388,46 @@ TEST(DDSStatus, keyed_reliable_positive_acks_disabled_on_unack_sample_removed)
33883388
delete dummy_data;
33893389
}
33903390

3391+
/*!
3392+
* Regression Test for 22658: when the entire history is acked in volatile, given that the entries are deleted from the
3393+
* history, check_acked_status satisfies min_low_mark >= get_seq_num_min() because seq_num_min is unknown. This makes
3394+
* try_remove to fail, because it tries to remove changes but there were none. This causes prepare_change to not
3395+
* perform the changes, since the history was full and could not delete any changes.
3396+
*/
3397+
3398+
TEST(DDSStatus, entire_history_acked_volatile_unknown_pointer)
3399+
{
3400+
PubSubWriter<HelloWorldPubSubType> writer(TEST_TOPIC_NAME);
3401+
PubSubReader<HelloWorldPubSubType> reader(TEST_TOPIC_NAME);
3402+
3403+
writer.reliability(eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS, eprosima::fastrtps::Duration_t (200, 0))
3404+
.durability_kind(eprosima::fastdds::dds::VOLATILE_DURABILITY_QOS)
3405+
.history_kind(eprosima::fastdds::dds::KEEP_ALL_HISTORY_QOS)
3406+
.resource_limits_max_instances(1)
3407+
.resource_limits_max_samples(1)
3408+
.resource_limits_max_samples_per_instance(1)
3409+
.init();
3410+
ASSERT_TRUE(writer.isInitialized());
3411+
3412+
reader.reliability(eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS)
3413+
.durability_kind(eprosima::fastdds::dds::VOLATILE_DURABILITY_QOS)
3414+
.init();
3415+
ASSERT_TRUE(reader.isInitialized());
3416+
3417+
// Wait for discovery
3418+
writer.wait_discovery();
3419+
reader.wait_discovery();
3420+
3421+
auto data = default_helloworld_data_generator(2);
3422+
for (auto sample : data)
3423+
{
3424+
// A value of true means that the sample was sent successfully.
3425+
// This aligns with the expected behaviour of having the history
3426+
// acknowledged and emptied before the next message.
3427+
EXPECT_TRUE(writer.send_sample(sample));
3428+
}
3429+
}
3430+
33913431
/*!
33923432
* Test that checks with a writer of each type that having the same listener attached, the notified writer in the
33933433
* callback is the corresponding writer that has removed a sample unacknowledged.

0 commit comments

Comments
 (0)