Skip to content

Commit 1ba6439

Browse files
juanjo4936RookieCLY
authored andcommitted
Reliable volatile change dropped when all history acked (eProsima#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]> Signed-off-by: RookieCLY <[email protected]>
1 parent 439100d commit 1ba6439

File tree

3 files changed

+52
-1
lines changed

3 files changed

+52
-1
lines changed

src/cpp/rtps/writer/StatefulWriter.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,9 @@ void StatefulWriter::check_acked_status()
15211521

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

15271529
min_readers_low_mark_ = min_low_mark;

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

+9
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,15 @@ class PubSubWriter
892892
return *this;
893893
}
894894

895+
PubSubWriter& reliability(
896+
const eprosima::fastdds::dds::ReliabilityQosPolicyKind kind,
897+
eprosima::fastdds::dds::Duration_t max_blocking_time)
898+
{
899+
datawriter_qos_.reliability().kind = kind;
900+
datawriter_qos_.reliability().max_blocking_time = max_blocking_time;
901+
return *this;
902+
}
903+
895904
PubSubWriter& mem_policy(
896905
const eprosima::fastdds::rtps::MemoryManagementPolicy mem_policy)
897906
{

test/blackbox/common/DDSBlackboxTestsListeners.cpp

+40
Original file line numberDiff line numberDiff line change
@@ -3436,6 +3436,46 @@ TEST(DDSStatus, keyed_reliable_positive_acks_disabled_on_unack_sample_removed)
34363436
delete dummy_data;
34373437
}
34383438

3439+
/*!
3440+
* Regression Test for 22658: when the entire history is acked in volatile, given that the entries are deleted from the
3441+
* history, check_acked_status satisfies min_low_mark >= get_seq_num_min() because seq_num_min is unknown. This makes
3442+
* try_remove to fail, because it tries to remove changes but there were none. This causes prepare_change to not
3443+
* perform the changes, since the history was full and could not delete any changes.
3444+
*/
3445+
3446+
TEST(DDSStatus, entire_history_acked_volatile_unknown_pointer)
3447+
{
3448+
PubSubWriter<HelloWorldPubSubType> writer(TEST_TOPIC_NAME);
3449+
PubSubReader<HelloWorldPubSubType> reader(TEST_TOPIC_NAME);
3450+
3451+
writer.reliability(eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS, eprosima::fastdds::dds::Duration_t (200, 0))
3452+
.durability_kind(eprosima::fastdds::dds::VOLATILE_DURABILITY_QOS)
3453+
.history_kind(eprosima::fastdds::dds::KEEP_ALL_HISTORY_QOS)
3454+
.resource_limits_max_instances(1)
3455+
.resource_limits_max_samples(1)
3456+
.resource_limits_max_samples_per_instance(1)
3457+
.init();
3458+
ASSERT_TRUE(writer.isInitialized());
3459+
3460+
reader.reliability(eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS)
3461+
.durability_kind(eprosima::fastdds::dds::VOLATILE_DURABILITY_QOS)
3462+
.init();
3463+
ASSERT_TRUE(reader.isInitialized());
3464+
3465+
// Wait for discovery
3466+
writer.wait_discovery();
3467+
reader.wait_discovery();
3468+
3469+
auto data = default_helloworld_data_generator(2);
3470+
for (auto sample : data)
3471+
{
3472+
// A value of true means that the sample was sent successfully.
3473+
// This aligns with the expected behaviour of having the history
3474+
// acknowledged and emptied before the next message.
3475+
EXPECT_TRUE(writer.send_sample(sample));
3476+
}
3477+
}
3478+
34393479
/*!
34403480
* Test that checks with a writer of each type that having the same listener attached, the notified writer in the
34413481
* callback is the corresponding writer that has removed a sample unacknowledged.

0 commit comments

Comments
 (0)