From issues-return-145156-archive-asf-public=cust-asf.ponee.io@hive.apache.org Thu Dec 13 21:44:05 2018 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 E54E0180609 for ; Thu, 13 Dec 2018 21:44:04 +0100 (CET) Received: (qmail 45631 invoked by uid 500); 13 Dec 2018 20:44:04 -0000 Mailing-List: contact issues-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hive.apache.org Delivered-To: mailing list issues@hive.apache.org Received: (qmail 45621 invoked by uid 99); 13 Dec 2018 20:44:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Dec 2018 20:44:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id A3535C8D1E for ; Thu, 13 Dec 2018 20:44:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-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-eu.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 8oh5vRpSRga6 for ; Thu, 13 Dec 2018 20:44:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id 40A1160F75 for ; Thu, 13 Dec 2018 20:44:01 +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 57DD9E00D4 for ; Thu, 13 Dec 2018 20:44: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 15E5B2532A for ; Thu, 13 Dec 2018 20:44:00 +0000 (UTC) Date: Thu, 13 Dec 2018 20:44:00 +0000 (UTC) From: "Karthik Manamcheri (JIRA)" To: issues@hive.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (HIVE-21028) get_table_meta should use a fetch plan to avoid race conditions ending up in NucleusObjectNotFoundException MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HIVE-21028?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Karthik Manamcheri updated HIVE-21028: -------------------------------------- Attachment: HIVE-21028.4.patch > get_table_meta should use a fetch plan to avoid race conditions ending up in NucleusObjectNotFoundException > ----------------------------------------------------------------------------------------------------------- > > Key: HIVE-21028 > URL: https://issues.apache.org/jira/browse/HIVE-21028 > Project: Hive > Issue Type: Bug > Reporter: Karthik Manamcheri > Assignee: Karthik Manamcheri > Priority: Major > Attachments: HIVE-21028.1.patch, HIVE-21028.2.patch, HIVE-21028.3.patch, HIVE-21028.4.patch > > > The {{getTableMeta}} call retrieves the tables, loops through the tables and during this loop it retrieves the database object to get the containing database name. DataNuclues does a lazy retrieval and so, when the first call to get all the tables is done, it does not retrieve the database objects. > When this query is executed > {code}query = pm.newQuery(MTable.class, filterBuilder.toString()); > {code} > it loads all the tables, and when you do > {code} > table.getDatabase().getName() > {code} > it then goes and retrieves the database object. > *However*, there could be another thread which actually has deleted the database!! If this happens, we end up with exceptions such as > {code} > 2018-12-04 22:25:06,525 INFO DataNucleus.Datastore.Retrieve: [pool-7-thread-191]: Object with id "6930391[OID]org.apache.hadoop.hive.metastore.model.MTable" not found ! > 2018-12-04 22:25:06,527 WARN DataNucleus.Persistence: [pool-7-thread-191]: Exception thrown by StateManager.isLoaded > No such database row > org.datanucleus.exceptions.NucleusObjectNotFoundException: No such database row > {code} > We see this happen especially with calls which retrieve all the tables in all the databases (basically a call to get_table_meta with dbNames="\*" and tableNames="\*"). > To avoid this, we can define a custom fetch plan and activate it only for the get_table_meta query. This fetch plan would fetch the database object along with the MTable object. > We would first create a fetch plan on the pmf > {code} > pmf.getFetchGroup(MTable.class, "mtable_db_fetch_group").addMember("database"); > {code} > Then we use it just before calling the query > {code} > pm.getFetchPlan().addGroup("mtable_db_fetch_group"); > query = pm.newQuery(MTable.class, filterBuilder.toString()); > Collection tables = (Collection) query.executeWithArray(...); > ... > {code} > Before the API call ends, we can remove the fetch plan by > {code} > pm.getFetchPlan().removeGroup("mtable_db_fetch_group"); > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)