EdColeman commented on code in PR #2778:
URL: https://github.com/apache/accumulo/pull/2778#discussion_r926735250
##########
server/base/src/main/java/org/apache/accumulo/server/conf/store/impl/ZooPropStore.java:
##########
@@ -391,4 +416,61 @@ public PropCache getCache() {
public @Nullable VersionedProperties getWithoutCaching(PropStoreKey<?>
propStoreKey) {
return cache.getWithoutCaching(propStoreKey);
}
+
+ /**
+ * Check that the stored version in ZooKeeper matches the version held in
the local snapshot. When
+ * a mismatch is detected, a change event is sent to the prop store which
will cause a re-load. If
+ * the Zookeeper node has been deleted, the local cache entries are removed.
+ * <p>
+ * This method is designed to be called as a scheduled task, so it does not
propagate exceptions
+ * other than interrupted Exceptions so the scheduled tasks will continue to
run.
+ */
+ @SuppressFBWarnings(value = "PREDICTABLE_RANDOM",
+ justification = "random number not used in secure context")
+ private void verifySnapshotVersions() {
+ long refreshStart = System.nanoTime();
+ int keyCount = 0;
+ int keyChangedCount = 0;
+
+ var cacheView = cache.asMap();
+ for (Map.Entry<PropStoreKey<?>,VersionedProperties> entry :
cacheView.entrySet()) {
+ keyCount++;
+ var key = entry.getKey();
+ if (versionChanged(key, entry.getValue())) {
+ keyChangedCount++;
+ propStoreWatcher.signalZkChangeEvent(key);
+ log.debug("data version sync: difference found. forcing configuration
update for {}}", key);
+ }
+ // add small jitter between calls.
+ int randDelay = ThreadLocalRandom.current().nextInt(0, MAX_JITTER_DELAY);
+ try {
+ Thread.sleep(randDelay);
+ } catch (InterruptedException ex) {
+ Thread.currentThread().interrupt();
+ throw new IllegalStateException(ex);
+ }
+ }
+ log.debug("data version sync: Total runtime {} ms for {} entries, changes
detected: {}",
Review Comment:
The message should only be generated once every 15 minutes and seems to
provide a good debug level of configuration health that can provide information
if ZooKeeper synchronization, prop configuration goes of the rails during
system issues and point to other things to investigate why this are "getting
slow"
--
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]