From issues-return-3707-archive-asf-public=cust-asf.ponee.io@phoenix.apache.org Wed Jan 2 22:14:04 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id C5071180662 for ; Wed, 2 Jan 2019 22:14:03 +0100 (CET) Received: (qmail 31620 invoked by uid 500); 2 Jan 2019 21:14:02 -0000 Mailing-List: contact issues-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list issues@phoenix.apache.org Received: (qmail 31611 invoked by uid 99); 2 Jan 2019 21:14:02 -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, 02 Jan 2019 21:14:02 +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 7E712C03A4 for ; Wed, 2 Jan 2019 21:14:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.501 X-Spam-Level: X-Spam-Status: No, score=-109.501 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5, 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 Pc75bwDCoYyR for ; Wed, 2 Jan 2019 21:14:01 +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 EF0705F1C7 for ; Wed, 2 Jan 2019 21:14:00 +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 5BADDE0177 for ; Wed, 2 Jan 2019 21:14:00 +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 0C570253C4 for ; Wed, 2 Jan 2019 21:14:00 +0000 (UTC) Date: Wed, 2 Jan 2019 21:14:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@phoenix.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (PHOENIX-5069) Use asynchronous refresh to provide non-blocking Phoenix Stats Client Cache MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/PHOENIX-5069?page=3Dcom.atlassi= an.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D16= 732430#comment-16732430 ]=20 ASF GitHub Bot commented on PHOENIX-5069: ----------------------------------------- Github user karanmehta93 commented on a diff in the pull request: https://github.com/apache/phoenix/pull/416#discussion_r244856169 =20 --- Diff: phoenix-core/src/main/java/org/apache/phoenix/query/GuidePost= sCache.java --- @@ -80,38 +94,46 @@ public GuidePostsCache(ConnectionQueryServices quer= yServices, Configuration conf // Log removals at TRACE for debugging .removalListener(new PhoenixStatsCacheRemovalListener(= )) // Automatically load the cache when entries are missi= ng - .build(new StatsLoader()); + .build(new PhoenixStatsCacheLoader(new StatsLoaderImpl= (), executor)); } =20 /** - * {@link CacheLoader} implementation for the Phoenix Table Stats = cache. + * {@link PhoenixStatsLoader} implementation for the Stats Loader. */ - protected class StatsLoader extends CacheLoader { + protected class StatsLoaderImpl implements PhoenixStatsLoader { + @Override + public boolean needsLoad() { + // Whenever it's called, we try to load stats from stats t= able + // no matter it has been updated or not. + return true; + } + @Override - public GuidePostsInfo load(GuidePostsKey statsKey) throws Exce= ption { + public GuidePostsInfo loadStats(GuidePostsKey statsKey, GuideP= ostsInfo prevGuidepostInfo) throws Exception { @SuppressWarnings("deprecation") - Table statsHTable =3D queryServices.getTable(SchemaUtil.ge= tPhysicalName( + TableName tableName =3D SchemaUtil.getPhysicalName( PhoenixDatabaseMetaData.SYSTEM_STATS_NAME_BYTES, - queryServices.getProps()).getName()); + queryServices.getProps()); + Table statsHTable =3D queryServices.getTable(tableName.get= Name()); try { GuidePostsInfo guidePostsInfo =3D StatisticsUtil.readS= tatistics(statsHTable, statsKey, HConstants.LATEST_TIMESTAMP); traceStatsUpdate(statsKey, guidePostsInfo); return guidePostsInfo; } catch (TableNotFoundException e) { // On a fresh install, stats might not yet be created,= don't warn about this. - logger.debug("Unable to locate Phoenix stats table", e= ); - return GuidePostsInfo.NO_GUIDEPOST; + logger.debug("Unable to locate Phoenix stats table: " = + tableName.toString(), e); + return prevGuidepostInfo; } catch (IOException e) { - logger.warn("Unable to read from stats table", e); + logger.warn("Unable to read from stats table: " + tabl= eName.toString(), e); // Just cache empty stats. We'll try again after some = time anyway. --- End diff -- =20 nit: remove this comment. > Use asynchronous refresh to provide non-blocking Phoenix Stats Client Cac= he > -------------------------------------------------------------------------= -- > > Key: PHOENIX-5069 > URL: https://issues.apache.org/jira/browse/PHOENIX-5069 > Project: Phoenix > Issue Type: Improvement > Reporter: Bin Shi > Assignee: Bin Shi > Priority: Major > > The current Phoenix Stats Cache uses TTL based eviction policy. A cached = entry will expire after a given amount of time (900s by default) passed sin= ce the entry's been created. This will lead to cache miss when Compiler/Opt= imizer fetches stats from cache at the next time. As you can see from the a= bove graph, fetching stats from the cache is a blocking operation =E2=80=94= when there is cache miss, it has a round trip over the wire to scan the SY= STEM.STATS Table and to get the latest stats info, rebuild the cache and fi= nally return the stats to the Compiler/Optimizer. Whenever there is a cache= miss, this blocking call causes significant performance penalty=C2=A0and s= ee periodic spikes. > *This Jira suggests to use=C2=A0asynchronous refresh mechanism=C2=A0to pr= ovide a non-blocking cache. For details, please see the linked design docum= ent below.* > [~karanmehta93] [~twdsilva@gmail.com]=C2=A0[~dbwong]=C2=A0[~elserj]=C2=A0= [~ankit@apache.org]=C2=A0[~sergey soldatov]=C2=A0 -- This message was sent by Atlassian JIRA (v7.6.3#76005)