Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
May 31, 2024

Conversation

Mario-DL
Copy link
Member

@Mario-DL Mario-DL commented May 21, 2024

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

  • 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

  • The PR has a milestone assigned.
  • The title and description correctly express the PR's purpose.
  • Check contributor checklist is correct.
  • Check CI results: changes do not issue any warning.
  • Check CI results: failing tests are unrelated with the changes.

@Mario-DL Mario-DL added this to the v3.0.0 milestone May 21, 2024
@Mario-DL Mario-DL requested a review from richiprosima May 21, 2024 13:16
@github-actions github-actions bot added the ci-pending PR which CI is running label May 21, 2024
@Mario-DL Mario-DL requested review from richiprosima and removed request for richiprosima May 21, 2024 14:46
@elianalf elianalf added the needs-review PR that is ready to be reviewed label May 23, 2024
@MiguelCompany MiguelCompany self-requested a review May 27, 2024 13:07
Mario-DL added 2 commits May 30, 2024 10:19
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
@Mario-DL Mario-DL requested review from MiguelCompany and removed request for MiguelCompany May 30, 2024 09:14
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
@Mario-DL Mario-DL requested review from MiguelCompany and removed request for richiprosima and MiguelCompany May 30, 2024 10:35
@MiguelCompany
Copy link
Member

@richiprosima Please test_3 this

Copy link
Member

@MiguelCompany MiguelCompany left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a small nit, can be applied without running CI again

src/cpp/rtps/writer/LivelinessManager.hpp Outdated Show resolved Hide resolved
@MiguelCompany MiguelCompany removed the needs-review PR that is ready to be reviewed label May 30, 2024
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
@MiguelCompany
Copy link
Member

@richiprosima Please test_3 linux

@elianalf elianalf added ready-to-merge Ready to be merged. CI and changes have been reviewed and approved. and removed ci-pending PR which CI is running labels May 31, 2024
@MiguelCompany MiguelCompany merged commit df90943 into master May 31, 2024
4 checks passed
@MiguelCompany MiguelCompany deleted the bugfix/21065 branch May 31, 2024 07:58
@MiguelCompany
Copy link
Member

@Mergifyio backport 2.14.x 2.13.x 2.10.x 2.6.x

Copy link
Contributor

mergify bot commented May 31, 2024

backport 2.14.x 2.13.x 2.10.x 2.6.x

✅ Backports have been created

mergify bot pushed a commit that referenced this pull request May 31, 2024
…s on the same topic (#4822)

* Refs #21065: Add BB test

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #21065: Add fix rework after sync with Miguel

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* REfs #21065: Correct windows NIT

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #21065: Apply NIT

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

---------

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
(cherry picked from commit df90943)

# Conflicts:
#	include/fastdds/rtps/writer/LivelinessManager.h
#	src/cpp/rtps/writer/LivelinessManager.cpp
#	test/unittest/rtps/writer/LivelinessManagerTests.cpp
mergify bot pushed a commit that referenced this pull request May 31, 2024
…s on the same topic (#4822)

* Refs #21065: Add BB test

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #21065: Add fix rework after sync with Miguel

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* REfs #21065: Correct windows NIT

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #21065: Apply NIT

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

---------

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
(cherry picked from commit df90943)

# Conflicts:
#	include/fastdds/rtps/writer/LivelinessManager.h
#	src/cpp/rtps/writer/LivelinessManager.cpp
#	test/unittest/rtps/writer/LivelinessManagerTests.cpp
mergify bot pushed a commit that referenced this pull request May 31, 2024
…s on the same topic (#4822)

* Refs #21065: Add BB test

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #21065: Add fix rework after sync with Miguel

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* REfs #21065: Correct windows NIT

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #21065: Apply NIT

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

---------

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
(cherry picked from commit df90943)

# Conflicts:
#	include/fastdds/rtps/writer/LivelinessManager.h
#	src/cpp/rtps/writer/LivelinessManager.cpp
#	test/unittest/rtps/writer/LivelinessManagerTests.cpp
mergify bot pushed a commit that referenced this pull request May 31, 2024
…s on the same topic (#4822)

* Refs #21065: Add BB test

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #21065: Add fix rework after sync with Miguel

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* REfs #21065: Correct windows NIT

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #21065: Apply NIT

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

---------

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
(cherry picked from commit df90943)

# Conflicts:
#	include/fastdds/rtps/writer/LivelinessManager.h
#	src/cpp/rtps/writer/LivelinessManager.cpp
#	test/unittest/rtps/writer/LivelinessManagerTests.cpp
EduPonz pushed a commit that referenced this pull request Jun 5, 2024
…enario (#4822) (#4881)

* Correctly call `on_liveliness_changed` when there are multiple readers on the same topic (#4822)

* Refs #21065: Add BB test

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #21065: Add fix rework after sync with Miguel

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* REfs #21065: Correct windows NIT

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #21065: Apply NIT

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

---------

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
(cherry picked from commit df90943)

# Conflicts:
#	include/fastdds/rtps/writer/LivelinessManager.h
#	src/cpp/rtps/writer/LivelinessManager.cpp
#	test/unittest/rtps/writer/LivelinessManagerTests.cpp

* Solve conflicts

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

---------

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
Co-authored-by: Mario Domínguez López <116071334+Mario-DL@users.noreply.github.com>
Co-authored-by: Mario Dominguez <mariodominguez@eprosima.com>
EduPonz pushed a commit that referenced this pull request Jun 5, 2024
…enario (#4822) (#4884)

* Correctly call `on_liveliness_changed` when there are multiple readers on the same topic (#4822)

* Refs #21065: Add BB test

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #21065: Add fix rework after sync with Miguel

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* REfs #21065: Correct windows NIT

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #21065: Apply NIT

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

---------

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
(cherry picked from commit df90943)

# Conflicts:
#	include/fastdds/rtps/writer/LivelinessManager.h
#	src/cpp/rtps/writer/LivelinessManager.cpp
#	test/unittest/rtps/writer/LivelinessManagerTests.cpp

* Solve conflicts

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

---------

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
Co-authored-by: Mario Domínguez López <116071334+Mario-DL@users.noreply.github.com>
Co-authored-by: Mario Dominguez <mariodominguez@eprosima.com>
MiguelCompany pushed a commit that referenced this pull request Jun 6, 2024
…on the same topic (#4822) (#4882)

* Correctly call `on_liveliness_changed` when there are multiple readers on the same topic (#4822)

* Refs #21065: Add BB test

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #21065: Add fix rework after sync with Miguel

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* REfs #21065: Correct windows NIT

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #21065: Apply NIT

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

---------

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
(cherry picked from commit df90943)

# Conflicts:
#	include/fastdds/rtps/writer/LivelinessManager.h
#	src/cpp/rtps/writer/LivelinessManager.cpp
#	test/unittest/rtps/writer/LivelinessManagerTests.cpp

* Solve conflicts

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

---------

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
Co-authored-by: Mario Domínguez López <116071334+Mario-DL@users.noreply.github.com>
Co-authored-by: Mario Dominguez <mariodominguez@eprosima.com>
MiguelCompany pushed a commit that referenced this pull request Jun 10, 2024
…s on the same topic (#4822) (#4883)

* Correctly call `on_liveliness_changed` when there are multiple readers on the same topic (#4822)

* Refs #21065: Add BB test

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #21065: Add fix rework after sync with Miguel

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* REfs #21065: Correct windows NIT

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #21065: Apply NIT

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

---------

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
(cherry picked from commit df90943)

# Conflicts:
#	include/fastdds/rtps/writer/LivelinessManager.h
#	src/cpp/rtps/writer/LivelinessManager.cpp
#	test/unittest/rtps/writer/LivelinessManagerTests.cpp

* Solve conflicts

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

---------

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
Co-authored-by: Mario Domínguez López <116071334+Mario-DL@users.noreply.github.com>
Co-authored-by: Mario Dominguez <mariodominguez@eprosima.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge Ready to be merged. CI and changes have been reviewed and approved.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect state of Liveliness of Readers who accept data from a single Writer
3 participants