Return-Path: X-Original-To: apmail-hive-dev-archive@www.apache.org Delivered-To: apmail-hive-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 26AE11016C for ; Sat, 22 Jun 2013 20:44:08 +0000 (UTC) Received: (qmail 13508 invoked by uid 500); 22 Jun 2013 20:44:07 -0000 Delivered-To: apmail-hive-dev-archive@hive.apache.org Received: (qmail 13464 invoked by uid 500); 22 Jun 2013 20:44:07 -0000 Mailing-List: contact dev-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 dev@hive.apache.org Received: (qmail 13455 invoked by uid 99); 22 Jun 2013 20:44:07 -0000 Received: from reviews-vm.apache.org (HELO reviews.apache.org) (140.211.11.40) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 22 Jun 2013 20:44:07 +0000 Received: from reviews.apache.org (localhost [127.0.0.1]) by reviews.apache.org (Postfix) with ESMTP id B66931C0297; Sat, 22 Jun 2013 20:43:59 +0000 (UTC) Content-Type: multipart/alternative; boundary="===============0935194495166966848==" MIME-Version: 1.0 Subject: Review Request: HIVE-3756 (LOAD DATA does not honor permission inheritance) From: "Chaoyu Tang" To: "hive" , "Chaoyu Tang" Date: Sat, 22 Jun 2013 20:43:59 -0000 Message-ID: <20130622204359.32008.87124@reviews.apache.org> X-ReviewBoard-URL: https://reviews.apache.org Auto-Submitted: auto-generated Sender: "Chaoyu Tang" X-ReviewGroup: hive X-ReviewRequest-URL: https://reviews.apache.org/r/12050/ X-Sender: "Chaoyu Tang" Reply-To: "Chaoyu Tang" --===============0935194495166966848== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable ----------------------------------------------------------- This is an automatically generated e-mail. To reply, visit: https://reviews.apache.org/r/12050/ ----------------------------------------------------------- Review request for hive. Description ------- Problems: 1. When doing load data or insert overwrite to a table, the data files unde= r database/table directory could not inherit their parent's permissions (i.= e. group) as described in HIVE-3756. 2. Beside the group issue, the read/write permission mode is also not inher= ited 3. Same problem affects the partition files (see HIVE-3094) Cause: The task results (from load data or insert overwrite) are initially stored = in scratchdir and then loaded under warehouse table directory. FileSystem.r= ename is used in this step (e.g. LoadTable/LoadPartition) to move the dirs/= files but it preserves their permissions (including group and mode) which a= re determined by scratchdir permission or umask. If the scratchdir has diff= erent permissions from those of warehouse table directories, the problem oc= curs. Solution: After the FileSystem.rename is called, changing all renamed (moved) files/d= irs to their destination parents' permissions if needed (say if hive.wareho= use.subdir.inherit.perms is true). Here I introduced a new method renameFil= e doing both rename and permission. It replaces the FileSystem.rename used = in LoadTable/LoadPartition. I do not replace rename used to move files/dirs= under same scratchdir in the middle of task processing. It looks to me not= necessary since they are temp files and also probably access protected by = top scratchdir mode 700 (HIVE-4487). This addresses bugs HIVE- and HIVE-3756. https://issues.apache.org/jira/browse/HIVE- https://issues.apache.org/jira/browse/HIVE-3756 Diffs ----- ql/src/java/org/apache/hadoop/hive/ql/metadata/Hive.java 17daaa1 = Diff: https://reviews.apache.org/r/12050/diff/ Testing ------- The following cases tested that all created subdirs/files inherit their par= ents' permission mode and group in : 1). create database; 2). create table;= 3). load data; 4) insert overwrite; 5) partitions. {code} hive> dfs -ls -d /user/tester1/hive; = = drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:20 /user/teste= r1/hive hive> create database tester1 COMMENT 'Database for user tester1' LOCATION = '/user/tester1/hive/tester1.db'; hive> dfs -ls -R /user/tester1/hive; = = drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:21 /user/teste= r1/hive/tester1.db hive> use tester1; hive> create table tester1.tst1(col1 int, col2 string) ROW FORMAT DELIMITE= D FIELDS TERMINATED BY ',' STORED AS TEXTFILE; hive> dfs -ls -R /user/tester1/hive; = = drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:22 /user/teste= r1/hive/tester1.db drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:22 /user/teste= r1/hive/tester1.db/tst1 hive> load data local inpath '/home/tester1/tst1.input' into table tst1; = = hive> dfs -ls -R /user/tester1/hive; = drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:22 /user/teste= r1/hive/tester1.db drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:23 /user/teste= r1/hive/tester1.db/tst1 -rw-rw---- 3 tester1 testgroup123 168 2013-06-22 13:23 /user/teste= r1/hive/tester1.db/tst1/tst1.input hive> create table tester1.tst2(col1 int, col2 string) ROW FORMAT DELIMITED= FIELDS TERMINATED BY ',' STORED AS SEQUENCEFILE; hive> dfs -ls -R /user/tester1/hive; = = drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:24 /user/teste= r1/hive/tester1.db drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:23 /user/teste= r1/hive/tester1.db/tst1 -rw-rw---- 3 tester1 testgroup123 168 2013-06-22 13:23 /user/teste= r1/hive/tester1.db/tst1/tst1.input drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:24 /user/teste= r1/hive/tester1.db/tst2 hive> insert overwrite table tst2 select * from tst1; hive> dfs -ls -R /user/tester1/hive; = drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:25 /user/teste= r1/hive/tester1.db drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:23 /user/teste= r1/hive/tester1.db/tst1 -rw-rw---- 3 tester1 testgroup123 168 2013-06-22 13:23 /user/teste= r1/hive/tester1.db/tst1/tst1.input drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:25 /user/teste= r1/hive/tester1.db/tst2 -rw-rw---- 3 tester1 testgroup123 291 2013-06-22 13:25 /user/teste= r1/hive/tester1.db/tst2/000000_0 hive> create table tester1.tst3(col2 string) PARTITIONED BY (col1 int) ROW = FORMAT DELIMITED FIELDS TERMINATED BY ',' STORED AS TEXTFILE; hive> dfs -ls -R /user/tester1/hive; = = drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:27 /user/teste= r1/hive/tester1.db drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:23 /user/teste= r1/hive/tester1.db/tst1 -rw-rw---- 3 tester1 testgroup123 168 2013-06-22 13:23 /user/teste= r1/hive/tester1.db/tst1/tst1.input drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:25 /user/teste= r1/hive/tester1.db/tst2 -rw-rw---- 3 tester1 testgroup123 291 2013-06-22 13:25 /user/teste= r1/hive/tester1.db/tst2/000000_0 drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:27 /user/teste= r1/hive/tester1.db/tst3 hive> set hive.exec.dynamic.partition.mode=3Dnonstrict; = = hive> insert overwrite table tester1.tst3 partition (col1) select t1.col2, = t1.col1 from tst1 t1; hive> dfs -ls -R /user/tester1/hive; = = drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:27 /user/teste= r1/hive/tester1.db drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:23 /user/teste= r1/hive/tester1.db/tst1 -rw-rw---- 3 tester1 testgroup123 168 2013-06-22 13:23 /user/teste= r1/hive/tester1.db/tst1/tst1.input drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:25 /user/teste= r1/hive/tester1.db/tst2 -rw-rw---- 3 tester1 testgroup123 291 2013-06-22 13:25 /user/teste= r1/hive/tester1.db/tst2/000000_0 drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:28 /user/teste= r1/hive/tester1.db/tst3 drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:28 /user/teste= r1/hive/tester1.db/tst3/col1=3D1111 -rw-rw---- 3 tester1 testgroup123 51 2013-06-22 13:28 /user/teste= r1/hive/tester1.db/tst3/col1=3D1111/000000_0 drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:28 /user/teste= r1/hive/tester1.db/tst3/col1=3D2222 -rw-rw---- 3 tester1 testgroup123 51 2013-06-22 13:28 /user/teste= r1/hive/tester1.db/tst3/col1=3D2222/000000_0 drwxrwx--- - tester1 testgroup123 0 2013-06-22 13:28 /user/teste= r1/hive/tester1.db/tst3/col1=3D3333 -rw-rw---- 3 tester1 testgroup123 51 2013-06-22 13:28 /user/teste= r1/hive/tester1.db/tst3/col1=3D3333/000000_0 {code} Thanks, Chaoyu Tang --===============0935194495166966848==--