Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 744AA200CA4 for ; Wed, 7 Jun 2017 08:51:25 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 72F3E160BB6; Wed, 7 Jun 2017 06:51:25 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 92F3F160BD0 for ; Wed, 7 Jun 2017 08:51:24 +0200 (CEST) Received: (qmail 74390 invoked by uid 500); 7 Jun 2017 06:51:23 -0000 Mailing-List: contact issues-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list issues@hbase.apache.org Received: (qmail 74379 invoked by uid 99); 7 Jun 2017 06:51:23 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Jun 2017 06:51:23 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id B4B74C090C for ; Wed, 7 Jun 2017 06:51:22 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id r-0oP6VQ0IGR for ; Wed, 7 Jun 2017 06:51:21 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 1A6BF5FCA4 for ; Wed, 7 Jun 2017 06:51:20 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 44B09E0352 for ; Wed, 7 Jun 2017 06:51:19 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 60B7921E1A for ; Wed, 7 Jun 2017 06:51:18 +0000 (UTC) Date: Wed, 7 Jun 2017 06:51:18 +0000 (UTC) From: "Hudson (JIRA)" To: issues@hbase.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HBASE-15576) Scanning cursor to prevent blocking long time on ResultScanner.next() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 07 Jun 2017 06:51:25 -0000 [ https://issues.apache.org/jira/browse/HBASE-15576?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16040320#comment-16040320 ] Hudson commented on HBASE-15576: -------------------------------- SUCCESS: Integrated in Jenkins build HBase-1.4 #765 (See [https://builds.apache.org/job/HBase-1.4/765/]) HBASE-15576 Scanning cursor to prevent blocking long time on (yangzhe1991: rev 381c89b5cc463b58010ab443de9e1c1d40d8bf98) * (edit) hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientUtil.java * (add) hbase-client/src/main/java/org/apache/hadoop/hbase/client/Cursor.java * (edit) hbase-client/src/main/java/org/apache/hadoop/hbase/client/ScannerCallable.java * (edit) hbase-client/src/main/java/org/apache/hadoop/hbase/client/Scan.java * (edit) hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java * (edit) hbase-protocol/src/main/java/org/apache/hadoop/hbase/protobuf/generated/ClientProtos.java * (add) hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestScannerCursor.java * (edit) hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java * (edit) hbase-protocol/src/main/protobuf/Client.proto * (edit) hbase-client/src/main/java/org/apache/hadoop/hbase/client/ScannerCallableWithReplicas.java * (edit) hbase-client/src/main/java/org/apache/hadoop/hbase/client/Result.java * (edit) hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/RSRpcServices.java * (edit) hbase-client/src/main/java/org/apache/hadoop/hbase/client/ClientScanner.java * (edit) hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/ScannerContext.java > Scanning cursor to prevent blocking long time on ResultScanner.next() > --------------------------------------------------------------------- > > Key: HBASE-15576 > URL: https://issues.apache.org/jira/browse/HBASE-15576 > Project: HBase > Issue Type: New Feature > Reporter: Phil Yang > Assignee: Phil Yang > Fix For: 2.0.0, 1.4.0 > > Attachments: HBASE-15576.branch-1.v01.patch, HBASE-15576.branch-1.v01.patch, HBASE-15576.branch-1.v01.patch, HBASE-15576.branch-1.v02.patch, HBASE-15576.v01.patch, HBASE-15576.v02.patch, HBASE-15576.v03.patch, HBASE-15576.v03.patch, HBASE-15576.v04.patch, HBASE-15576.v04.patch, HBASE-15576.v05.patch, HBASE-15576.v06.patch, HBASE-15576.v07.patch > > > After 1.1.0 released, we have partial and heartbeat protocol in scanning to prevent responding large data or timeout. Now for ResultScanner.next(), we may block for longer time larger than timeout settings to get a Result if the row is very large, or filter is sparse, or there are too many delete markers in files. > However, in some scenes, we don't want it to be blocked for too long. For example, a web service which handles requests from mobile devices whose network is not stable and we can not set timeout too long(eg. only 5 seconds) between mobile and web service. This service will scan rows from HBase and return it to mobile devices. In this scene, the simplest way is to make the web service stateless. Apps in mobile devices will send several requests one by one to get the data until enough just like paging a list. In each request it will carry a start position which depends on the last result from web service. Different requests can be sent to different web service server because it is stateless. > Therefore, the stateless web service need a cursor from HBase telling where we have scanned in RegionScanner when HBase client receives an empty heartbeat. And the service will return the cursor to mobile device although the response has no data. In next request we can start at the position of cursor, without the cursor we have to scan from last returned result and we may timeout forever. And of course even if the heartbeat message is not empty we can still use cursor to prevent re-scan the same rows/cells which has beed skipped. > Obviously, we will give up consistency for scanning because even HBase client is also stateless, but it is acceptable in this scene. And maybe we can keep mvcc in cursor so we can get a consistent view? > HBASE-13099 had some discussion, but it has no further progress by now. > API: > In Scan we need a new method setNeedCursorResult(true) to get the cursor row key when there is a RPC response but client can not return any Result. In this mode we will not block ResultScanner.next() longer than this timeout setting. > {code} > while (r = scanner.next() && r != null) { > if(r.isCursor()){ > // scanning is not end, it is a cursor, save its row key and close scanner if you want, or > // just continue the loop to call next(). > } else { > // just like before > } > } > // scanning is end > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)