Files
impala/testdata/bin/avoid_hive_replication_bug.sh
Alex Behm 8223e1e44b Avoid Hive replication bug (CDH-17414) by 'warming up' HiveServer2 after it starts.
The purpose of this patch is to avoid CDH-17414 which causes data files loaded
with Hive to incorrectly have a replication factor of 1. When using beeline
this problem only appears to occur immediately after creating the first HBase table
since starting HiveServer2, i.e., subsequent loads seem to function correctly.
This patch add a new script that creates an external HBase table in Hive to
'warm up' HiveServer2 immediately after it is started.
Subsequent loads should assign a correct replication factor.

Change-Id: Ic54c9401b67b748a8848d19f82b8e7df9535e845
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1640
Reviewed-by: Lenni Kuff <lskuff@cloudera.com>
Tested-by: jenkins
2014-02-25 17:33:53 -08:00

44 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
# Copyright 2012 Cloudera Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# The purpose of this script is to avoid CDH-17414 which causes data files loaded
# with Hive to incorrectly have a replication factor of 1. When using beeline
# this problem only appears to occur immediately after creating the first HBase table
# since starting HiveServer2, i.e., subsequent loads seem to function correctly.
# This script creates an external HBase table in Hive to 'warm up' HiveServer2.
# Subsequent loads should assign a correct replication factor.
set -e
set -u
cat > /tmp/create_hive_table.q << EOF
DROP TABLE if exists hive_replication_bug_warmup_table;
create table hive_replication_bug_warmup_table(x int, y string)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:c1")
TBLPROPERTIES ("hbase.table.name" = "hive_replication_bug_warmup_table");
EOF
cat > /tmp/drop_hive_tables.q << EOF
DROP TABLE if exists hive_replication_bug_warmup_table;
EOF
beeline -n $USER -u "jdbc:hive2://localhost:11050/default;" -f /tmp/create_hive_table.q
beeline -n $USER -u "jdbc:hive2://localhost:11050/default;" -f /tmp/drop_hive_tables.q
# Clean up temp files.
rm /tmp/create_hive_table.q
rm /tmp/drop_hive_tables.q