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 207AB200CBF for ; Sat, 8 Jul 2017 23:14:10 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 1518116B3FC; Sat, 8 Jul 2017 21:14:10 +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 327B616B3FB for ; Sat, 8 Jul 2017 23:14:09 +0200 (CEST) Received: (qmail 32042 invoked by uid 500); 8 Jul 2017 21:14:08 -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 32033 invoked by uid 99); 8 Jul 2017 21:14:08 -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; Sat, 08 Jul 2017 21:14:08 +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 8452FC090B for ; Sat, 8 Jul 2017 21:14:07 +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-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id B8fscBYqXXrK for ; Sat, 8 Jul 2017 21:14:04 +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 F2BF35FD02 for ; Sat, 8 Jul 2017 21:14:03 +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 8B6C7E0069 for ; Sat, 8 Jul 2017 21:14:02 +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 7391724686 for ; Sat, 8 Jul 2017 21:14:00 +0000 (UTC) Date: Sat, 8 Jul 2017 21:14:00 +0000 (UTC) From: "Eugene Koifman (JIRA)" To: issues@hive.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (HIVE-16832) duplicate ROW__ID possible in multi insert into transactional table MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Sat, 08 Jul 2017 21:14:10 -0000 [ https://issues.apache.org/jira/browse/HIVE-16832?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Eugene Koifman updated HIVE-16832: ---------------------------------- Description: {noformat} create table AcidTablePart(a int, b int) partitioned by (p string) clustered by (a) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true'); create temporary table if not exists data1 (x int); insert into data1 values (1); from data1 insert into AcidTablePart partition(p) select 0, 0, 'p' || x insert into AcidTablePart partition(p='p1') select 0, 1 {noformat} Each branch of this multi-insert create a row in partition p1/bucket0 with ROW__ID=(1,0,0). The same can happen when running SQL Merge (HIVE-10924) statement that has both Insert and Update clauses when target table has _'transactional'='true','transactional_properties'='default'_ (see HIVE-14035). This is so because Merge is internally run as a multi-insert statement. The solution relies on statement ID introduced in HIVE-11030. Each Insert clause of a multi-insert is gets a unique ID. The ROW__ID.bucketId now becomes a bit packed triplet (format version, bucketId, statementId). (Since ORC stores field names in the data file we can't rename ROW__ID.bucketId). This ensures that there are no collisions and retains desired sort properties of ROW__ID. In particular _SortedDynPartitionOptimizer_ works w/o any changes even in cases where there fewer reducers than buckets. was: {noformat} create table AcidTablePart(a int, b int) partitioned by (p string) clustered by (a) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true'); create temporary table if not exists data1 (x int); insert into data1 values (1),(2),(1); from data1 insert into AcidTablePart partition(p) select 0, 0, 'p' || x insert into AcidTablePart partition(p='p1') select 0, 1 {noformat} Each branch of this multi-insert create a row in partition p1/bucket0 with ROW__ID=(1,0,0). The same can happen when running SQL Merge (HIVE-10924) statement that has both Insert and Update clauses when target table has _'transactional'='true','transactional_properties'='default'_ (see HIVE-14035). This is so because Merge is internally run as a multi-insert statement. The solution relies on statement ID introduced in HIVE-11030. Each Insert clause of a multi-insert is gets a unique ID. The ROW__ID.bucketId now becomes a bit packed triplet (format version, bucketId, statementId). (Since ORC stores field names in the data file we can't rename ROW__ID.bucketId). This ensures that there are no collisions and retains desired sort properties of ROW__ID. In particular _SortedDynPartitionOptimizer_ works w/o any changes even in cases where there fewer reducers than buckets. > duplicate ROW__ID possible in multi insert into transactional table > ------------------------------------------------------------------- > > Key: HIVE-16832 > URL: https://issues.apache.org/jira/browse/HIVE-16832 > Project: Hive > Issue Type: Bug > Components: Transactions > Affects Versions: 2.2.0 > Reporter: Eugene Koifman > Assignee: Eugene Koifman > Priority: Critical > Attachments: HIVE-16832.01.patch, HIVE-16832.03.patch, HIVE-16832.04.patch, HIVE-16832.05.patch, HIVE-16832.06.patch, HIVE-16832.08.patch, HIVE-16832.09.patch, HIVE-16832.10.patch, HIVE-16832.11.patch, HIVE-16832.14.patch, HIVE-16832.15.patch, HIVE-16832.16.patch, HIVE-16832.17.patch, HIVE-16832.18.patch, HIVE-16832.19.patch, HIVE-16832.20.patch, HIVE-16832.20.patch > > > {noformat} > create table AcidTablePart(a int, b int) partitioned by (p string) clustered by (a) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true'); > create temporary table if not exists data1 (x int); > insert into data1 values (1); > from data1 > insert into AcidTablePart partition(p) select 0, 0, 'p' || x > insert into AcidTablePart partition(p='p1') select 0, 1 > {noformat} > Each branch of this multi-insert create a row in partition p1/bucket0 with ROW__ID=(1,0,0). > The same can happen when running SQL Merge (HIVE-10924) statement that has both Insert and Update clauses when target table has _'transactional'='true','transactional_properties'='default'_ (see HIVE-14035). This is so because Merge is internally run as a multi-insert statement. > The solution relies on statement ID introduced in HIVE-11030. Each Insert clause of a multi-insert is gets a unique ID. > The ROW__ID.bucketId now becomes a bit packed triplet (format version, bucketId, statementId). > (Since ORC stores field names in the data file we can't rename ROW__ID.bucketId). > This ensures that there are no collisions and retains desired sort properties of ROW__ID. > In particular _SortedDynPartitionOptimizer_ works w/o any changes even in cases where there fewer reducers than buckets. -- This message was sent by Atlassian JIRA (v6.4.14#64029)