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 2021/02/03 04:58:05 UTC
[lucene-solr] branch reference_impl_dev updated: @1312 Touch up
previous.
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
The following commit(s) were added to refs/heads/reference_impl_dev by this push:
new f13877a @1312 Touch up previous.
f13877a is described below
commit f13877a7bfb4b840eb19b411834d7a1410b84e07
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Tue Feb 2 22:57:36 2021 -0600
@1312 Touch up previous.
---
.../java/org/apache/solr/cloud/LeaderElector.java | 2 +-
.../org/apache/solr/update/AddUpdateCommand.java | 20 ++-------
.../java/org/apache/solr/update/UpdateCommand.java | 6 +--
.../processor/DistributedUpdateProcessor.java | 48 ++++++++++++++++++----
4 files changed, 48 insertions(+), 28 deletions(-)
diff --git a/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java b/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java
index 0fc9d19..38ebbb6 100644
--- a/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java
+++ b/solr/core/src/java/org/apache/solr/cloud/LeaderElector.java
@@ -472,7 +472,7 @@ public class LeaderElector implements Closeable {
}
@Override
- public void close() throws IOException {
+ public synchronized void close() throws IOException {
assert ObjectReleaseTracker.release(this);
state = CLOSED;
this.isClosed = true;
diff --git a/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java b/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java
index 47d3891..234a13d 100644
--- a/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java
+++ b/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java
@@ -58,14 +58,14 @@ public class AddUpdateCommand extends UpdateCommand {
*/
public volatile long prevVersion = -1;
- public boolean overwrite = true;
+ public volatile boolean overwrite = true;
/**
* The term to use to delete an existing document (for dedupe). (optional)
*/
- public Term updateTerm;
+ public volatile Term updateTerm;
- public int commitWithin = -1;
+ public volatile int commitWithin = -1;
public volatile boolean isLastDocInBatch = false;
@@ -159,20 +159,6 @@ public class AddUpdateCommand extends UpdateCommand {
return "(null)";
}
- public boolean hasId() {
- if (req != null) {
- IndexSchema schema = req.getSchema();
- SchemaField sf = schema.getUniqueKeyField();
- if (solrDoc != null && sf != null) {
- SolrInputField field = solrDoc.getField(sf.getName());
- if (field != null) {
- return true;
- }
- }
- }
- return false;
- }
-
/**
*
* @return value of _route_ param({@link ShardParams#_ROUTE_}), otherwise doc id.
diff --git a/solr/core/src/java/org/apache/solr/update/UpdateCommand.java b/solr/core/src/java/org/apache/solr/update/UpdateCommand.java
index a91cf25..b48fe25 100644
--- a/solr/core/src/java/org/apache/solr/update/UpdateCommand.java
+++ b/solr/core/src/java/org/apache/solr/update/UpdateCommand.java
@@ -23,10 +23,10 @@ import org.apache.solr.request.SolrQueryRequest;
*
*/
public abstract class UpdateCommand implements Cloneable {
- protected SolrQueryRequest req;
+ protected volatile SolrQueryRequest req;
protected volatile long version;
- protected String route;
- protected int flags;
+ protected volatile String route;
+ protected volatile int flags;
public static int BUFFERING = 0x00000001; // update command is being buffered.
public static int REPLAY = 0x00000002; // update command is from replaying a log.
diff --git a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
index aa3a9f1..ac68c3e 100644
--- a/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
+++ b/solr/core/src/java/org/apache/solr/update/processor/DistributedUpdateProcessor.java
@@ -316,7 +316,9 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
try {
distCall.call();
} catch (Exception e) {
- log.error("Exception sending dist update", e);
+ if (e instanceof RuntimeException) {
+ throw (RuntimeException) e;
+ }
throw new SolrException(ErrorCode.SERVER_ERROR, e);
}
}
@@ -333,14 +335,20 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
try {
doLocalAdd(cmd);
} catch (Exception e) {
+ Throwable t;
+ if (e instanceof ExecutionException) {
+ t = e.getCause();
+ } else {
+ t = e;
+ }
if (distFuture != null && isLeader && !forwardToLeader) {
distFuture.cancel(false);
cancelCmds.add(cloneCmd);
}
- if (e instanceof RuntimeException) {
- throw (RuntimeException) e;
+ if (t instanceof RuntimeException) {
+ throw (RuntimeException) t;
}
- throw new SolrException(ErrorCode.SERVER_ERROR, e);
+ throw new SolrException(ErrorCode.SERVER_ERROR, t);
}
// if the update updates a doc that is part of a nested structure,
// force open a realTimeSearcher to trigger a ulog cache refresh.
@@ -941,14 +949,40 @@ public class DistributedUpdateProcessor extends UpdateRequestProcessor {
}
Future<?> distFuture = null;
-
- distFuture = ParWork.getRootSharedExecutor().submit(() -> {
+ Callable distCall = () -> {
try {
doDistribDeleteByQuery(cmd, replicas, coll);
} catch (IOException e) {
+ // MRM TODO: fail this harder...
+ throw new SolrException(ErrorCode.SERVER_ERROR, e);
+ }
+ return null;
+ };
+ if (!forwardToLeader) {
+ distFuture = ParWork.getRootSharedExecutor().submit(distCall);
+ } else {
+ try {
+ distCall.call();
+ } catch (Exception e) {
+ if (e instanceof RuntimeException) {
+ throw (RuntimeException) e;
+ }
throw new SolrException(ErrorCode.SERVER_ERROR, e);
}
- });
+ }
+
+ if (!forwardToLeader) {
+ distFuture = ParWork.getRootSharedExecutor().submit(distCall);
+ } else {
+ try {
+ distCall.call();
+ } catch (Exception e) {
+ if (e instanceof RuntimeException) {
+ throw (RuntimeException) e;
+ }
+ throw new SolrException(ErrorCode.SERVER_ERROR, e);
+ }
+ }
try {
doLocalDelete(cmd);