eProsima / Fast-DDS

The most complete DDS - Proven: Plenty of success cases. Looking for commercial support? Contact info@eprosima.com
https://eprosima.com
Apache License 2.0
2.06k stars 738 forks source link

[21065] Bugfix: correct liveliness state in a multiple reader - one writer scenario (backport #4822) #4884

Closed mergify[bot] closed 1 month ago

mergify[bot] commented 1 month ago

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, the LivelinessManager::remove_writer() returns false as --writer.count is 1, hence the liveliness_changed callback is not triggered (callback_ within LivelinessManager is not invoked). When the WriterProxy is deleted from the second reader, the LivelinessManager::remove_writer() correctly removes the writer and fires the callback. The problem in this case is that, later, in WLP::sub_liveliness_changed() the update_liveliness_changed_status() is only called for this later reader, since the first one is not matched anymore and reader->matched_writer_is_matched() returns false, corrupting its liveliness state. In this situation, if the writer wakes up again, the first reader is going to return an alive_count of 2 instead of 1.

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

Reviewer Checklist

mergify[bot] commented 1 month ago

Cherry-pick of df909438f4442afabc332364dba74c1612209c15 has failed:

On branch mergify/bp/2.6.x/pr-4822
Your branch is up to date with 'origin/2.6.x'.

You are currently cherry-picking commit df909438f.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
    modified:   src/cpp/rtps/builtin/liveliness/WLP.cpp
    modified:   src/cpp/rtps/reader/StatefulReader.cpp
    modified:   src/cpp/rtps/reader/StatelessReader.cpp
    modified:   test/blackbox/common/BlackboxTestsLivelinessQos.cpp

Unmerged paths:
  (use "git add <file>..." to mark resolution)
    both modified:   include/fastdds/rtps/writer/LivelinessManager.h
    both modified:   src/cpp/rtps/writer/LivelinessManager.cpp
    both modified:   test/unittest/rtps/writer/LivelinessManagerTests.cpp

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

Mario-DL commented 1 month ago

@richiprosima please test this