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

[Issue 11153] [pulsar-broker] Fix for missing metadata-store watch events #11157

Closed

Conversation

bharanic-dev
Copy link
Contributor

@bharanic-dev bharanic-dev commented Jun 29, 2021

Fixes #11153

Motivation

There is a race condition between the admin API handler updating the cache with the latest changes and the metadata-store get()/getAsync() API that is invoked in the watch callback. If there is a cache hit in the get()/getAsync(), no watch event gets registered for future updates (this likely only affects zookeeper metadata store). This results in watch events getting missed.

Modifications

The admin API handler should not update the cache. This results in the metadata-store get()/getAsync() API lazily populating the cache via asyncReload().

Fix is to not update the cache in admin API handler.

Verifying this change

  • Make sure that the change passes the CI checks.
  • Added unit test to verify change. Without the fix, the unit test would fail.

This change added tests and can be verified as follows:

Added test org.apache.pulsar.broker.resourcegroup.ResourceGroupConfigListenerTest#testResourceGroupUpdateLoop to verify the changes. The test can be run using mvn command:

mvn test -Dtest=org.apache.pulsar.broker.resourcegroup.ResourceGroupConfigListenerTest#testResourceGroupUpdateLoop -pl pulsar-broker

Documentation

  • Does this pull request introduce a new feature? (no)

this is a bug fix and has no user visible change (except that the issue is fixed). There is no documentation impact.

Bharani Chadalavada added 2 commits June 29, 2021 13:34
- if the cache is updated in admin API handler, the getDataAsync will hit the cache and fails to register a watch for
  future updates.
- fix is to just not update the cache in the admin API handler. This forces the getData APIs to lazily populate the
  cache via asyncReload, also ensuring that a watch is registered for future updates.
@bharanic-dev
Copy link
Contributor Author

@merlimat @jerrypeng @sursingh please help review.

@bharanic-dev
Copy link
Contributor Author

/pulsarbot run-failure-checks

@merlimat
Copy link
Contributor

merlimat commented Jul 2, 2021

@bharanic-dev I think all these problems of watches not being set would be solved by #11198

@bharanic-dev
Copy link
Contributor Author

@merlimat ok. can we please make sure that the unit test in #11155 passes with changes in #11198.

@bharanic-dev
Copy link
Contributor Author

Closing this as, #11198 has been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing metadata-store watch events
2 participants