From 2cb018d47d25391085e47f80fc14b04c4f065ec7 Mon Sep 17 00:00:00 2001 From: Tomoya Fujita Date: Sun, 8 Jun 2025 17:53:04 -0700 Subject: [PATCH 1/3] clip min_low_mark to handle the acked changes properly. Signed-off-by: Tomoya Fujita --- src/cpp/rtps/writer/StatefulWriter.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/cpp/rtps/writer/StatefulWriter.cpp b/src/cpp/rtps/writer/StatefulWriter.cpp index 3133c98c407..2a629f2f61c 100644 --- a/src/cpp/rtps/writer/StatefulWriter.cpp +++ b/src/cpp/rtps/writer/StatefulWriter.cpp @@ -1453,6 +1453,16 @@ void StatefulWriter::check_acked_status() } ); + // In situation that there are recently matched readers to the writer has not yet + // sent changes, both 'min_low_mark = zero' and 'all_acked == true' will be met. + // In this scenario, onWriterChangeReceivedByAll() will be skipped for the acked + // changes, that causes the changes to remain in history indefinitely. + // To prevent this condition, clip min_low_mark to handle the acked changes. + if (all_acked) + { + min_low_mark = mp_history->next_sequence_number() - 1; + } + bool something_changed = all_acked; SequenceNumber_t min_seq = get_seq_num_min(); if (min_seq != SequenceNumber_t::unknown()) From f7d3fd3396a7ff03c6001ba501ce6615a9f4e6e0 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Mon, 9 Jun 2025 07:48:40 +0200 Subject: [PATCH 2/3] Fix build --- src/cpp/rtps/writer/StatefulWriter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cpp/rtps/writer/StatefulWriter.cpp b/src/cpp/rtps/writer/StatefulWriter.cpp index 2a629f2f61c..a7fe361a6e7 100644 --- a/src/cpp/rtps/writer/StatefulWriter.cpp +++ b/src/cpp/rtps/writer/StatefulWriter.cpp @@ -1460,7 +1460,7 @@ void StatefulWriter::check_acked_status() // To prevent this condition, clip min_low_mark to handle the acked changes. if (all_acked) { - min_low_mark = mp_history->next_sequence_number() - 1; + min_low_mark = history_->next_sequence_number() - 1; } bool something_changed = all_acked; From 4480d463e47604563e63ab45c7c362c73abe3b4c Mon Sep 17 00:00:00 2001 From: Tomoya Fujita Date: Mon, 9 Jun 2025 10:37:49 -0700 Subject: [PATCH 3/3] Avoids iterating over sequence numbers already known irrelevant or processed. Signed-off-by: Tomoya Fujita --- src/cpp/rtps/reader/StatefulReader.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cpp/rtps/reader/StatefulReader.cpp b/src/cpp/rtps/reader/StatefulReader.cpp index 1cd27d4ddd5..7a1f8c5c7ce 100644 --- a/src/cpp/rtps/reader/StatefulReader.cpp +++ b/src/cpp/rtps/reader/StatefulReader.cpp @@ -932,8 +932,10 @@ bool StatefulReader::process_gap_msg( // TODO (Miguel C): Refactor this inside WriterProxy SequenceNumber_t auxSN; SequenceNumber_t finalSN = gapList.base(); + // Avoids iterating over sequence numbers already known irrelevant or processed + SequenceNumber_t startSN = std::max(gapStart, pWP->available_changes_max()); History::const_iterator history_iterator = history_->changesBegin(); - for (auxSN = gapStart; auxSN < finalSN; auxSN++) + for (auxSN = startSN; auxSN < finalSN; auxSN++) { if (pWP->irrelevant_change_set(auxSN)) {