1
votes

I have a solr cloud setup with 5 nodes, 5 shards and replicationFactor=2. As I understand when we query solr cloud, the request is sent to shard leader which then directs the request to the replica. So a query result must be fetched from a single replica. But when I query with debug info enabled I see that query request is being sent to all the replicas. Below is the attached debug info

  "debug":{
    "track":{
      "rid":"-collection_shard2_replica1-1521525496479-3",
      "EXECUTE_QUERY":{
        "http://ip:8983/solr/collection_shard2_replica2/|http://ip:8983/solr/collection_shard2_replica1/":{
          "QTime":"0",
          "ElapsedTime":"4",
          "RequestPurpose":"GET_TOP_IDS",
          "NumFound":"3882137",
          "Response":"{responseHeader={zkConnected=true,status=0,QTime=0,params={df=contents,f.contents.hl.fragsize=50,distrib=false,hl=false,f.ttl.hl.snippets=1,f.kw_skl.hl.simple.post=</span>,fl=[id, score],shards.purpose=4,fsv=true,f.kw_skl.hl.snippets=1,f.ttl.hl.fragsize=0,shard.url=http://ip:8983/solr/collection_shard2_replica2/|http://ip:8983/solr/collection_shard2_replica1/,rid=-collection_shard2_replica1-1521525496479-3,f.kw_skl.hl.fragsize=0,hl.simple.pre= <span class=\"bg_yellow\">,f.kw_it.hl.alternateField=kw_it,f.kw_skl.hl.alternateField=kw_skl,defType=edismax,f.ttl.hl.simple.post=</span>,qf=contents currdesig lng ttl kw_skl kw_it,hl.highlightAlternate=false,f.contents.hl.snippets=3,hl.fl=ttl,kw_skl,kw_it,contents,wt=javabin,_=1521525657029,debug=[false, timing, track],qt=/resumesearch,f.contents.hl.simple.post=</span>,start=0,f.kw_it.hl.fragsize=0,f.kw_it.hl.simple.pre= <span class=\"bg_yellow\">,rows=10,version=2,hl.encoder=html,f.kw_it.hl.snippets=1,f.ttl.hl.alternateField=ttl,q=*:*,f.ttl.hl.simple.pre= <span class=\"bg_yellow\">,hl.simple.post=</span>,requestPurpose=GET_TOP_IDS,NOW=1521525496479,isShard=true,hl.method=postings,f.contents.hl.simple.pre= <span class=\"bg_yellow\">,f.kw_skl.hl.simple.pre= <span class=\"bg_yellow\">,f.kw_it.hl.simple.post=</span>,debugQuery=false}},response={numFound=3882137,start=0,maxScore=1.0,docs=[SolrDocument{id=82569162, score=1.0}, SolrDocument{id=82569230, score=1.0}, SolrDocument{id=82569265, score=1.0}, SolrDocument{id=82569294, score=1.0}, SolrDocument{id=82569309, score=1.0}, SolrDocument{id=82569313, score=1.0}, SolrDocument{id=82569386, score=1.0}, SolrDocument{id=35263232, score=1.0}, SolrDocument{id=35263237, score=1.0}, SolrDocument{id=35263300, score=1.0}]},sort_values={},debug={timing={time=0.0,prepare={time=0.0,query={time=0.0},facet={time=0.0},facet_module={time=0.0},mlt={time=0.0},highlight={time=0.0},stats={time=0.0},expand={time=0.0},terms={time=0.0},debug={time=0.0}},process={time=0.0,query={time=0.0},facet={time=0.0},facet_module={time=0.0},mlt={time=0.0},highlight={time=0.0},stats={time=0.0},expand={time=0.0},terms={time=0.0},debug={time=0.0}}}}}"},
        "http://ip:8983/solr/collection_shard3_replica2/|http://ip:8983/solr/collection_shard3_replica1/":{
          "QTime":"0",
          "ElapsedTime":"5",
          "RequestPurpose":"GET_TOP_IDS",
          "NumFound":"3884681",
          "Response":"{responseHeader={zkConnected=true,status=0,QTime=0,params={df=contents,f.contents.hl.fragsize=50,distrib=false,hl=false,f.ttl.hl.snippets=1,f.kw_skl.hl.simple.post=</span>,fl=[id, score],shards.purpose=4,fsv=true,f.kw_skl.hl.snippets=1,f.ttl.hl.fragsize=0,shard.url=http://ip:8983/solr/collection_shard3_replica2/|http://ip:8983/solr/collection_shard3_replica1/,rid=-collection_shard2_replica1-1521525496479-3,f.kw_skl.hl.fragsize=0,hl.simple.pre= <span class=\"bg_yellow\">,f.kw_it.hl.alternateField=kw_it,f.kw_skl.hl.alternateField=kw_skl,defType=edismax,f.ttl.hl.simple.post=</span>,qf=contents currdesig lng ttl kw_skl kw_it,hl.highlightAlternate=false,f.contents.hl.snippets=3,hl.fl=ttl,kw_skl,kw_it,contents,wt=javabin,_=1521525657029,debug=[false, timing, track],qt=/resumesearch,f.contents.hl.simple.post=</span>,start=0,f.kw_it.hl.fragsize=0,f.kw_it.hl.simple.pre= <span class=\"bg_yellow\">,rows=10,version=2,hl.encoder=html,f.kw_it.hl.snippets=1,f.ttl.hl.alternateField=ttl,q=*:*,f.ttl.hl.simple.pre= <span class=\"bg_yellow\">,hl.simple.post=</span>,requestPurpose=GET_TOP_IDS,NOW=1521525496479,isShard=true,hl.method=postings,f.contents.hl.simple.pre= <span class=\"bg_yellow\">,f.kw_skl.hl.simple.pre= <span class=\"bg_yellow\">,f.kw_it.hl.simple.post=</span>,debugQuery=false}},response={numFound=3884681,start=0,maxScore=1.0,docs=[SolrDocument{id=55933756, score=1.0}, SolrDocument{id=72335162, score=1.0}, SolrDocument{id=72335169, score=1.0}, SolrDocument{id=72335184, score=1.0}, SolrDocument{id=55933816, score=1.0}, SolrDocument{id=55933834, score=1.0}, SolrDocument{id=55933978, score=1.0}, SolrDocument{id=55934020, score=1.0}, SolrDocument{id=55934028, score=1.0}, SolrDocument{id=55934052, score=1.0}]},sort_values={},debug={timing={time=0.0,prepare={time=0.0,query={time=0.0},facet={time=0.0},facet_module={time=0.0},mlt={time=0.0},highlight={time=0.0},stats={time=0.0},expand={time=0.0},terms={time=0.0},debug={time=0.0}},process={time=0.0,query={time=0.0},facet={time=0.0},facet_module={time=0.0},mlt={time=0.0},highlight={time=0.0},stats={time=0.0},expand={time=0.0},terms={time=0.0},debug={time=0.0}}}}}"},
        "http://ip:8983/solr/collection_shard1_replica1/|http://ip:8983/solr/collection_shard1_replica3/":{
          "QTime":"0",
          "ElapsedTime":"3",
          "RequestPurpose":"GET_TOP_IDS",
          "NumFound":"3884574",
          "Response":"{responseHeader={zkConnected=true,status=0,QTime=0,params={df=contents,f.contents.hl.fragsize=50,distrib=false,hl=false,f.ttl.hl.snippets=1,f.kw_skl.hl.simple.post=</span>,fl=[id, score],shards.purpose=4,fsv=true,f.kw_skl.hl.snippets=1,f.ttl.hl.fragsize=0,shard.url=http://ip:8983/solr/collection_shard1_replica1/|http://ip:8983/solr/collection_shard1_replica3/,rid=-collection_shard2_replica1-1521525496479-3,f.kw_skl.hl.fragsize=0,hl.simple.pre= <span class=\"bg_yellow\">,f.kw_it.hl.alternateField=kw_it,f.kw_skl.hl.alternateField=kw_skl,defType=edismax,f.ttl.hl.simple.post=</span>,qf=contents currdesig lng ttl kw_skl kw_it,hl.highlightAlternate=false,f.contents.hl.snippets=3,hl.fl=ttl,kw_skl,kw_it,contents,wt=javabin,_=1521525657029,debug=[false, timing, track],qt=/resumesearch,f.contents.hl.simple.post=</span>,start=0,f.kw_it.hl.fragsize=0,f.kw_it.hl.simple.pre= <span class=\"bg_yellow\">,rows=10,version=2,hl.encoder=html,f.kw_it.hl.snippets=1,f.ttl.hl.alternateField=ttl,q=*:*,f.ttl.hl.simple.pre= <span class=\"bg_yellow\">,hl.simple.post=</span>,requestPurpose=GET_TOP_IDS,NOW=1521525496479,isShard=true,hl.method=postings,f.contents.hl.simple.pre= <span class=\"bg_yellow\">,f.kw_skl.hl.simple.pre= <span class=\"bg_yellow\">,f.kw_it.hl.simple.post=</span>,debugQuery=false}},response={numFound=3884574,start=0,maxScore=1.0,docs=[SolrDocument{id=30504181, score=1.0}, SolrDocument{id=30504213, score=1.0}, SolrDocument{id=30504221, score=1.0}, SolrDocument{id=30504252, score=1.0}, SolrDocument{id=30504264, score=1.0}, SolrDocument{id=30504291, score=1.0}, SolrDocument{id=30504319, score=1.0}, SolrDocument{id=30504346, score=1.0}, SolrDocument{id=30504350, score=1.0}, SolrDocument{id=30504355, score=1.0}]},sort_values={},debug={timing={time=0.0,prepare={time=0.0,query={time=0.0},facet={time=0.0},facet_module={time=0.0},mlt={time=0.0},highlight={time=0.0},stats={time=0.0},expand={time=0.0},terms={time=0.0},debug={time=0.0}},process={time=0.0,query={time=0.0},facet={time=0.0},facet_module={time=0.0},mlt={time=0.0},highlight={time=0.0},stats={time=0.0},expand={time=0.0},terms={time=0.0},debug={time=0.0}}}}}"},
        "http://ip:8983/solr/collection_shard4_replica1/|http://ip:8983/solr/collection_shard4_replica3/":{
          "QTime":"2",
          "ElapsedTime":"6",
          "RequestPurpose":"GET_TOP_IDS",
          "NumFound":"3881377",
          "Response":"{responseHeader={zkConnected=true,status=0,QTime=2,params={df=contents,f.contents.hl.fragsize=50,distrib=false,hl=false,f.ttl.hl.snippets=1,f.kw_skl.hl.simple.post=</span>,fl=[id, score],shards.purpose=4,fsv=true,f.kw_skl.hl.snippets=1,f.ttl.hl.fragsize=0,shard.url=http://ip:8983/solr/collection_shard4_replica1/|http://ip:8983/solr/collection_shard4_replica3/,rid=-collection_shard2_replica1-1521525496479-3,f.kw_skl.hl.fragsize=0,hl.simple.pre= <span class=\"bg_yellow\">,f.kw_it.hl.alternateField=kw_it,f.kw_skl.hl.alternateField=kw_skl,defType=edismax,f.ttl.hl.simple.post=</span>,qf=contents currdesig lng ttl kw_skl kw_it,hl.highlightAlternate=false,f.contents.hl.snippets=3,hl.fl=ttl,kw_skl,kw_it,contents,wt=javabin,_=1521525657029,debug=[false, timing, track],qt=/resumesearch,f.contents.hl.simple.post=</span>,start=0,f.kw_it.hl.fragsize=0,f.kw_it.hl.simple.pre= <span class=\"bg_yellow\">,rows=10,version=2,hl.encoder=html,f.kw_it.hl.snippets=1,f.ttl.hl.alternateField=ttl,q=*:*,f.ttl.hl.simple.pre= <span class=\"bg_yellow\">,hl.simple.post=</span>,requestPurpose=GET_TOP_IDS,NOW=1521525496479,isShard=true,hl.method=postings,f.contents.hl.simple.pre= <span class=\"bg_yellow\">,f.kw_skl.hl.simple.pre= <span class=\"bg_yellow\">,f.kw_it.hl.simple.post=</span>,debugQuery=false}},response={numFound=3881377,start=0,maxScore=1.0,docs=[SolrDocument{id=83997361, score=1.0}, SolrDocument{id=86755299, score=1.0}, SolrDocument{id=83997456, score=1.0}, SolrDocument{id=83997474, score=1.0}, SolrDocument{id=83997636, score=1.0}, SolrDocument{id=83997702, score=1.0}, SolrDocument{id=83997734, score=1.0}, SolrDocument{id=83997739, score=1.0}, SolrDocument{id=83997740, score=1.0}, SolrDocument{id=33944905, score=1.0}]},sort_values={},debug={timing={time=2.0,prepare={time=1.0,query={time=1.0},facet={time=0.0},facet_module={time=0.0},mlt={time=0.0},highlight={time=0.0},stats={time=0.0},expand={time=0.0},terms={time=0.0},debug={time=0.0}},process={time=0.0,query={time=0.0},facet={time=0.0},facet_module={time=0.0},mlt={time=0.0},highlight={time=0.0},stats={time=0.0},expand={time=0.0},terms={time=0.0},debug={time=0.0}}}}}"},
        "http://ip:8983/solr/collection_shard5_replica2/|http://ip:8983/solr/collection_shard5_replica1/":{
          "QTime":"1",
          "ElapsedTime":"5",
          "RequestPurpose":"GET_TOP_IDS",
          "NumFound":"3885899",
          "Response":"{responseHeader={zkConnected=true,status=0,QTime=1,params={df=contents,f.contents.hl.fragsize=50,distrib=false,hl=false,f.ttl.hl.snippets=1,f.kw_skl.hl.simple.post=</span>,fl=[id, score],shards.purpose=4,fsv=true,f.kw_skl.hl.snippets=1,f.ttl.hl.fragsize=0,shard.url=http://ip:8983/solr/collection_shard5_replica2/|http://ip:8983/solr/collection_shard5_replica1/,rid=-collection_shard2_replica1-1521525496479-3,f.kw_skl.hl.fragsize=0,hl.simple.pre= <span class=\"bg_yellow\">,f.kw_it.hl.alternateField=kw_it,f.kw_skl.hl.alternateField=kw_skl,defType=edismax,f.ttl.hl.simple.post=</span>,qf=contents currdesig lng ttl kw_skl kw_it,hl.highlightAlternate=false,f.contents.hl.snippets=3,hl.fl=ttl,kw_skl,kw_it,contents,wt=javabin,_=1521525657029,debug=[false, timing, track],qt=/resumesearch,f.contents.hl.simple.post=</span>,start=0,f.kw_it.hl.fragsize=0,f.kw_it.hl.simple.pre= <span class=\"bg_yellow\">,rows=10,version=2,hl.encoder=html,f.kw_it.hl.snippets=1,f.ttl.hl.alternateField=ttl,q=*:*,f.ttl.hl.simple.pre= <span class=\"bg_yellow\">,hl.simple.post=</span>,requestPurpose=GET_TOP_IDS,NOW=1521525496479,isShard=true,hl.method=postings,f.contents.hl.simple.pre= <span class=\"bg_yellow\">,f.kw_skl.hl.simple.pre= <span class=\"bg_yellow\">,f.kw_it.hl.simple.post=</span>,debugQuery=false}},response={numFound=3885899,start=0,maxScore=1.0,docs=[SolrDocument{id=38604136, score=1.0}, SolrDocument{id=38604159, score=1.0}, SolrDocument{id=38604197, score=1.0}, SolrDocument{id=38604210, score=1.0}, SolrDocument{id=38604216, score=1.0}, SolrDocument{id=38604237, score=1.0}, SolrDocument{id=38604252, score=1.0}, SolrDocument{id=38604258, score=1.0}, SolrDocument{id=38604260, score=1.0}, SolrDocument{id=38604290, score=1.0}]},sort_values={},debug={timing={time=1.0,prepare={time=0.0,query={time=0.0},facet={time=0.0},facet_module={time=0.0},mlt={time=0.0},highlight={time=0.0},stats={time=0.0},expand={time=0.0},terms={time=0.0},debug={time=0.0}},process={time=0.0,query={time=0.0},facet={time=0.0},facet_module={time=0.0},mlt={time=0.0},highlight={time=0.0},stats={time=0.0},expand={time=0.0},terms={time=0.0},debug={time=0.0}}}}}"}},
      "GET_FIELDS":{
        "http://ip:8983/solr/collection_shard2_replica2/|http://ip:8983/solr/collection_shard2_replica1/":{
          "QTime":"27",
          "ElapsedTime":"31",
          "RequestPurpose":"GET_FIELDS,GET_HIGHLIGHTS,GET_DEBUG",
          "NumFound":"10",

As it can be seen in "EXECUTE_QUERY" section, the request is being sent to all replicas. Can someone explain this?

1

1 Answers

2
votes

The first phase of your query is to find out which shards have documents that meet your criteria, and which documents those are. Since there's no centralized way to determine which shards hold documents that meet your criteria, the query is sent to all shards in parallel via a GET_TOP_IDS request. The GET_TOP_IDS is sent to either the primary or replica for a given shard...not both.

From there, the GET_DATA_FIELDS will be sent to one or more shards depending on sort/rows/score to get the requested data from a subset of documents identified by GET_TOP_IDS