0

尝试使用 Solr 8.1.1 设置单向 CDCR,

在源日志中将数据目录从源副本同步到目标副本(1 到 1)后,我看到:

2020-03-09 11:04:28.873 INFO  (cdcr-replicator-17-thread-4) [   ] o.a.s.h.CdcrReplicator Forwarded 0 updates to target search1
2020-03-09 11:04:30.872 INFO  (cdcr-replicator-17-thread-5) [   ] o.a.s.h.CdcrReplicator Forwarded 0 updates to target search1
2020-03-09 11:04:32.873 INFO  (cdcr-replicator-17-thread-6) [   ] o.a.s.h.CdcrReplicator Forwarded 0 updates to target search1
2020-03-09 11:04:34.873 INFO  (cdcr-replicator-17-thread-7) [   ] o.a.s.h.CdcrReplicator Forwarded 0 updates to target search1
2020-03-09 11:04:36.873 INFO  (cdcr-replicator-17-thread-8) [   ] o.a.s.h.CdcrReplicator Forwarded 0 updates to target search1

我在源集合上启动了 CDCR,当我将新数据索引到源集合中时,出现以下错误:

2020-03-09 11:14:22.933 ERROR (cdcr-replicator-17-thread-5) [   ] o.a.s.c.s.i.BaseCloudSolrClient Request to collection [search1] failed due to (409) org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://10.11.33.159:8983/solr/search1_shard1_replica_n1: version conflict for THREE_INDEXING_01 expected=1660684743870513152 actual=-1, retry=0 commError=false errorCode=409
2020-03-09 11:14:22.933 INFO  (cdcr-replicator-17-thread-5) [   ] o.a.s.c.s.i.BaseCloudSolrClient request was not communication error it seems
2020-03-09 11:14:22.933 WARN  (cdcr-replicator-17-thread-5) [   ] o.a.s.h.CdcrReplicator Failed to forward update request to target: search1 => org.apache.solr.client.solrj.impl.CloudSolrClient$RouteException: Error from server at http://10.11.33.159:8983/solr/search1_shard1_replica_n1: version conflict for THREE_INDEXING_01 expected=1660684743870513152 actual=-1
        at org.apache.solr.client.solrj.impl.CloudSolrClient.getRouteException(CloudSolrClient.java:125)
org.apache.solr.client.solrj.impl.CloudSolrClient$RouteException: Error from server at http://10.11.33.159:8983/solr/search1_shard1_replica_n1: version conflict for THREE_INDEXING_01 expected=1660684743870513152 actual=-1
        at org.apache.solr.client.solrj.impl.CloudSolrClient.getRouteException(CloudSolrClient.java:125) ~[?:?]
        at org.apache.solr.client.solrj.impl.CloudSolrClient.getRouteException(CloudSolrClient.java:46) ~[?:?]
        at org.apache.solr.client.solrj.impl.BaseCloudSolrClient.directUpdate(BaseCloudSolrClient.java:489) ~[?:?]
        at org.apache.solr.client.solrj.impl.BaseCloudSolrClient.sendRequest(BaseCloudSolrClient.java:977) ~[?:?]
        at org.apache.solr.client.solrj.impl.BaseCloudSolrClient.requestWithRetryOnStaleState(BaseCloudSolrClient.java:837) ~[?:?]
        at org.apache.solr.client.solrj.impl.BaseCloudSolrClient.request(BaseCloudSolrClient.java:769) ~[?:?]
        at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:207) ~[?:?]
        at org.apache.solr.client.solrj.SolrRequest.process(SolrRequest.java:224) ~[?:?]
        at org.apache.solr.handler.CdcrReplicator.sendRequest(CdcrReplicator.java:140) ~[?:?]
        at org.apache.solr.handler.CdcrReplicator.run(CdcrReplicator.java:120) ~[?:?]
        at org.apache.solr.handler.CdcrReplicatorScheduler.lambda$null$0(CdcrReplicatorScheduler.java:81) ~[?:?]
        at org.apache.solr.common.util.ExecutorUtil$MDCAwareThreadPoolExecutor.lambda$execute$0(ExecutorUtil.java:209) ~[?:?]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[?:1.8.0_232]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[?:1.8.0_232]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_232]
Caused by: org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://10.11.33.159:8983/solr/search1_shard1_replica_n1: version conflict for THREE_INDEXING_01 expected=1660684743870513152 actual=-1
        at org.apache.solr.client.solrj.impl.HttpSolrClient.executeMethod(HttpSolrClient.java:649) ~[?:?]
        at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:255) ~[?:?]
        at org.apache.solr.client.solrj.impl.HttpSolrClient.request(HttpSolrClient.java:244) ~[?:?]
        at org.apache.solr.client.solrj.impl.LBSolrClient.doRequest(LBSolrClient.java:368) ~[?:?]
        at org.apache.solr.client.solrj.impl.LBSolrClient.request(LBSolrClient.java:296) ~[?:?]
        at org.apache.solr.client.solrj.impl.BaseCloudSolrClient.lambda$directUpdate$0(BaseCloudSolrClient.java:465) ~[?:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[?:1.8.0_232]
        ... 4 more
4

1 回答 1

0

如果存在版本冲突(HTTP 错误代码 409),则会收到 HTTP 错误代码 409。

默认情况下,Solr 的 Schema 包含一个版本字段,该字段会自动添加到每个新文档中。此功能通过要求索引中所有文档的版本字段,并将其与作为更新命令的一部分指定的版本进行比较来工作。

$ curl -X POST -H 'Content-Type: application/json' 'http://localhost:8983/solr/techproducts/update?_version_=1632740120218042368&versions=true&commit=true&omitHeader=true' --data-binary '
[{ "id" : "aaa",
   "foo_s" : "update attempt with correct existing version" }]'

使用与索引中的值匹配的版本值进行更新,并且成功。因为我们包含在更新请求中,所以响应包含版本字段versions=true的不同值。

如果更新具有嵌入在文档本身中的版本值。请求失败,因为您指定了错误的版本。下面将是它的错误。

{
  "error":{
    "metadata":[
      "error-class","org.apache.solr.common.SolrException",
      "root-error-class","org.apache.solr.common.SolrException"],
    "msg":"version conflict for aaa expected=100 actual=1632740462042284032",
    "code":409
    }
}

这里的 -1 表示 Solr 无法找到具有该版本的文档。我建议您尝试在 Solr 管理 UI 上手动将文档之一发送给 solr。选择您的核心/集合名称,然后单击文档链接(在 solr 管理页面上),您将进入可以将文档发送到 solr 以进行更新的页面。

有关更多详细信息,请参阅 solr 文档。 Solr 文档

于 2020-03-09T12:25:30.873 回答