Repository navigation
Conversation
This is interesting that broker2 does not receive the event |
@Jason918 - you're correct, broker 2 does not receive this notification. If I understand correctly, it doesn't get that notification because it isn't watching that node. It is watching |
lhotari
left a comment
There was a problem hiding this comment.
LGTM, Great analysis and good work @michaeljmarshall
| List<String> topics = second.topics().getList("public/default"); | ||
| assertTrue(topics.contains("persistent://public/default/my-topic")); | ||
| } | ||
| } |
There was a problem hiding this comment.
@michaeljmarshall This test should go in the pulsar-metadata module (without using the `PulsarAdmin) and we can test across all the backends
There was a problem hiding this comment.
Are you asking for a more generic test in addition to this one or instead of this one? Since we don't have the broker in pulsar-metadata, it seems like I can only write a test that ensures a notification for Created/Deleted triggers cache invalidation for the path on childrenCache. We'd also lose the double broker integration test.
There was a problem hiding this comment.
yes, we can double the test to just verify the cache correctness without needing a broker.
though, I just saw that this is for 2.8 and I believe we should already have tests covering this scenario in master (or 2.9)
Motivation
In Pulsar 2.8, there is currently a bug that can lead to an incorrectly cached value in the
childrenCache. The resulting behavior is that the broker serves the stale cache value until it is evicted from the cache.Steps to Reproduce Issue
Start a 2.8 cluster with at least 2 brokers. It is helpful to run with debug logging to observe the ZK watch notifications. Run the following bash commands in order:
When broker 2 handles the command for
bin/pulsar-admin --admin-url http://$BROKER_2:8080 topics list test/a, it caches a miss in thechildrenCacheinAbstractMetadataStorefor path/managed-ledgers/test/a/persistent.After caching the miss, broker 2 only logs two ZK events:
Note that the second even is of type
NodeCreated. Because of its type, theAbstractMetadataStoredoes not invalidate the correct node in thechildrenCache:pulsar/pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/AbstractMetadataStore.java
Lines 163 to 182 in 42422d8
I was not able to reproduce this issue in 2.9. My theory is that we get around it because we have a persistent watch at
/.Note also that when creating a second topic in the namespace, we see the following notification:
In this case, we properly invalidate the child node in the cache.
Also note that in 2.7 we always invalidate the child node for a notification. I don't believe this is strictly necessary because we'll get
NodeChildrenChangednotifications when the event is not created/deleted.pulsar/pulsar-zookeeper-utils/src/main/java/org/apache/pulsar/zookeeper/ZooKeeperCache.java
Line 146 in 77f7965
Modifications
pathforchildrenCachewhen thepathis created or deleted.Verifying this change
I added a test that failed before this change and passes after the change.
Does this pull request potentially affect one of the following parts:
This is an internal change.
Documentation
no-need-doc