[ 
https://issues.apache.org/jira/browse/PHOENIX-2221?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14949791#comment-14949791
 ] 

Rajeshbabu Chintaguntla commented on PHOENIX-2221:
--------------------------------------------------

Minor comments:
We need not change this code any way if we don't configure anything setting 
PhoenixIndexFailurePolicy as default. 
{noformat}
-        // Install handler that will attempt to disable the index first before 
killing the region
-        // server
-        conf.setIfUnset(IndexWriter.INDEX_FAILURE_POLICY_CONF_KEY,
-            PhoenixIndexFailurePolicy.class.getName());
+        String readable = 
conf.get(QueryServices.INDEX_RECOVERY_FAILURE_POLICY_KEY);
+        boolean indexReadable = readable != null && 
readable.equals(ReadableIndexFailurePolicy.class.getName());
+        if (indexReadable) {
+            conf.setIfUnset(IndexWriter.INDEX_FAILURE_POLICY_CONF_KEY,
+                    ReadableIndexFailurePolicy.class.getName());
+        } else {
+            // Install handler that will attempt to disable the index first 
before killing the region
+            // server
+            conf.setIfUnset(IndexWriter.INDEX_FAILURE_POLICY_CONF_KEY,
+                    PhoenixIndexFailurePolicy.class.getName());
+        }
{noformat}

In ReadableIndexFailurePolicy we need not check for the failure policy because 
it's any way ReadableIndexFailurePolicy so directly pass readable state bytes 
without any checks.
{noformat}
+        String readable = 
env.getConfiguration().get(QueryServices.INDEX_RECOVERY_FAILURE_POLICY_KEY);
+        boolean blockWrite = readable !=null && 
readable.equals(ReadableIndexFailurePolicy.class.getName());
+        byte[] indexState = blockWrite? 
PIndexState.READABLE.getSerializedBytes() : 
PIndexState.DISABLE.getSerializedBytes();
{noformat}


> Option to make data regions not writable when index regions are not available
> -----------------------------------------------------------------------------
>
>                 Key: PHOENIX-2221
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2221
>             Project: Phoenix
>          Issue Type: Improvement
>            Reporter: Devaraj Das
>            Assignee: Alicia Ying Shu
>         Attachments: PHOENIX-2221-v1.patch, PHOENIX-2221-v2.patch, 
> PHOENIX-2221.patch
>
>
> In one usecase, it was deemed better to not accept writes when the index 
> regions are unavailable for any reason (as opposed to disabling the index and 
> the queries doing bigger data-table scans).
> The idea is that the index regions are kept consistent with the data regions, 
> and when a query runs against the index regions, one can be reasonably sure 
> that the query ran with the most recent data in the data regions. When the 
> index regions are unavailable, the writes to the data table are rejected. 
> Read queries off of the index regions would have deterministic performance 
> (and on the other hand if the index is disabled, then the read queries would 
> have to go to the data regions until the indexes are rebuilt, and the queries 
> would suffer).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to