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

ASF GitHub Bot commented on KYLIN-3499:
---------------------------------------

shaofengshi closed pull request #198: KYLIN-3499 Update HBaseResourceStore.java
URL: https://github.com/apache/kylin/pull/198
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/HBaseResourceStore.java
 
b/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/HBaseResourceStore.java
index 23df556beb..2c7494e0a7 100644
--- 
a/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/HBaseResourceStore.java
+++ 
b/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/HBaseResourceStore.java
@@ -44,6 +44,7 @@
 import org.apache.hadoop.hbase.client.ResultScanner;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.client.Table;
+import org.apache.hadoop.hbase.client.RetriesExhaustedException;
 import org.apache.hadoop.hbase.filter.CompareFilter;
 import org.apache.hadoop.hbase.filter.Filter;
 import org.apache.hadoop.hbase.filter.FilterList;
@@ -317,13 +318,20 @@ protected long checkAndPutResourceImpl(String resPath, 
byte[] content, long oldT
             byte[] bOldTS = oldTS == 0 ? null : Bytes.toBytes(oldTS);
             Put put = buildPut(resPath, newTS, row, content, table);
 
-            boolean ok = table.checkAndPut(row, B_FAMILY, B_COLUMN_TS, bOldTS, 
put);
-            logger.trace("Update row " + resPath + " from oldTs: " + oldTS + 
", to newTs: " + newTS
-                    + ", operation result: " + ok);
-            if (!ok) {
+            try {
+                boolean ok = table.checkAndPut(row, B_FAMILY, B_COLUMN_TS, 
bOldTS, put);
+                logger.trace("Update row " + resPath + " from oldTs: " + oldTS 
+ ", to newTs: " + newTS + ", operation result: " + ok);
+                if (!ok) {
+                    long real = getResourceTimestampImpl(resPath);
+                    throw new WriteConflictException(
+                            "Overwriting conflict " + resPath + ", expect old 
TS " + oldTS + ", but it is " + real);
+                }
+            } catch (RetriesExhaustedException e){
                 long real = getResourceTimestampImpl(resPath);
-                throw new WriteConflictException(
-                        "Overwriting conflict " + resPath + ", expect old TS " 
+ oldTS + ", but it is " + real);
+                // rpc timeout but resource has been already updated
+                if(newTS != real){
+                    throw e;
+                }
             }
 
             return newTS;


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> resource inconsistent caused by hbase rpc timeout
> -------------------------------------------------
>
>                 Key: KYLIN-3499
>                 URL: https://issues.apache.org/jira/browse/KYLIN-3499
>             Project: Kylin
>          Issue Type: Bug
>          Components: Storage - HBase
>    Affects Versions: all
>            Reporter: ulysses you
>            Priority: Major
>             Fix For: v2.6.0
>
>         Attachments: ca7a61b2fdbfc321e7c896c3d34fd4d4c48e3eed.patch, error.png
>
>
> KYLIN use hbase to persist resouce metadata. When hbase rpc timeout, kylin 
> would rollback the resource timestamp. It caused resource inconsistent 
> between kylin's memory and hbase if hbase already put the resource.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to