You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by bo...@apache.org on 2019/05/28 10:26:16 UTC
[impala] 07/08: IMPALA-8585: Fix for upgraded + compacted acid
tables
This is an automated email from the ASF dual-hosted git repository.
boroknagyz pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git
commit 5faf1745b0e27ff3f95d532ad5e7dc8e34310172
Author: Csaba Ringhofer <cs...@cloudera.com>
AuthorDate: Fri May 24 15:28:15 2019 +0200
IMPALA-8585: Fix for upgraded + compacted acid tables
Tables that already had data before altered to be an ACID table
keep the old data in their root table/partition directory if
hive.mm.allow.originals == true. These files should be merged to
the base file during the first compaction, so should be read only
if there is no valid base yet.
Also added EE tests for upgraded tables.
Change-Id: I062d8e76f90e0da1b954bf156208c0afb424deb1
Reviewed-on: http://gerrit.cloudera.org:8080/13427
Reviewed-by: Zoltan Borok-Nagy <bo...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
.../java/org/apache/impala/util/AcidUtils.java | 8 +++-
.../java/org/apache/impala/util/AcidUtilsTest.java | 49 ++++++++++++----------
.../queries/QueryTest/acid-compaction.test | 31 ++++++++++++++
.../functional-query/queries/QueryTest/acid.test | 18 ++++++++
tests/query_test/test_acid.py | 1 -
5 files changed, 83 insertions(+), 24 deletions(-)
diff --git a/fe/src/main/java/org/apache/impala/util/AcidUtils.java b/fe/src/main/java/org/apache/impala/util/AcidUtils.java
index cb8b66f..3d294b1 100644
--- a/fe/src/main/java/org/apache/impala/util/AcidUtils.java
+++ b/fe/src/main/java/org/apache/impala/util/AcidUtils.java
@@ -224,7 +224,13 @@ public class AcidUtils {
}
// Not in a base or a delta directory. In that case, it's probably a post-upgrade
- // file and we should include it.
+ // file.
+ // If there is no valid base: we should read the file (assuming that
+ // hive.mm.allow.originals == true)
+ // If there is a valid base: the file should be merged to the base by the
+ // compaction, so we can assume that the file is no longer valid and just
+ // waits to be deleted.
+ if (maxBaseWriteId != SENTINEL_BASE_WRITE_ID) it.remove();
}
return validStats;
}
diff --git a/fe/src/test/java/org/apache/impala/util/AcidUtilsTest.java b/fe/src/test/java/org/apache/impala/util/AcidUtilsTest.java
index 4fc72a9..0019327 100644
--- a/fe/src/test/java/org/apache/impala/util/AcidUtilsTest.java
+++ b/fe/src/test/java/org/apache/impala/util/AcidUtilsTest.java
@@ -89,8 +89,6 @@ public class AcidUtilsTest {
"base_00000100/def.txt"},
"default.test:10:1234:1,2,3",
new String[]{
- "base_01.txt",
- "post_upgrade.txt",
"base_0000005/abc.txt",
"base_0000005/0000/abc.txt"});
}
@@ -155,28 +153,35 @@ public class AcidUtilsTest {
@Test
public void testAcidStateNoBase() {
assertFiltering(new String[]{
- "delta_000005_000005_0000/",
- "delta_000005_000005_0000/lmn.txt",
- "base_000010/",
- "delta_0000012_0000012_0000/",
- "delta_0000012_0000012_0000/0000_0",
- "delta_0000012_0000012_0000/0000_1"},
- "", // writeIdList that accepts all transactions as valid
- new String[]{
- "delta_0000012_0000012_0000/0000_0",
- "delta_0000012_0000012_0000/0000_1"});
+ "base_01.txt",
+ "post_upgrade.txt",
+ "delta_000005_000005_0000/",
+ "delta_000005_000005_0000/lmn.txt",
+ "base_000010/",
+ "delta_0000012_0000012_0000/",
+ "delta_0000012_0000012_0000/0000_0",
+ "delta_0000012_0000012_0000/0000_1"},
+ "", // writeIdList that accepts all transactions as valid
+ new String[]{
+ // Post upgrade files are ignored if there is a valid base.
+ "delta_0000012_0000012_0000/0000_0",
+ "delta_0000012_0000012_0000/0000_1"});
// Same set of files, but no base directory.
assertFiltering(new String[]{
- "delta_000005_000005_0000/",
- "delta_000005_000005_0000/lmn.txt",
- "delta_0000012_0000012_0000/",
- "delta_0000012_0000012_0000/0000_0",
- "delta_0000012_0000012_0000/0000_1"},
- "", // writeIdList that accepts all transactions as valid
- new String[]{
- "delta_000005_000005_0000/lmn.txt",
- "delta_0000012_0000012_0000/0000_0",
- "delta_0000012_0000012_0000/0000_1"});
+ "base_01.txt",
+ "post_upgrade.txt",
+ "delta_000005_000005_0000/",
+ "delta_000005_000005_0000/lmn.txt",
+ "delta_0000012_0000012_0000/",
+ "delta_0000012_0000012_0000/0000_0",
+ "delta_0000012_0000012_0000/0000_1"},
+ "", // writeIdList that accepts all transactions as valid
+ new String[]{
+ "base_01.txt", // Post upgrade files are considered valid if there is no base.
+ "post_upgrade.txt",
+ "delta_000005_000005_0000/lmn.txt",
+ "delta_0000012_0000012_0000/0000_0",
+ "delta_0000012_0000012_0000/0000_1"});
}
}
diff --git a/testdata/workloads/functional-query/queries/QueryTest/acid-compaction.test b/testdata/workloads/functional-query/queries/QueryTest/acid-compaction.test
index 62b6700..608c2af 100644
--- a/testdata/workloads/functional-query/queries/QueryTest/acid-compaction.test
+++ b/testdata/workloads/functional-query/queries/QueryTest/acid-compaction.test
@@ -37,3 +37,34 @@ Path,Size,Partition
row_regex:'$NAMENODE/test-warehouse/$DATABASE.db/tt/base_0000003_v\d+/000000_0','\d+B',''
---- TYPES
STRING,STRING,STRING
+====
+---- HIVE_QUERY
+use $DATABASE;
+create table upgraded_table (x int);
+insert into upgraded_table values (1);
+# Upgrade to the table to insert only acid when there are already values in it.
+alter table upgraded_table set tblproperties
+ ('transactional' = 'true', 'transactional_properties' = 'insert_only');
+insert into upgraded_table values (2);
+insert into upgraded_table values (3);
+====
+---- QUERY
+invalidate metadata upgraded_table;
+select * from upgraded_table;
+---- RESULTS
+1
+2
+3
+====
+---- HIVE_QUERY
+use $DATABASE;
+alter table upgraded_table compact 'major' and wait;
+====
+---- QUERY
+refresh upgraded_table;
+select * from upgraded_table;
+---- RESULTS
+1
+2
+3
+====
diff --git a/testdata/workloads/functional-query/queries/QueryTest/acid.test b/testdata/workloads/functional-query/queries/QueryTest/acid.test
index f185d2d..3612e18 100644
--- a/testdata/workloads/functional-query/queries/QueryTest/acid.test
+++ b/testdata/workloads/functional-query/queries/QueryTest/acid.test
@@ -36,3 +36,21 @@ select * from tt order by x;
3
4
====
+---- HIVE_QUERY
+use $DATABASE;
+create table upgraded_table (x int);
+insert into upgraded_table values (1);
+# Upgrade to the table to insert only acid when there are already values in it.
+alter table upgraded_table set tblproperties
+ ('transactional' = 'true', 'transactional_properties' = 'insert_only');
+insert into upgraded_table values (2);
+insert into upgraded_table values (3);
+====
+---- QUERY
+invalidate metadata upgraded_table;
+select * from upgraded_table;
+---- RESULTS
+1
+2
+3
+====
diff --git a/tests/query_test/test_acid.py b/tests/query_test/test_acid.py
index 3b64c54..bd40a41 100644
--- a/tests/query_test/test_acid.py
+++ b/tests/query_test/test_acid.py
@@ -50,5 +50,4 @@ class TestAcid(ImpalaTestSuite):
# TODO(todd): further tests to write:
# TRUNCATE, once HIVE-20137 is implemented.
# INSERT OVERWRITE with empty result set, once HIVE-21750 is fixed.
-# Test for a post-upgrade Hive table which contains files not in ACID layout.
# Negative test for LOAD DATA INPATH and all other SQL that we don't support.