merlimat commented on a change in pull request #12120:
URL: https://github.com/apache/pulsar/pull/12120#discussion_r714949186
##########
File path:
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/AbstractMetadataStore.java
##########
@@ -65,6 +67,9 @@
private final AsyncLoadingCache<String, Boolean> existsCache;
private final CopyOnWriteArrayList<MetadataCacheImpl<?>> metadataCaches =
new CopyOnWriteArrayList<>();
+ @Getter
+ private boolean isConnected = true;
Review comment:
What volatile gives you is that if you modify that variable (in a
particular sequence), you're guaranteed to immediately see the change from a
different thread (in same consistent order in which they were changed).
If it's not volatile, the other thread will see that change some time later.
Typically that corresponds to when either thread writing or reading is
encountering a memory barrier (on *any* other variable). In practice it means
that the flag will be visible in a tiny amount of time.
We're extensively using this approach when reading stats and similars, so
that we can expose values without paying the price each time.
For this particular usage, I mentioned that this is best effort. The reason
is that when we detect that the ZK connection is broken, it's already "late".
The detection is based on running a probe every 2sec to validate ZK
connectivity, so when the prob fails, we already got some time in which we
thought we were connected but we're really not anymore.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]