You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by js...@apache.org on 2023/03/13 15:18:52 UTC
[solr] branch branch_9x updated: SOLR-16689: Improving efficiency of replication process (#1442)
This is an automated email from the ASF dual-hosted git repository.
jsweeney pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new fa72d986a7e SOLR-16689: Improving efficiency of replication process (#1442)
fa72d986a7e is described below
commit fa72d986a7e713c0d280f9c2c9ed6e636177604c
Author: Justin Sweeney <ju...@fullstory.com>
AuthorDate: Mon Mar 13 09:17:34 2023 -0600
SOLR-16689: Improving efficiency of replication process (#1442)
Improving efficiency of replication process by avoiding repeated attempts to replicate empty index and avoiding commit call to leader when replicating to a non-leader replica
---
solr/CHANGES.txt | 2 ++
solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java | 6 ++++--
solr/core/src/java/org/apache/solr/handler/IndexFetcher.java | 2 +-
solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java | 10 ++++++++++
4 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 7b96b468d6c..837bb9a12fc 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -163,6 +163,8 @@ Optimizations
* SOLR-16487: Replication pooling is optimized based on hard and soft commit settings for a given collection (Justin Sweeney)
+* SOLR-16689: Avoiding commits on leader when recovering a non-leader replica and avoiding incorrectly replicating an empty core (Justin Sweeney)
+
Bug Fixes
---------------------
diff --git a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
index 565ce004b99..e24b132cf34 100644
--- a/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
+++ b/solr/core/src/java/org/apache/solr/cloud/RecoveryStrategy.java
@@ -223,8 +223,10 @@ public class RecoveryStrategy implements Runnable, Closeable {
log.info("Attempting to replicate from [{}].", leaderUrl);
- // send commit
- commitOnLeader(leaderUrl);
+ // send commit if replica could be a leader
+ if (Replica.Type.isLeaderType(replicaType)) {
+ commitOnLeader(leaderUrl);
+ }
// use rep handler directly, so we can do this sync rather than async
SolrRequestHandler handler = core.getRequestHandler(ReplicationHandler.PATH);
diff --git a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
index 9d61974e859..099bac7ec35 100644
--- a/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
+++ b/solr/core/src/java/org/apache/solr/handler/IndexFetcher.java
@@ -546,7 +546,7 @@ public class IndexFetcher {
}
if (latestVersion == 0L) {
- if (commit.getGeneration() != 0) {
+ if (IndexDeletionPolicyWrapper.getCommitTimestamp(commit) != 0L) {
// since we won't get the files for an empty index,
// we just clear ours and commit
log.info("New index in Leader. Deleting mine...");
diff --git a/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java b/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java
index 83155fa48d1..583c4a4e494 100644
--- a/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java
+++ b/solr/solrj/src/java/org/apache/solr/common/cloud/Replica.java
@@ -129,6 +129,16 @@ public class Replica extends ZkNodeProps implements MapWriter {
public static Type get(String name) {
return name == null ? Type.NRT : Type.valueOf(name.toUpperCase(Locale.ROOT));
}
+
+ /**
+ * Only certain replica types can become leaders
+ *
+ * @param type the type of a replica
+ * @return true if that type is able to be leader, false otherwise
+ */
+ public static boolean isLeaderType(Type type) {
+ return type == null || type == NRT || type == TLOG;
+ }
}
// immutable