<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>zookeeper &#8211; Solr.pl</title>
	<atom:link href="https://solr.pl/en/tag/zookeeper-2/feed/" rel="self" type="application/rss+xml" />
	<link>https://solr.pl/en/</link>
	<description>All things to be found - Blog related to Apache Solr &#38; Lucene projects - https://solr.apache.org</description>
	<lastBuildDate>Sat, 14 Nov 2020 13:54:51 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0</generator>
	<item>
		<title>SolrCloud: What happens when ZooKeeper fails &#8211; part two</title>
		<link>https://solr.pl/en/2015/06/29/solrcloud-what-happens-when-zookeeper-fails-part-two/</link>
					<comments>https://solr.pl/en/2015/06/29/solrcloud-what-happens-when-zookeeper-fails-part-two/#respond</comments>
		
		<dc:creator><![CDATA[Rafał Kuć]]></dc:creator>
		<pubDate>Mon, 29 Jun 2015 12:54:28 +0000</pubDate>
				<category><![CDATA[Solr]]></category>
		<category><![CDATA[indexing]]></category>
		<category><![CDATA[solr]]></category>
		<category><![CDATA[zookeeper]]></category>
		<guid isPermaLink="false">http://sematext.solr.pl/?p=869</guid>

					<description><![CDATA[In the previous blog post about SolrCloud we&#8217;ve talked about the situation when ZooKeeper connection failed and how Solr handles that situation. However, we only talked about query time behavior of SolrCloud and we said that we will get back]]></description>
										<content:encoded><![CDATA[<p>In the <a href="http://solr.pl/en/2013/12/02/solrcloud-what-happens-when-zookeeper-fails/">previous</a> blog post about SolrCloud we&#8217;ve talked about the situation when ZooKeeper connection failed and how Solr handles that situation. However, we only talked about query time behavior of SolrCloud and we said that we will get back to the topic of indexing in the future. That future is finally here &#8211; let&#8217;s see what happens to indexing when ZooKeeper connection is not available.</p>
<p><span id="more-869"></span></p>
<h3>Looking back at the old post</h3>
<p>In the <a href="http://solr.pl/en/2013/12/02/solrcloud-what-happens-when-zookeeper-fails/">SolrCloud &#8211; What happens when ZooKeeper fails?</a> blog post, we&#8217;ve shown that Solr can handle querying without any issues when connection to ZooKeeper has been lost (which can be caused by different reasons). Of course this is true until we change the cluster topology. Unfortunately, in case of indexing or cluster change operations, we can&#8217;t change the cluster state or index documents when ZooKeeper connection is not working or ZooKeeper failed to read/write the data we want.</p>
<h3>Why we can run queries?</h3>
<p>The situation is quite simple &#8211; querying is not an operation that needs to alter SolrCloud cluster state. The only thing Solr needs to do is accept the query, run it against known shards/replicas and gather the results. Of course cluster topology is not retrieved with each query, so when there is no active ZooKeeper connection (or ZooKeeper failed) we don&#8217;t have a problem with running queries.</p>
<p>There is also one important and not widely know feature of SolrCloud &#8211; the ability to return partial results. By adding the <em>shards.tolerant=true</em> parameter to our queries we inform Solr, that we can live with partial results and it should ignore shards that are not available. This means that Solr will return results even if some of the shards from our collection is not available. By default, when this parameter is not present or set to <em>false</em>, Solr will just return error when running a query against collection that doesn&#8217;t have all the shards available.</p>
<h3>Why we can&#8217;t index data?</h3>
<p>So, we can&#8217;t we index data, when ZooKeeper connection is not available or when ZooKeeper doesn&#8217;t have a quorum? Because there is potentially not enough information about the cluster state to process the indexing operation. Solr just may not have the fresh information about all the shards, replicas, etc. Because of that, indexing operation may be pointed to incorrect shard (like not to the current leader), which can lead to data corruption. And because of that indexing (or cluster change) operation is jus not possible.</p>
<p>It is generally worth remembering, that all operations that can lead to cluster state update or collections update won&#8217;t be possible when ZooKeeper quorum is not visible by Solr (in our test case, it will be a lack of connectivity of a single ZooKeeper server).</p>
<p>Of course, we could leave you with what we wrote above, but let&#8217;s check if all that is true.</p>
<h4>Running ZooKeeper</h4>
<p>A very simple step. For the purpose of the test we will only need a single ZooKeeper instance which is run using the following command from ZooKeeper installation directory:
</p>
<pre class="brush:xml">bin/zkServer.sh start
</pre>
<p>We should see the following information on the console:
</p>
<pre class="brush:xml">JMX enabled by default
Using config: /Users/gro/Solry/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
</pre>
<p>And that means that we have a running ZooKeeper server.</p>
<h4>Starting two Solr instances</h4>
<p>To run the test we&#8217;ve used the newest available Solr version &#8211; the <em>5.2.1</em> when this blog post was published. To run two Solr instances we&#8217;ve used the following command:
</p>
<pre class="brush:xml">bin/solr start -e cloud -z localhost:2181
</pre>
<p>Solr asked us a few questions when it was starting and the answers where the following:</p>
<ul>
<li>number of instances: <em>2</em></li>
<li>collection name: <em>gettingstarted</em></li>
<li>number of shards: <em>2</em></li>
<li>replication count: <em>1</em></li>
<li>configuration name: <em>data_driven_schema_configs</em></li>
</ul>
<p>Cluster topology after Solr started was as follows:</p>
<p><img decoding="async" class="aligncenter  wp-image-3617" src="http://solr.pl/wp-content/uploads/2015/06/zookeeper_kolekcja.png" alt="Zrzut ekranu 2015-06-21 o 11.13.31" width="683" height="58"></p>
<h4>Let&#8217;s index a few documents</h4>
<p>To see that Solr is really running, we&#8217;ve indexed a few documents by running the following command:
</p>
<pre class="brush:xml">bin/post -c gettingstarted docs/
</pre>
<p>If everything went well, after running the following command:
</p>
<pre class="brush:xml">curl -XGET 'localhost:8983/solr/gettingstarted/select?indent=true&amp;q=*:*&amp;rows=0'
</pre>
<p>we should see Solr responding with similar XML:
</p>
<pre class="brush:xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;response&gt;
 &lt;lst name="responseHeader"&gt;
  &lt;int name="status"&gt;0&lt;/int&gt;
  &lt;int name="QTime"&gt;38&lt;/int&gt;
  &lt;lst name="params"&gt;
   &lt;str name="q"&gt;*:*&lt;/str&gt;
   &lt;str name="indent"&gt;true&lt;/str&gt;
   &lt;str name="rows"&gt;0&lt;/str&gt;
  &lt;/lst&gt;
 &lt;/lst&gt;
 &lt;result name="response" numFound="3577" start="0" maxScore="1.0"&gt;
 &lt;/result&gt;
&lt;/response&gt;
</pre>
<p>We&#8217;ve indexed our documents, we have Solr running.</p>
<h4>Let&#8217;s stop ZooKeeper and index data</h4>
<p>To stop ZooKeeper server we will just run the following command in the ZooKeeper installation directory:
</p>
<pre class="brush:xml">bin/zkServer.sh stop
</pre>
<p>And now, let&#8217;s again try to index our data:
</p>
<pre class="brush:xml">bin/post -c gettingstarted docs/
</pre>
<p>This time, instead of data being written into the collection we will get an error response similar to the following one:
</p>
<pre class="brush:xml">POSTing file index.html (text/html) to [base]/extract
SimplePostTool: WARNING: Solr returned an error #503 (Service Unavailable) for url: http://localhost:8983/solr/gettingstarted/update/extract?resource.name=%2FUsers%2Fgro%2FSolry%2F5.2.1%2Fdocs%2Findex.html&amp;literal.id=%2FUsers%2Fgro%2FSolry%2F5.2.1%2Fdocs%2Findex.html
SimplePostTool: WARNING: Response: &lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;response&gt;
&lt;lst name="responseHeader"&gt;&lt;int name="status"&gt;503&lt;/int&gt;&lt;int name="QTime"&gt;3&lt;/int&gt;&lt;/lst&gt;&lt;lst name="error"&gt;&lt;str name="msg"&gt;Cannot talk to ZooKeeper - Updates are disabled.&lt;/str&gt;&lt;int name="code"&gt;503&lt;/int&gt;&lt;/lst&gt;
&lt;/response&gt;
</pre>
<p>As we can see, the lack of ZooKeeper connectivity resulted in Solr not being able to index data. Of course querying still works. Turning on ZooKeeper again and retrying indexing will be successful, because Solr will automatically reconnect to ZooKeeper and will start working again.</p>
<h3>Short summary</h3>
<p>Of course this and the previous blog post related to ZooKeeper and SolrCloud are only touching the surface of what is happening when ZooKeeper connection is not available. A very good test that shows us data consistency related information can be found at <a href="http://lucidworks.com/blog/call-maybe-solrcloud-jepsen-flaky-networks/">http://lucidworks.com/blog/call-maybe-solrcloud-jepsen-flaky-networks/</a>. I really recommend it if you would like to know what will happen with SolrCloud in various emergency situations.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://solr.pl/en/2015/06/29/solrcloud-what-happens-when-zookeeper-fails-part-two/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>SolrCloud &#8211; What happens when ZooKeeper fails?</title>
		<link>https://solr.pl/en/2013/12/02/solrcloud-what-happens-when-zookeeper-fails-2/</link>
					<comments>https://solr.pl/en/2013/12/02/solrcloud-what-happens-when-zookeeper-fails-2/#respond</comments>
		
		<dc:creator><![CDATA[Rafał Kuć]]></dc:creator>
		<pubDate>Mon, 02 Dec 2013 14:13:35 +0000</pubDate>
				<category><![CDATA[General]]></category>
		<category><![CDATA[solr]]></category>
		<category><![CDATA[solrcloud]]></category>
		<category><![CDATA[zookeeper]]></category>
		<guid isPermaLink="false">http://sematext.solr.pl/?p=620</guid>

					<description><![CDATA[One of the questions I tend to get is what happens with SolrCloud cluster when ZooKeeper fails. Of course we are not talking about a single ZooKeeper instance failure, but the whole ensemble not being accessible and so the quorum]]></description>
										<content:encoded><![CDATA[<p>One of the questions I tend to get is what happens with SolrCloud cluster when ZooKeeper fails. Of course we are not talking about a single ZooKeeper instance failure, but the whole <em>ensemble</em> not being accessible and so the <em>quorum</em> not present. Because the answer to this question is very easy to verify i decided to make a simple blog post to show what happens when ZooKeeper fails.</p>
<p><span id="more-620"></span></p>
<h3>Test environment</h3>
<p>The test environment was very simple:</p>
<ul>
<li>A single virtual machine running under Linux operating system</li>
<li>A single instance of ZooKeeper (which will be suitable for our test)</li>
<li>Two Solr instances with a single collection deployed</li>
<li>Solr <a title="Apache Lucene and Solr 4.6" href="http://solr.pl/en/2013/11/24/apache-lucene-and-solr-4-6/">4.6</a></li>
</ul>
<p>In order to create our test collection I&#8217;ve uploaded the configuration to ZooKeeper and used the following command:
</p>
<pre class="brush:bash">curl 'http://localhost:8983/solr/admin/collections?action=CREATE&amp;name=collection1&amp;numShards=2&amp;replicationFactor=1'</pre>
<p>The cloud view of the example cluster was as follows:
</p>
<p style="text-align: center;"><a href="http://solr.pl/wp-content/uploads/2013/12/cloud_view.png"><img decoding="async" class="aligncenter  wp-image-3330" alt="cloud_view" src="http://solr.pl/wp-content/uploads/2013/12/cloud_view.png" width="495" height="44"></a></p>
<h3>Test data indexing</h3>
<p>The next step in our test will be indexing. We will index a few example documents that are provided with Solr in the <em>exampledocs</em> directory. The following commands were used to index the data:
</p>
<pre class="brush:bash">curl 'localhost:8983/solr/collection1/update?commit=true' --data-binary @mem.xml -H 'Content-type:application/xml'
curl 'localhost:8983/solr/collection1/update?commit=true' --data-binary @monitor.xml -H 'Content-type:application/xml'
curl 'localhost:8983/solr/collection1/update?commit=true' --data-binary @monitor2.xml -H 'Content-type:application/xml'</pre>
<p>After executing the above commands we get the following number of documents:</p>
<ul>
<li>The whole collection holds <strong>5</strong> documents</li>
<li>Shard located on Solr running on port <strong>8983</strong> host <strong>1</strong> document</li>
<li>Shard located on Solr running on port<strong> 7983</strong> has <strong>4</strong> documents</li>
</ul>
<h3>Querying with ZooKeeper not present</h3>
<p>Now we go to the next step &#8211; we shutdown our ZooKeeper instance and we try to run a simple query by sending the following command:
</p>
<pre class="brush:bash">curl 'localhost:8983/solr/collection1/select?q=*:*&amp;indent=true'</pre>
<p>In result we get the following response:
</p>
<pre class="brush:xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;response&gt;
 &lt;lst name="responseHeader"&gt;
  &lt;int name="status"&gt;0&lt;/int&gt;
  &lt;int name="QTime"&gt;16&lt;/int&gt;
  &lt;lst name="params"&gt;
   &lt;str name="indent"&gt;true&lt;/str&gt;
   &lt;str name="q"&gt;*:*&lt;/str&gt;
  &lt;/lst&gt;
 &lt;/lst&gt;
&lt;result name="response" numFound="5" start="0" maxScore="1.0"&gt;
&lt;doc&gt;
 &lt;str name="id"&gt;TWINX2048-3200PRO&lt;/str&gt; 
 &lt;str name="name"&gt;CORSAIR  XMS 2GB (2 x 1GB) 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) Dual Channel Kit System Memory - Retail&lt;/str&gt;
 &lt;str name="manu"&gt;Corsair Microsystems Inc.&lt;/str&gt;
 &lt;str name="manu_id_s"&gt;corsair&lt;/str&gt;
 &lt;arr name="cat"&gt;
  &lt;str&gt;electronics&lt;/str&gt;
  &lt;str&gt;memory&lt;/str&gt;
 &lt;/arr&gt;
 &lt;arr name="features"&gt;
  &lt;str&gt;CAS latency 2,    2-3-3-6 timing, 2.75v, unbuffered, heat-spreader&lt;/str&gt;
 &lt;/arr&gt;
 &lt;float name="price"&gt;185.0&lt;/float&gt;
 &lt;str name="price_c"&gt;185,USD&lt;/str&gt;
 &lt;int name="popularity"&gt;5&lt;/int&gt;
 &lt;bool name="inStock"&gt;true&lt;/bool&gt;
 &lt;str name="store"&gt;37.7752,-122.4232&lt;/str&gt;
 &lt;date name="manufacturedate_dt"&gt;2006-02-13T15:26:37Z&lt;/date&gt;
 &lt;str name="payloads"&gt;electronics|6.0 memory|3.0&lt;/str&gt;
 &lt;long name="_version_"&gt;1453219034197655552&lt;/long&gt;
&lt;/doc&gt;
&lt;doc&gt;
 &lt;str name="id"&gt;VS1GB400C3&lt;/str&gt;
 &lt;str name="name"&gt;CORSAIR ValueSelect 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - Retail&lt;/str&gt;
 &lt;str name="manu"&gt;Corsair Microsystems Inc.&lt;/str&gt;
 &lt;str name="manu_id_s"&gt;corsair&lt;/str&gt;
 &lt;arr name="cat"&gt;
  &lt;str&gt;electronics&lt;/str&gt;
  &lt;str&gt;memory&lt;/str&gt;
 &lt;/arr&gt;
 &lt;float name="price"&gt;74.99&lt;/float&gt;
 &lt;str name="price_c"&gt;74.99,USD&lt;/str&gt;
 &lt;int name="popularity"&gt;7&lt;/int&gt;
 &lt;bool name="inStock"&gt;true&lt;/bool&gt;
 &lt;str name="store"&gt;37.7752,-100.0232&lt;/str&gt;
 &lt;date name="manufacturedate_dt"&gt;2006-02-13T15:26:37Z&lt;/date&gt;
 &lt;str name="payloads"&gt;electronics|4.0 memory|2.0&lt;/str&gt;
 &lt;long name="_version_"&gt;1453219034252181504&lt;/long&gt;
&lt;/doc&gt;
&lt;doc&gt;
 &lt;str name="id"&gt;VDBDB1A16&lt;/str&gt;
 &lt;str name="name"&gt;A-DATA V-Series 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - OEM&lt;/str&gt;
 &lt;str name="manu"&gt;A-DATA Technology Inc.&lt;/str&gt;
 &lt;str name="manu_id_s"&gt;corsair&lt;/str&gt;
 &lt;arr name="cat"&gt;
  &lt;str&gt;electronics&lt;/str&gt;
  &lt;str&gt;memory&lt;/str&gt;
 &lt;/arr&gt;
 &lt;arr name="features"&gt;
  &lt;str&gt;CAS latency 3,     2.7v&lt;/str&gt;
 &lt;/arr&gt;
 &lt;int name="popularity"&gt;0&lt;/int&gt;
 &lt;bool name="inStock"&gt;true&lt;/bool&gt;
 &lt;str name="store"&gt;45.18414,-93.88141&lt;/str&gt;
 &lt;date name="manufacturedate_dt"&gt;2006-02-13T15:26:37Z&lt;/date&gt;
 &lt;str name="payloads"&gt;electronics|0.9 memory|0.1&lt;/str&gt;
 &lt;long name="_version_"&gt;1453219034255327232&lt;/long&gt;
&lt;/doc&gt;
&lt;doc&gt;
 &lt;str name="id"&gt;3007WFP&lt;/str&gt;
 &lt;str name="name"&gt;Dell Widescreen UltraSharp 3007WFP&lt;/str&gt;
 &lt;str name="manu"&gt;Dell, Inc.&lt;/str&gt;
 &lt;str name="manu_id_s"&gt;dell&lt;/str&gt;
 &lt;arr name="cat"&gt;
  &lt;str&gt;electronics&lt;/str&gt;
  &lt;str&gt;monitor&lt;/str&gt;
 &lt;/arr&gt;
 &lt;arr name="features"&gt;
  &lt;str&gt;30" TFT active matrix LCD, 2560 x 1600, .25mm dot pitch, 700:1 contrast&lt;/str&gt;
 &lt;/arr&gt;
 &lt;str name="includes"&gt;USB cable&lt;/str&gt;
 &lt;float name="weight"&gt;401.6&lt;/float&gt;
 &lt;float name="price"&gt;2199.0&lt;/float&gt;
 &lt;str name="price_c"&gt;2199,USD&lt;/str&gt;
 &lt;int name="popularity"&gt;6&lt;/int&gt;
 &lt;bool name="inStock"&gt;true&lt;/bool&gt;
 &lt;str name="store"&gt;43.17614,-90.57341&lt;/str&gt;
 &lt;long name="_version_"&gt;1453219041357332480&lt;/long&gt;
&lt;/doc&gt;
&lt;doc&gt;
 &lt;str name="id"&gt;VA902B&lt;/str&gt;
 &lt;str name="name"&gt;ViewSonic VA902B - flat panel display - TFT - 19"&lt;/str&gt;
 &lt;str name="manu"&gt;ViewSonic Corp.&lt;/str&gt;
 &lt;str name="manu_id_s"&gt;viewsonic&lt;/str&gt;
 &lt;arr name="cat"&gt;
  &lt;str&gt;electronics&lt;/str&gt;
  &lt;str&gt;monitor&lt;/str&gt;
 &lt;/arr&gt;
 &lt;arr name="features"&gt;
  &lt;str&gt;19" TFT active matrix LCD, 8ms response time, 1280 x 1024 native resolution&lt;/str&gt;
 &lt;/arr&gt;
 &lt;float name="weight"&gt;190.4&lt;/float&gt;
 &lt;float name="price"&gt;279.95&lt;/float&gt;
 &lt;str name="price_c"&gt;279.95,USD&lt;/str&gt;
 &lt;int name="popularity"&gt;6&lt;/int&gt;
 &lt;bool name="inStock"&gt;true&lt;/bool&gt;
 &lt;str name="store"&gt;45.18814,-93.88541&lt;/str&gt;
 &lt;long name="_version_"&gt;1453219045997281280&lt;/long&gt;&lt;/doc&gt;
&lt;/result&gt;
&lt;/response&gt;</pre>
<p>As we can see Solr responded correctly. This is because Solr already has the clusterstate.json file cached. To search Solr doesn&#8217;t need to update that file, so search should and is working as we could see.</p>
<h3>Indexing with failed ZooKeeper</h3>
<p>Without turning on our ZooKeeper instance we try to run the following command:
</p>
<pre class="brush:bash">curl 'localhost:8983/solr/collection1/update?commit=true' --data-binary @hd.xml -H 'Content-type:application/xml'</pre>
<p>The above command should result in indexing the contents of the <em>hd.xml </em>file. After a longer period of time Solr responds with the following information:
</p>
<pre class="brush:xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;response&gt;
&lt;lst name="responseHeader"&gt;&lt;int name="status"&gt;503&lt;/int&gt;&lt;int name="QTime"&gt;15096&lt;/int&gt;&lt;/lst&gt;&lt;lst name="error"&gt;&lt;str name="msg"&gt;Cannot talk to ZooKeeper - Updates are disabled.&lt;/str&gt;&lt;int name="code"&gt;503&lt;/int&gt;&lt;/lst&gt;
&lt;/response&gt;</pre>
<p>So as you can see we are not able to index data without working ZooKeeper <em>ensemble</em>.</p>
<h3>Starting ZooKeeper again</h3>
<p>So let&#8217;s see what will happen when we start our ZooKeeper instance again without restarting Solr nodes. After starting ZooKeeper we try to run the same indexing command, we just did, once again:
</p>
<pre class="brush:bash">curl 'localhost:8983/solr/collection1/update?commit=true' --data-binary @hd.xml -H 'Content-type:application/xml'</pre>
<p>And this time the response is different:
</p>
<pre class="brush:xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;response&gt;
&lt;lst name="responseHeader"&gt;&lt;int name="status"&gt;0&lt;/int&gt;&lt;int name="QTime"&gt;118&lt;/int&gt;&lt;/lst&gt;
&lt;/response&gt;</pre>
<p>As we can see the indexing request was successful this time. This allows us to assume that the connection to ZooKeeper was re-established by Solr. We can see that in Solr and ZooKeeper logs.</p>
<h3>Short summary</h3>
<p>As you can see, our short test allowed to see what happens when our ZooKeeper <em>ensemble </em>fails and what we can expect from Solr in such rare cases. I hope this blog entry will help you with some doubts about SolrCloud and its usefulnesses.</p>
<p>Please also remember that during the test, the cluster state did not change &#8211; all shards were accessible and working. We will see what will be happening when shards or replicas fails when ZooKeeeper is down in the next blog entry about SolrCloud.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://solr.pl/en/2013/12/02/solrcloud-what-happens-when-zookeeper-fails-2/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>SolrCloud &#8211; What happens when ZooKeeper fails?</title>
		<link>https://solr.pl/en/2013/12/02/solrcloud-what-happens-when-zookeeper-fails/</link>
					<comments>https://solr.pl/en/2013/12/02/solrcloud-what-happens-when-zookeeper-fails/#respond</comments>
		
		<dc:creator><![CDATA[Rafał Kuć]]></dc:creator>
		<pubDate>Mon, 02 Dec 2013 14:13:03 +0000</pubDate>
				<category><![CDATA[Solr]]></category>
		<category><![CDATA[solr]]></category>
		<category><![CDATA[zookeeper]]></category>
		<guid isPermaLink="false">http://sematext.solr.pl/?p=618</guid>

					<description><![CDATA[One of the questions I tend to get is what happens with SolrCloud cluster when ZooKeeper fails. Of course we are not talking about a single ZooKeeper instance failure, but the whole ensemble not being accessible and so the quorum]]></description>
										<content:encoded><![CDATA[<p>One of the questions I tend to get is what happens with SolrCloud cluster when ZooKeeper fails. Of course we are not talking about a single ZooKeeper instance failure, but the whole <em>ensemble</em> not being accessible and so the <em>quorum</em> not present. Because the answer to this question is very easy to verify i decided to make a simple blog post to show what happens when ZooKeeper fails.</p>
<p><span id="more-618"></span></p>
<h3>Test environment</h3>
<p>The test environment was very simple:</p>
<ul>
<li>A single virtual machine running under Linux operating system</li>
<li>A single instance of ZooKeeper (which will be suitable for our test)</li>
<li>Two Solr instances with a single collection deployed</li>
<li>Solr <a title="Apache Lucene and Solr 4.6" href="http://solr.pl/en/2013/11/24/apache-lucene-and-solr-4-6/">4.6</a></li>
</ul>
<p>In order to create our test collection I&#8217;ve uploaded the configuration to ZooKeeper and used the following command:
</p>
<pre class="brush:bash">curl 'http://localhost:8983/solr/admin/collections?action=CREATE&amp;name=collection1&amp;numShards=2&amp;replicationFactor=1'</pre>
<p>The cloud view of the example cluster was as follows:
</p>
<p style="text-align: center;"><a href="http://solr.pl/wp-content/uploads/2013/12/cloud_view.png"><img decoding="async" class="aligncenter  wp-image-3330" alt="cloud_view" src="http://solr.pl/wp-content/uploads/2013/12/cloud_view.png" width="495" height="44"></a></p>
<h3>Test data indexing</h3>
<p>The next step in our test will be indexing. We will index a few example documents that are provided with Solr in the <em>exampledocs</em> directory. The following commands were used to index the data:
</p>
<pre class="brush:bash">curl 'localhost:8983/solr/collection1/update?commit=true' --data-binary @mem.xml -H 'Content-type:application/xml'
curl 'localhost:8983/solr/collection1/update?commit=true' --data-binary @monitor.xml -H 'Content-type:application/xml'
curl 'localhost:8983/solr/collection1/update?commit=true' --data-binary @monitor2.xml -H 'Content-type:application/xml'</pre>
<p>After executing the above commands we get the following number of documents:</p>
<ul>
<li>The whole collection holds <strong>5</strong> documents</li>
<li>Shard located on Solr running on port <strong>8983</strong> host <strong>1</strong> document</li>
<li>Shard located on Solr running on port<strong> 7983</strong> has <strong>4</strong> documents</li>
</ul>
<h3>Querying with ZooKeeper not present</h3>
<p>Now we go to the next step &#8211; we shutdown our ZooKeeper instance and we try to run a simple query by sending the following command:
</p>
<pre class="brush:bash">curl 'localhost:8983/solr/collection1/select?q=*:*&amp;indent=true'</pre>
<p>In result we get the following response:
</p>
<pre class="brush:xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;response&gt;
 &lt;lst name="responseHeader"&gt;
  &lt;int name="status"&gt;0&lt;/int&gt;
  &lt;int name="QTime"&gt;16&lt;/int&gt;
  &lt;lst name="params"&gt;
   &lt;str name="indent"&gt;true&lt;/str&gt;
   &lt;str name="q"&gt;*:*&lt;/str&gt;
  &lt;/lst&gt;
 &lt;/lst&gt;
&lt;result name="response" numFound="5" start="0" maxScore="1.0"&gt;
&lt;doc&gt;
 &lt;str name="id"&gt;TWINX2048-3200PRO&lt;/str&gt; 
 &lt;str name="name"&gt;CORSAIR  XMS 2GB (2 x 1GB) 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) Dual Channel Kit System Memory - Retail&lt;/str&gt;
 &lt;str name="manu"&gt;Corsair Microsystems Inc.&lt;/str&gt;
 &lt;str name="manu_id_s"&gt;corsair&lt;/str&gt;
 &lt;arr name="cat"&gt;
  &lt;str&gt;electronics&lt;/str&gt;
  &lt;str&gt;memory&lt;/str&gt;
 &lt;/arr&gt;
 &lt;arr name="features"&gt;
  &lt;str&gt;CAS latency 2,    2-3-3-6 timing, 2.75v, unbuffered, heat-spreader&lt;/str&gt;
 &lt;/arr&gt;
 &lt;float name="price"&gt;185.0&lt;/float&gt;
 &lt;str name="price_c"&gt;185,USD&lt;/str&gt;
 &lt;int name="popularity"&gt;5&lt;/int&gt;
 &lt;bool name="inStock"&gt;true&lt;/bool&gt;
 &lt;str name="store"&gt;37.7752,-122.4232&lt;/str&gt;
 &lt;date name="manufacturedate_dt"&gt;2006-02-13T15:26:37Z&lt;/date&gt;
 &lt;str name="payloads"&gt;electronics|6.0 memory|3.0&lt;/str&gt;
 &lt;long name="_version_"&gt;1453219034197655552&lt;/long&gt;
&lt;/doc&gt;
&lt;doc&gt;
 &lt;str name="id"&gt;VS1GB400C3&lt;/str&gt;
 &lt;str name="name"&gt;CORSAIR ValueSelect 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - Retail&lt;/str&gt;
 &lt;str name="manu"&gt;Corsair Microsystems Inc.&lt;/str&gt;
 &lt;str name="manu_id_s"&gt;corsair&lt;/str&gt;
 &lt;arr name="cat"&gt;
  &lt;str&gt;electronics&lt;/str&gt;
  &lt;str&gt;memory&lt;/str&gt;
 &lt;/arr&gt;
 &lt;float name="price"&gt;74.99&lt;/float&gt;
 &lt;str name="price_c"&gt;74.99,USD&lt;/str&gt;
 &lt;int name="popularity"&gt;7&lt;/int&gt;
 &lt;bool name="inStock"&gt;true&lt;/bool&gt;
 &lt;str name="store"&gt;37.7752,-100.0232&lt;/str&gt;
 &lt;date name="manufacturedate_dt"&gt;2006-02-13T15:26:37Z&lt;/date&gt;
 &lt;str name="payloads"&gt;electronics|4.0 memory|2.0&lt;/str&gt;
 &lt;long name="_version_"&gt;1453219034252181504&lt;/long&gt;
&lt;/doc&gt;
&lt;doc&gt;
 &lt;str name="id"&gt;VDBDB1A16&lt;/str&gt;
 &lt;str name="name"&gt;A-DATA V-Series 1GB 184-Pin DDR SDRAM Unbuffered DDR 400 (PC 3200) System Memory - OEM&lt;/str&gt;
 &lt;str name="manu"&gt;A-DATA Technology Inc.&lt;/str&gt;
 &lt;str name="manu_id_s"&gt;corsair&lt;/str&gt;
 &lt;arr name="cat"&gt;
  &lt;str&gt;electronics&lt;/str&gt;
  &lt;str&gt;memory&lt;/str&gt;
 &lt;/arr&gt;
 &lt;arr name="features"&gt;
  &lt;str&gt;CAS latency 3,     2.7v&lt;/str&gt;
 &lt;/arr&gt;
 &lt;int name="popularity"&gt;0&lt;/int&gt;
 &lt;bool name="inStock"&gt;true&lt;/bool&gt;
 &lt;str name="store"&gt;45.18414,-93.88141&lt;/str&gt;
 &lt;date name="manufacturedate_dt"&gt;2006-02-13T15:26:37Z&lt;/date&gt;
 &lt;str name="payloads"&gt;electronics|0.9 memory|0.1&lt;/str&gt;
 &lt;long name="_version_"&gt;1453219034255327232&lt;/long&gt;
&lt;/doc&gt;
&lt;doc&gt;
 &lt;str name="id"&gt;3007WFP&lt;/str&gt;
 &lt;str name="name"&gt;Dell Widescreen UltraSharp 3007WFP&lt;/str&gt;
 &lt;str name="manu"&gt;Dell, Inc.&lt;/str&gt;
 &lt;str name="manu_id_s"&gt;dell&lt;/str&gt;
 &lt;arr name="cat"&gt;
  &lt;str&gt;electronics&lt;/str&gt;
  &lt;str&gt;monitor&lt;/str&gt;
 &lt;/arr&gt;
 &lt;arr name="features"&gt;
  &lt;str&gt;30" TFT active matrix LCD, 2560 x 1600, .25mm dot pitch, 700:1 contrast&lt;/str&gt;
 &lt;/arr&gt;
 &lt;str name="includes"&gt;USB cable&lt;/str&gt;
 &lt;float name="weight"&gt;401.6&lt;/float&gt;
 &lt;float name="price"&gt;2199.0&lt;/float&gt;
 &lt;str name="price_c"&gt;2199,USD&lt;/str&gt;
 &lt;int name="popularity"&gt;6&lt;/int&gt;
 &lt;bool name="inStock"&gt;true&lt;/bool&gt;
 &lt;str name="store"&gt;43.17614,-90.57341&lt;/str&gt;
 &lt;long name="_version_"&gt;1453219041357332480&lt;/long&gt;
&lt;/doc&gt;
&lt;doc&gt;
 &lt;str name="id"&gt;VA902B&lt;/str&gt;
 &lt;str name="name"&gt;ViewSonic VA902B - flat panel display - TFT - 19"&lt;/str&gt;
 &lt;str name="manu"&gt;ViewSonic Corp.&lt;/str&gt;
 &lt;str name="manu_id_s"&gt;viewsonic&lt;/str&gt;
 &lt;arr name="cat"&gt;
  &lt;str&gt;electronics&lt;/str&gt;
  &lt;str&gt;monitor&lt;/str&gt;
 &lt;/arr&gt;
 &lt;arr name="features"&gt;
  &lt;str&gt;19" TFT active matrix LCD, 8ms response time, 1280 x 1024 native resolution&lt;/str&gt;
 &lt;/arr&gt;
 &lt;float name="weight"&gt;190.4&lt;/float&gt;
 &lt;float name="price"&gt;279.95&lt;/float&gt;
 &lt;str name="price_c"&gt;279.95,USD&lt;/str&gt;
 &lt;int name="popularity"&gt;6&lt;/int&gt;
 &lt;bool name="inStock"&gt;true&lt;/bool&gt;
 &lt;str name="store"&gt;45.18814,-93.88541&lt;/str&gt;
 &lt;long name="_version_"&gt;1453219045997281280&lt;/long&gt;&lt;/doc&gt;
&lt;/result&gt;
&lt;/response&gt;</pre>
<p>As we can see Solr responded correctly. This is because Solr already has the clusterstate.json file cached. To search Solr doesn&#8217;t need to update that file, so search should and is working as we could see.</p>
<h3>Indexing with failed ZooKeeper</h3>
<p>Without turning on our ZooKeeper instance we try to run the following command:
</p>
<pre class="brush:bash">curl 'localhost:8983/solr/collection1/update?commit=true' --data-binary @hd.xml -H 'Content-type:application/xml'</pre>
<p>The above command should result in indexing the contents of the <em>hd.xml </em>file. After a longer period of time Solr responds with the following information:
</p>
<pre class="brush:xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;response&gt;
&lt;lst name="responseHeader"&gt;&lt;int name="status"&gt;503&lt;/int&gt;&lt;int name="QTime"&gt;15096&lt;/int&gt;&lt;/lst&gt;&lt;lst name="error"&gt;&lt;str name="msg"&gt;Cannot talk to ZooKeeper - Updates are disabled.&lt;/str&gt;&lt;int name="code"&gt;503&lt;/int&gt;&lt;/lst&gt;
&lt;/response&gt;</pre>
<p>So as you can see we are not able to index data without working ZooKeeper <em>ensemble</em>.</p>
<h3>Starting ZooKeeper again</h3>
<p>So let&#8217;s see what will happen when we start our ZooKeeper instance again without restarting Solr nodes. After starting ZooKeeper we try to run the same indexing command, we just did, once again:
</p>
<pre class="brush:bash">curl 'localhost:8983/solr/collection1/update?commit=true' --data-binary @hd.xml -H 'Content-type:application/xml'</pre>
<p>And this time the response is different:
</p>
<pre class="brush:xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;response&gt;
&lt;lst name="responseHeader"&gt;&lt;int name="status"&gt;0&lt;/int&gt;&lt;int name="QTime"&gt;118&lt;/int&gt;&lt;/lst&gt;
&lt;/response&gt;</pre>
<p>As we can see the indexing request was successful this time. This allows us to assume that the connection to ZooKeeper was re-established by Solr. We can see that in Solr and ZooKeeper logs.</p>
<h3>Short summary</h3>
<p>As you can see, our short test allowed to see what happens when our ZooKeeper <em>ensemble </em>fails and what we can expect from Solr in such rare cases. I hope this blog entry will help you with some doubts about SolrCloud and its usefulnesses.</p>
<p>Please also remember that during the test, the cluster state did not change &#8211; all shards were accessible and working. We will see what will be happening when shards or replicas fails when ZooKeeeper is down in the next blog entry about SolrCloud.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://solr.pl/en/2013/12/02/solrcloud-what-happens-when-zookeeper-fails/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>SOLR-1873 &#8211; Solr Cloud in trunk</title>
		<link>https://solr.pl/en/2010/10/14/solr-1873-solr-cloud-in-trunk/</link>
					<comments>https://solr.pl/en/2010/10/14/solr-1873-solr-cloud-in-trunk/#respond</comments>
		
		<dc:creator><![CDATA[Rafał Kuć]]></dc:creator>
		<pubDate>Thu, 14 Oct 2010 12:15:51 +0000</pubDate>
				<category><![CDATA[Solr]]></category>
		<category><![CDATA[cloud]]></category>
		<category><![CDATA[solr]]></category>
		<category><![CDATA[solr cloud]]></category>
		<category><![CDATA[zookeeper]]></category>
		<guid isPermaLink="false">http://sematext.solr.pl/?p=86</guid>

					<description><![CDATA[A few minutes ago changes marked as SOLR-1873 in the Apache JIRA system were added the trunk branch of Lucene and Solr SVN repository This means that the developer version of Solr was expanded with the functionality called Solr Cloud]]></description>
										<content:encoded><![CDATA[<p>A few minutes ago changes marked as <a href="https://issues.apache.org/jira/browse/SOLR-1873" target="_blank" rel="noopener noreferrer">SOLR-1873</a> in the Apache JIRA system were added the <em>trunk</em> branch of Lucene and Solr SVN repository This means that the developer version of Solr was expanded with the functionality called <em>Solr Cloud </em>&#8211; the ability of managing the distributed Solr deployment from the administration pages.</p>
<p>We will try to write something about these new functionality as soon as possible <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f609.png" alt="😉" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://solr.pl/en/2010/10/14/solr-1873-solr-cloud-in-trunk/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
