[21065] Bugfix: correct liveliness state in a multiple reader - one writer scenario (backport #4822) #4882
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR corrects a misbehavior given in a single writer - multiple readers scenario. When the writer is destroyed, the
WriterProxy
is removed from readers. When it is removed from the first one, theLivelinessManager::remove_writer()
returnsfalse
as--writer.count
is1
, hence theliveliness_changed
callback is not triggered (callback_
withinLivelinessManager
is not invoked). When theWriterProxy
is deleted from the second reader, theLivelinessManager::remove_writer()
correctly removes the writer and fires thecallback
. The problem in this case is that, later, inWLP::sub_liveliness_changed()
theupdate_liveliness_changed_status()
is only called for this later reader, since the first one is not matched anymore andreader->matched_writer_is_matched()
returnsfalse
, corrupting its liveliness state. In this situation, if the writer wakes up again, the first reader is going to return analive_count
of2
instead of1
.The fix proposes that every time we unpair a
WriterProxy
from a reader, we should also update the liveliness state for that particular reader. The solution tries to avoid defining extra collections for tracking readers/writers.@Mergifyio backport 2.14.x 2.13.x 2.10.x 2.6.x
Fixes #4610
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.
NO 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.
NO New feature has been added to the
versions.md
file (if applicable).NO New feature has been documented/Current behavior is correctly described in the documentation.
Applicable backports have been included in the description.
Reviewer Checklist
This is an automatic backport of pull request #4822 done by [Mergify](https://mergify.com).