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/10/02 04:15:03 UTC
[lucene-solr] 03/04: @918 Synchronization tweaks.
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 0aa3e895f021ed0c4b79f234cd9c422b7000de5d
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Thu Oct 1 22:49:41 2020 -0500
@918 Synchronization tweaks.
---
.../src/java/org/apache/solr/update/UpdateLog.java | 34 ++++++++++++----------
.../java/org/apache/solr/update/VersionInfo.java | 3 +-
2 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateLog.java b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
index eed84fa..81cf654 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateLog.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateLog.java
@@ -638,7 +638,7 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
* not an in-place update at all, and don't bother about the prevPointer value at
* all (which is -1 as a dummy value).)
*/
- private synchronized long getPrevPointerForUpdate(AddUpdateCommand cmd) {
+ private long getPrevPointerForUpdate(AddUpdateCommand cmd) {
// note: sync required to ensure maps aren't changed out form under us
if (cmd.isInPlaceUpdate()) {
BytesRef indexedId = cmd.getIndexedId();
@@ -736,29 +736,31 @@ public class UpdateLog implements PluginInfoInitialized, SolrMetricProducer {
// We must cause a new IndexReader to be opened before anything looks at these caches again
// so that a cache miss will read fresh data.
RefCounted<SolrIndexSearcher> holder = null;
+ tlogLock.lock();
try {
- holder = uhandler.core.openNewSearcher(true, true);
-
- } catch (Exception e) {
- ParWork.propagateInterrupt(e, true);
- SolrException.log(log, "Error opening realtime searcher", e);
- return null;
- } finally {
- tlogLock.lock();
try {
+ holder = uhandler.core.openNewSearcher(true, true);
+
+ } catch (Exception e) {
+ ParWork.propagateInterrupt(e, true);
+ SolrException.log(log, "Error opening realtime searcher", e);
+ return null;
+ } finally {
+
if (map != null) map.clear();
if (prevMap != null) prevMap.clear();
if (prevMap2 != null) prevMap2.clear();
- } finally {
- tlogLock.unlock();
+
+ if (!returnSearcher && holder != null) holder.decref();
}
- if (!returnSearcher && holder != null) holder.decref();
- }
- if (returnSearcher) {
- return holder;
+ if (returnSearcher) {
+ return holder;
+ }
+ return null;
+ } finally {
+ tlogLock.unlock();
}
- return null;
}
/** currently for testing only */
diff --git a/solr/core/src/java/org/apache/solr/update/VersionInfo.java b/solr/core/src/java/org/apache/solr/update/VersionInfo.java
index a9edf11..efa3676 100644
--- a/solr/core/src/java/org/apache/solr/update/VersionInfo.java
+++ b/solr/core/src/java/org/apache/solr/update/VersionInfo.java
@@ -198,10 +198,11 @@ public class VersionInfo {
// Make sure high bits are moved down, since only the low bits will matter.
// int h = hash + (hash >>> 8) + (hash >>> 16) + (hash >>> 24);
// Assume good hash codes for now.
- int slot = hash & (buckets.length - 1);
+ int slot;
buckUpdateLock.readLock().lock();
VersionBucket bucket;
try {
+ slot = hash & (buckets.length - 1);
bucket = buckets[slot];
} finally {
buckUpdateLock.readLock().unlock();