You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/11/10 22:10:35 UTC
[lucene-solr] 07/07: @1149 Whoops, need stronger sync.
This is an automated email from the ASF dual-hosted git repository.
markrmiller pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit 1af452d8855716e4c5f54d82753523a6342ad016
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Tue Nov 10 16:10:06 2020 -0600
@1149 Whoops, need stronger sync.
---
.../apache/solr/common/cloud/ZkStateReader.java | 59 ++++++++++++----------
1 file changed, 32 insertions(+), 27 deletions(-)
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
index 31cf7d6..88c962d 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/ZkStateReader.java
@@ -1636,22 +1636,25 @@ public class ZkStateReader implements SolrCloseable, Replica.NodeNameToBaseUrl {
AtomicBoolean watchSet = new AtomicBoolean(false);
- collectionWatches.compute(collection, (k, v) -> {
- if (v == null) {
- v = new CollectionWatch<>();
- watchSet.set(true);
- }
- v.stateWatchers.add(stateWatcher);
- return v;
- });
+ synchronized (collectionWatches) {
- if (watchSet.get()) {
- new StateWatcher(collection).refreshAndWatch();
- }
+ collectionWatches.compute(collection, (k, v) -> {
+ if (v == null) {
+ v = new CollectionWatch<>();
+ watchSet.set(true);
+ }
+ v.stateWatchers.add(stateWatcher);
+ return v;
+ });
- DocCollection state = clusterState.getCollectionOrNull(collection);
- if (stateWatcher.onStateChanged(state) == true) {
- removeDocCollectionWatcher(collection, stateWatcher);
+ if (watchSet.get()) {
+ new StateWatcher(collection).refreshAndWatch();
+ }
+
+ DocCollection state = clusterState.getCollectionOrNull(collection);
+ if (stateWatcher.onStateChanged(state) == true) {
+ removeDocCollectionWatcher(collection, stateWatcher);
+ }
}
}
@@ -1866,19 +1869,21 @@ public class ZkStateReader implements SolrCloseable, Replica.NodeNameToBaseUrl {
}
AtomicBoolean reconstructState = new AtomicBoolean(false);
-
- collectionWatches.compute(collection, (k, v) -> {
- if (v == null) return null;
- v.stateWatchers.remove(watcher);
- if (v.canBeRemoved()) {
- log.info("no longer watch collection {}", collection);
- watchedCollectionStates.remove(collection);
- lazyCollectionStates.put(collection, new LazyCollectionRef(collection));
- reconstructState.set(true);
- return null;
- }
- return v;
- });
+ synchronized (collectionWatches) {
+
+ collectionWatches.compute(collection, (k, v) -> {
+ if (v == null) return null;
+ v.stateWatchers.remove(watcher);
+ if (v.canBeRemoved()) {
+ log.info("no longer watch collection {}", collection);
+ watchedCollectionStates.remove(collection);
+ lazyCollectionStates.put(collection, new LazyCollectionRef(collection));
+ reconstructState.set(true);
+ return null;
+ }
+ return v;
+ });
+ }
if (reconstructState.get()) {
updateLock.lock();