You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by st...@apache.org on 2024/03/21 21:58:15 UTC
(impala) branch master updated (1e67480ba -> 99c5b9327)
This is an automated email from the ASF dual-hosted git repository.
stigahuang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git
from 1e67480ba IMPALA-12917: Skip TestEventProcessingError tests requiring tez execution on hive
new d7b5819f9 IMPALA-12443: Add catalog timeline for all DDL profiles
new 4d3676113 IMPALA-12819: Sync add-opens targets
new 4f5205a3d IMPALA-12926: Refactor BINARY type handling in the backend
new 99c5b9327 IMPALA-12923: Fix header alignment during horizontal scrolling in query timeline
The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
be/src/exec/catalog-op-executor.cc | 10 +-
be/src/exec/catalog-op-executor.h | 7 +
be/src/exec/file-metadata-utils.cc | 4 +-
be/src/exec/hbase/hbase-scan-node.cc | 5 +-
be/src/exec/hbase/hbase-table-writer.cc | 2 +-
be/src/exec/hdfs-scanner-ir.cc | 4 +-
be/src/exec/hdfs-scanner.cc | 13 +-
be/src/exec/hdfs-text-table-writer.cc | 6 +-
be/src/exec/json/hdfs-json-scanner.cc | 6 +-
be/src/exec/parquet/hdfs-parquet-table-writer.cc | 2 +-
be/src/exec/parquet/parquet-metadata-utils.cc | 3 +-
be/src/exec/parquet/parquet-metadata-utils.h | 2 +-
be/src/exec/rcfile/hdfs-rcfile-scanner.cc | 6 +-
be/src/exec/text-converter.cc | 19 +-
be/src/exec/text-converter.h | 18 +-
be/src/exec/text-converter.inline.h | 5 +-
be/src/exec/text/hdfs-text-scanner.cc | 6 +-
be/src/runtime/descriptors.cc | 3 +-
be/src/runtime/descriptors.h | 3 -
be/src/runtime/types.cc | 34 +-
be/src/runtime/types.h | 39 +-
be/src/service/client-request-state.cc | 38 +-
be/src/service/client-request-state.h | 3 +
be/src/service/hs2-util.cc | 3 +-
be/src/service/impala-server.cc | 8 +-
bin/run-all-tests.sh | 6 +
common/thrift/CatalogService.thrift | 6 +
.../java/org/apache/impala/catalog/Catalog.java | 18 +-
.../impala/catalog/CatalogServiceCatalog.java | 171 +++--
.../impala/catalog/CatalogdTableInvalidator.java | 7 +-
.../org/apache/impala/catalog/DataSourceTable.java | 5 +-
.../java/org/apache/impala/catalog/HBaseTable.java | 10 +-
.../java/org/apache/impala/catalog/HdfsTable.java | 196 ++---
.../org/apache/impala/catalog/IcebergTable.java | 19 +-
.../org/apache/impala/catalog/IncompleteTable.java | 5 +-
.../java/org/apache/impala/catalog/KuduTable.java | 19 +-
.../impala/catalog/MaterializedViewHdfsTable.java | 7 +-
.../main/java/org/apache/impala/catalog/Table.java | 9 +-
.../org/apache/impala/catalog/TableLoader.java | 16 +-
.../org/apache/impala/catalog/TableLoadingMgr.java | 10 +-
.../main/java/org/apache/impala/catalog/View.java | 5 +-
.../impala/catalog/events/MetastoreEvents.java | 6 +-
.../catalog/events/MetastoreEventsProcessor.java | 3 +-
.../metastore/CatalogMetastoreServiceHandler.java | 19 +-
.../apache/impala/service/CatalogOpExecutor.java | 853 ++++++++++++---------
.../java/org/apache/impala/service/JniCatalog.java | 4 +-
.../impala/service/KuduCatalogOpExecutor.java | 67 +-
.../java/org/apache/impala/util/EventSequence.java | 9 +
.../main/java/org/apache/impala/util/KuduUtil.java | 11 +
...AccessLevelUtil.java => NoOpEventSequence.java} | 23 +-
.../org/apache/impala/catalog/CatalogTest.java | 15 +-
.../catalog/CatalogdTableInvalidatorTest.java | 4 +-
.../catalog/PartialCatalogInfoWriteIdTest.java | 12 +-
.../catalog/events/EventsProcessorStressTest.java | 5 +-
.../events/MetastoreEventsProcessorTest.java | 24 +-
.../org/apache/impala/common/FrontendFixture.java | 3 +-
.../impala/testutil/CatalogServiceTestCatalog.java | 5 +-
.../apache/impala/testutil/ImpaladTestCatalog.java | 5 +-
.../queries/QueryTest/binary-type.test | 8 +
tests/query_test/test_observability.py | 69 +-
www/query_timeline.tmpl | 56 +-
www/scripts/query_timeline/fragment_diagram.js | 8 +-
.../query_timeline/fragment_metrics_diagram.js | 2 +-
.../query_timeline/host_utilization_diagram.js | 2 +-
64 files changed, 1165 insertions(+), 806 deletions(-)
copy fe/src/main/java/org/apache/impala/util/{TAccessLevelUtil.java => NoOpEventSequence.java} (65%)
(impala) 02/04: IMPALA-12819: Sync add-opens targets
Posted by st...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
stigahuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git
commit 4d3676113f004fdc04f99ba4ba57887c5db3165b
Author: Michael Smith <mi...@cloudera.com>
AuthorDate: Tue Feb 27 14:43:50 2024 -0800
IMPALA-12819: Sync add-opens targets
Syncs add-opens clauses in run-all-tests.sh to match those in init.cc.
Fixes a test_no_inaccessible_objects failure caused during a run of
LocalCatalogTest that used 'jdk.internal.platform'.
Change-Id: I24e5f1699d507e76fd8037f96ed3e3a48b888dcb
Reviewed-on: http://gerrit.cloudera.org:8080/21080
Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
bin/run-all-tests.sh | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/bin/run-all-tests.sh b/bin/run-all-tests.sh
index 1a06ca9b2..a97b6fbe2 100755
--- a/bin/run-all-tests.sh
+++ b/bin/run-all-tests.sh
@@ -272,6 +272,7 @@ do
# If running with Java 9+, add-opens to JAVA_TOOL_OPTIONS for
# CatalogdMetaProviderTest.testWeights with ehcache.sizeof.
JAVA_OPTIONS=" --add-opens=java.base/java.io=ALL-UNNAMED"
+ JAVA_OPTIONS+=" --add-opens=java.base/java.lang.invoke=ALL-UNNAMED"
JAVA_OPTIONS+=" --add-opens=java.base/java.lang.module=ALL-UNNAMED"
JAVA_OPTIONS+=" --add-opens=java.base/java.lang.ref=ALL-UNNAMED"
JAVA_OPTIONS+=" --add-opens=java.base/java.lang.reflect=ALL-UNNAMED"
@@ -281,17 +282,22 @@ do
JAVA_OPTIONS+=" --add-opens=java.base/java.nio.file.attribute=ALL-UNNAMED"
JAVA_OPTIONS+=" --add-opens=java.base/java.nio=ALL-UNNAMED"
JAVA_OPTIONS+=" --add-opens=java.base/java.security=ALL-UNNAMED"
+ JAVA_OPTIONS+=" --add-opens=java.base/java.util.concurrent.locks=ALL-UNNAMED"
JAVA_OPTIONS+=" --add-opens=java.base/java.util.concurrent=ALL-UNNAMED"
JAVA_OPTIONS+=" --add-opens=java.base/java.util.jar=ALL-UNNAMED"
+ JAVA_OPTIONS+=" --add-opens=java.base/java.util.regex=ALL-UNNAMED"
JAVA_OPTIONS+=" --add-opens=java.base/java.util.zip=ALL-UNNAMED"
JAVA_OPTIONS+=" --add-opens=java.base/java.util=ALL-UNNAMED"
JAVA_OPTIONS+=" --add-opens=java.base/jdk.internal.loader=ALL-UNNAMED"
JAVA_OPTIONS+=" --add-opens=java.base/jdk.internal.math=ALL-UNNAMED"
JAVA_OPTIONS+=" --add-opens=java.base/jdk.internal.module=ALL-UNNAMED"
JAVA_OPTIONS+=" --add-opens=java.base/jdk.internal.perf=ALL-UNNAMED"
+ JAVA_OPTIONS+=" --add-opens=java.base/jdk.internal.platform=ALL-UNNAMED"
JAVA_OPTIONS+=" --add-opens=java.base/jdk.internal.ref=ALL-UNNAMED"
JAVA_OPTIONS+=" --add-opens=java.base/jdk.internal.reflect=ALL-UNNAMED"
JAVA_OPTIONS+=" --add-opens=java.base/jdk.internal.util.jar=ALL-UNNAMED"
+ JAVA_OPTIONS+=" --add-opens=java.base/sun.net.www.protocol.jar=ALL-UNNAMED"
+ JAVA_OPTIONS+=" --add-opens=java.base/sun.nio.ch=ALL-UNNAMED"
JAVA_OPTIONS+=" --add-opens=java.base/sun.nio.fs=ALL-UNNAMED"
JAVA_OPTIONS+=" --add-opens=jdk.dynalink/jdk.dynalink.beans=ALL-UNNAMED"
JAVA_OPTIONS+=" --add-opens=jdk.dynalink/jdk.dynalink.linker.support=ALL-UNNAMED"
(impala) 03/04: IMPALA-12926: Refactor BINARY type handling in the backend
Posted by st...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
stigahuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git
commit 4f5205a3d87821220a8dea9164a122788322884a
Author: Daniel Becker <da...@cloudera.com>
AuthorDate: Fri Mar 15 17:52:26 2024 +0100
IMPALA-12926: Refactor BINARY type handling in the backend
Currently the STRING and BINARY types are not distinguished in most of
the backend. In contrast to the frontend, PrimitiveType::TYPE_BINARY is
not used there at all, TYPE_STRING being used instead. This is to ensure
that everything that works for STRING also works for BINARY. So far only
file readers and writers have had to handle them differently, and they
have access to ColumnDescriptors which contain AuxColumnType fields that
differentiate these two types.
However, only top-level columns have ColumnDescriptors. Adding support
for BINARYs within complex types (see IMPALA-11491 and IMPALA-12651)
necessitates adding type information about STRING vs BINARY to embedded
fields as well.
Using PrimitiveType::TYPE_BINARY would probably be the cleanest solution
but it would affect huge parts of the code as TYPE_BINARY would have to
be added to hundreds of switch statements and this would be error prone.
Instead, this change introduces a new field in ColumnType: 'is_binary',
which is true if the type is a BINARY and false otherwise. We keep using
TYPE_STRING as the PrimitiveType of the ColumnType for BINARYs. This way
full type information is present in ColumnType but code that does not
differentiate between STRING and BINARY will continue to work for
BINARY.
With this change, AuxColumnType is no longer needed and is removed.
See also IMPALA-5323 - https://gerrit.cloudera.org/#/c/18868/. This
change is a very similar implementation of the same refactoring, except
for the Kudu related parts.
Testing:
- added an extra test in binary-type.test
Change-Id: Icedbad4e24a46e7731de11cc14218761d11fb86f
Reviewed-on: http://gerrit.cloudera.org:8080/21157
Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
be/src/exec/file-metadata-utils.cc | 4 +--
be/src/exec/hbase/hbase-scan-node.cc | 5 ++-
be/src/exec/hbase/hbase-table-writer.cc | 2 +-
be/src/exec/hdfs-scanner-ir.cc | 4 +--
be/src/exec/hdfs-scanner.cc | 13 +++-----
be/src/exec/hdfs-text-table-writer.cc | 6 ++--
be/src/exec/json/hdfs-json-scanner.cc | 6 ++--
be/src/exec/parquet/hdfs-parquet-table-writer.cc | 2 +-
be/src/exec/parquet/parquet-metadata-utils.cc | 3 +-
be/src/exec/parquet/parquet-metadata-utils.h | 2 +-
be/src/exec/rcfile/hdfs-rcfile-scanner.cc | 6 ++--
be/src/exec/text-converter.cc | 19 ++++-------
be/src/exec/text-converter.h | 18 ++++------
be/src/exec/text-converter.inline.h | 5 ++-
be/src/exec/text/hdfs-text-scanner.cc | 6 ++--
be/src/runtime/descriptors.cc | 3 +-
be/src/runtime/descriptors.h | 3 --
be/src/runtime/types.cc | 34 ++++++++++---------
be/src/runtime/types.h | 39 +++++++++-------------
be/src/service/hs2-util.cc | 3 +-
.../queries/QueryTest/binary-type.test | 8 +++++
21 files changed, 80 insertions(+), 111 deletions(-)
diff --git a/be/src/exec/file-metadata-utils.cc b/be/src/exec/file-metadata-utils.cc
index a03024992..b63379abe 100644
--- a/be/src/exec/file-metadata-utils.cc
+++ b/be/src/exec/file-metadata-utils.cc
@@ -118,9 +118,7 @@ void FileMetadataUtils::AddIcebergColumns(MemPool* mem_pool, Tuple** template_tu
continue;
}
if (field_id != transform->source_id()) continue;
- const AuxColumnType& aux_type =
- scan_node_->hdfs_table()->GetColumnDesc(slot_desc).auxType();
- if (!text_converter.WriteSlot(slot_desc, &aux_type, *template_tuple,
+ if (!text_converter.WriteSlot(slot_desc, *template_tuple,
(const char*)transform->transform_value()->data(),
transform->transform_value()->size(),
true, false,
diff --git a/be/src/exec/hbase/hbase-scan-node.cc b/be/src/exec/hbase/hbase-scan-node.cc
index 55d0ab584..41a96edfa 100644
--- a/be/src/exec/hbase/hbase-scan-node.cc
+++ b/be/src/exec/hbase/hbase-scan-node.cc
@@ -147,9 +147,8 @@ void HBaseScanNode::WriteTextSlot(
const string& family, const string& qualifier,
void* value, int value_length, SlotDescriptor* slot_desc,
RuntimeState* state, MemPool* pool, Tuple* tuple, bool* error_in_row) {
- const AuxColumnType& aux_type = hbase_table_->GetColumnDesc(slot_desc).auxType();
- if (!text_converter_->WriteSlot(slot_desc, &aux_type, tuple,
- reinterpret_cast<char*>(value), value_length, true, false, pool)) {
+ if (!text_converter_->WriteSlot(slot_desc, tuple, reinterpret_cast<char*>(value),
+ value_length, true, false, pool)) {
*error_in_row = true;
if (state->LogHasSpace()) {
stringstream ss;
diff --git a/be/src/exec/hbase/hbase-table-writer.cc b/be/src/exec/hbase/hbase-table-writer.cc
index 0f1641c94..6c3d1163a 100644
--- a/be/src/exec/hbase/hbase-table-writer.cc
+++ b/be/src/exec/hbase/hbase-table-writer.cc
@@ -155,7 +155,7 @@ Status HBaseTableWriter::AppendRows(RowBatch* batch) {
string_value.clear();
output_expr_evals_[j]->PrintValue(value, &string_value);
const ColumnDescriptor& col_desc = table_desc_->col_descs()[j];
- if (col_desc.auxType().IsBinaryStringSubtype()) {
+ if (col_desc.type().IsBinaryType()) {
Base64Encode(string_value , &base64_encoded_value);
data = base64_encoded_value.data();
data_len = base64_encoded_value.length();
diff --git a/be/src/exec/hdfs-scanner-ir.cc b/be/src/exec/hdfs-scanner-ir.cc
index 0fe3e05c2..a05d07dc4 100644
--- a/be/src/exec/hdfs-scanner-ir.cc
+++ b/be/src/exec/hdfs-scanner-ir.cc
@@ -125,9 +125,7 @@ bool HdfsScanner::TextConverterWriteSlotInterpretedIR(HdfsScanner* hdfs_scanner,
}
SlotDescriptor* slot_desc = hdfs_scanner->scan_node_->materialized_slots()[slot_idx];
- const AuxColumnType& auxType =
- hdfs_scanner->scan_node_->hdfs_table_->GetColumnDesc(slot_desc).auxType();
- return hdfs_scanner->text_converter_->WriteSlot(slot_desc, &auxType, tuple, data, len,
+ return hdfs_scanner->text_converter_->WriteSlot(slot_desc, tuple, data, len,
copy_string, need_escape, pool);
}
diff --git a/be/src/exec/hdfs-scanner.cc b/be/src/exec/hdfs-scanner.cc
index ff83ab616..76314c9b5 100644
--- a/be/src/exec/hdfs-scanner.cc
+++ b/be/src/exec/hdfs-scanner.cc
@@ -289,10 +289,8 @@ bool HdfsScanner::WriteCompleteTuple(MemPool* pool, FieldLocation* fields,
}
const SlotDescriptor* slot_desc = scan_node_->materialized_slots()[i];
- const AuxColumnType& aux_type =
- scan_node_->hdfs_table()->GetColumnDesc(slot_desc).auxType();
- bool error = !text_converter_->WriteSlot(slot_desc, &aux_type, tuple,
- fields[i].start, len, false, need_escape, pool);
+ bool error = !text_converter_->WriteSlot(slot_desc, tuple, fields[i].start, len,
+ false, need_escape, pool);
error_fields[i] = error;
*error_in_row |= error;
}
@@ -374,12 +372,9 @@ Status HdfsScanner::CodegenWriteCompleteTuple(const HdfsScanPlanNode* node,
// If the type is CHAR, WriteSlot for this slot cannot be codegen'd. To keep codegen
// for other things, we call the interpreted code for this slot from the codegen'd
// code instead of failing codegen. See IMPALA-9747.
- const AuxColumnType& aux_type =
- node->hdfs_table_->GetColumnDesc(slot_desc).auxType();
- if (TextConverter::SupportsCodegenWriteSlot(
- slot_desc->type(), aux_type)) {
+ if (TextConverter::SupportsCodegenWriteSlot(slot_desc->type())) {
RETURN_IF_ERROR(TextConverter::CodegenWriteSlot(codegen, tuple_desc, slot_desc,
- &aux_type, &fn, node->hdfs_table_->null_column_value().data(),
+ &fn, node->hdfs_table_->null_column_value().data(),
node->hdfs_table_->null_column_value().size(), true,
state->query_options().strict_mode));
if (i >= LlvmCodeGen::CODEGEN_INLINE_EXPRS_THRESHOLD) codegen->SetNoInline(fn);
diff --git a/be/src/exec/hdfs-text-table-writer.cc b/be/src/exec/hdfs-text-table-writer.cc
index ddcbbf108..9ac4a7781 100644
--- a/be/src/exec/hdfs-text-table-writer.cc
+++ b/be/src/exec/hdfs-text-table-writer.cc
@@ -100,11 +100,9 @@ Status HdfsTextTableWriter::AppendRows(
StringValue sv(val_ptr, StringValue::UnpaddedCharLength(val_ptr, type.len));
PrintEscaped(&sv);
} else if (type.IsVarLenStringType()) {
- const ColumnDescriptor& col_desc =
- table_desc_->col_descs()[num_partition_cols + j];
const StringValue* string_value = reinterpret_cast<const StringValue*>(value);
- if (col_desc.auxType().IsBinaryStringSubtype()) {
- // TODO: try to find a more efficient imlementation
+ if (type.IsBinaryType()) {
+ // TODO: try to find a more efficient implementation
Base64Encode(
string_value->Ptr() , string_value->Len(), &rowbatch_stringstream_);
} else {
diff --git a/be/src/exec/json/hdfs-json-scanner.cc b/be/src/exec/json/hdfs-json-scanner.cc
index b0a5c5b16..90023130e 100644
--- a/be/src/exec/json/hdfs-json-scanner.cc
+++ b/be/src/exec/json/hdfs-json-scanner.cc
@@ -344,10 +344,8 @@ void HdfsJsonScanner::SubmitRow() {
bool HdfsJsonScanner::InvokeWriteSlot(const SlotDescriptor* slot_desc, const char* data,
int len) {
// TODO: Support Invoke CodeGend WriteSlot
- const AuxColumnType& aux_type =
- scan_node_->hdfs_table()->GetColumnDesc(slot_desc).auxType();
- if (LIKELY(text_converter_->WriteSlot(slot_desc, &aux_type, tuple_, data, len, true,
- false, current_pool_))) {
+ if (LIKELY(text_converter_->WriteSlot(slot_desc, tuple_, data, len, true, false,
+ current_pool_))) {
return true;
}
return HandleConvertError(slot_desc, data, len);
diff --git a/be/src/exec/parquet/hdfs-parquet-table-writer.cc b/be/src/exec/parquet/hdfs-parquet-table-writer.cc
index 412002e07..60d43a77e 100644
--- a/be/src/exec/parquet/hdfs-parquet-table-writer.cc
+++ b/be/src/exec/parquet/hdfs-parquet-table-writer.cc
@@ -1504,7 +1504,7 @@ Status HdfsParquetTableWriter::CreateSchema() {
const int field_id = col_desc.field_id();
if (field_id != -1) col_schema.__set_field_id(field_id);
ParquetMetadataUtils::FillSchemaElement(col_type, string_utf8_, timestamp_type_,
- col_desc.auxType(), &col_schema);
+ &col_schema);
}
return Status::OK();
diff --git a/be/src/exec/parquet/parquet-metadata-utils.cc b/be/src/exec/parquet/parquet-metadata-utils.cc
index 99c2d2319..2d4ade20d 100644
--- a/be/src/exec/parquet/parquet-metadata-utils.cc
+++ b/be/src/exec/parquet/parquet-metadata-utils.cc
@@ -415,7 +415,6 @@ parquet::Type::type ParquetMetadataUtils::ConvertInternalToParquetType(
void ParquetMetadataUtils::FillSchemaElement(const ColumnType& col_type,
bool string_utf8, TParquetTimestampType::type timestamp_type,
- const AuxColumnType& aux_type,
parquet::SchemaElement* col_schema) {
col_schema->__set_type(ConvertInternalToParquetType(col_type.type, timestamp_type));
col_schema->__set_repetition_type(parquet::FieldRepetitionType::OPTIONAL);
@@ -431,7 +430,7 @@ void ParquetMetadataUtils::FillSchemaElement(const ColumnType& col_type,
case TYPE_STRING:
// By default STRING has no logical type, see IMPALA-5982.
// VARCHAR and CHAR are always set to UTF8.
- if (string_utf8 && !aux_type.IsBinaryStringSubtype()) {
+ if (string_utf8 && !col_type.IsBinaryType()) {
SetUtf8ConvertedAndLogicalType(col_schema);
}
break;
diff --git a/be/src/exec/parquet/parquet-metadata-utils.h b/be/src/exec/parquet/parquet-metadata-utils.h
index 2981f7cef..74ab9e730 100644
--- a/be/src/exec/parquet/parquet-metadata-utils.h
+++ b/be/src/exec/parquet/parquet-metadata-utils.h
@@ -66,7 +66,7 @@ class ParquetMetadataUtils {
/// and this function's arguments.
static void FillSchemaElement(const ColumnType& col_type,
bool string_utf8, TParquetTimestampType::type timestamp_type,
- const AuxColumnType& aux_type, parquet::SchemaElement* col_schema);
+ parquet::SchemaElement* col_schema);
};
struct ParquetFileVersion {
diff --git a/be/src/exec/rcfile/hdfs-rcfile-scanner.cc b/be/src/exec/rcfile/hdfs-rcfile-scanner.cc
index 8264faf2b..e169e744a 100644
--- a/be/src/exec/rcfile/hdfs-rcfile-scanner.cc
+++ b/be/src/exec/rcfile/hdfs-rcfile-scanner.cc
@@ -590,10 +590,8 @@ Status HdfsRCFileScanner::ProcessRange(RowBatch* row_batch) {
return Status(ss.str());
}
- const AuxColumnType& aux_type =
- scan_node_->hdfs_table()->GetColumnDesc(slot_desc).auxType();
- if (!text_converter_->WriteSlot(slot_desc, &aux_type, tuple, col_start,
- field_len, false, false, row_batch->tuple_data_pool())) {
+ if (!text_converter_->WriteSlot(slot_desc, tuple, col_start, field_len, false,
+ false, row_batch->tuple_data_pool())) {
ReportColumnParseError(slot_desc, col_start, field_len);
error_in_row = true;
}
diff --git a/be/src/exec/text-converter.cc b/be/src/exec/text-converter.cc
index a709f0d80..ca4fb0fc8 100644
--- a/be/src/exec/text-converter.cc
+++ b/be/src/exec/text-converter.cc
@@ -106,12 +106,11 @@ void TextConverter::UnescapeString(const char* src, char* dest, int* len,
//}
// TODO: convert this function to use cross-compilation + constant substitution in whole
// or part. It is currently too complex and doesn't implement the full functionality.
-Status TextConverter::CodegenWriteSlot(LlvmCodeGen* codegen,
- TupleDescriptor* tuple_desc, SlotDescriptor* slot_desc,
- const AuxColumnType* aux_type, llvm::Function** fn, const char* null_col_val,
- int len, bool check_null, bool strict_mode) {
+Status TextConverter::CodegenWriteSlot(LlvmCodeGen* codegen, TupleDescriptor* tuple_desc,
+ SlotDescriptor* slot_desc, llvm::Function** fn, const char* null_col_val, int len,
+ bool check_null, bool strict_mode) {
DCHECK(fn != nullptr);
- DCHECK(SupportsCodegenWriteSlot(slot_desc->type(), *aux_type));
+ DCHECK(SupportsCodegenWriteSlot(slot_desc->type()));
// Codegen is_null_string
bool is_default_null = (len == 2 && null_col_val[0] == '\\' && null_col_val[1] == 'N');
@@ -351,11 +350,7 @@ Status TextConverter::CodegenWriteSlot(LlvmCodeGen* codegen,
return Status::OK();
}
-bool TextConverter::SupportsCodegenWriteSlot(const ColumnType& col_type,
- const AuxColumnType& auxType) {
- if (col_type.type == TYPE_STRING) {
- // TODO: implement codegen for binary (IMPALA-11475)
- return auxType.string_subtype != AuxColumnType::StringSubtype::BINARY;
- }
- return col_type.type != TYPE_CHAR;
+bool TextConverter::SupportsCodegenWriteSlot(const ColumnType& col_type) {
+ // TODO: implement codegen for binary (IMPALA-11475)
+ return col_type.type != TYPE_CHAR && !col_type.IsBinaryType();
}
diff --git a/be/src/exec/text-converter.h b/be/src/exec/text-converter.h
index 132e97741..f8b43f89b 100644
--- a/be/src/exec/text-converter.h
+++ b/be/src/exec/text-converter.h
@@ -53,7 +53,6 @@ class TextConverter {
/// Converts slot data, of length 'len', into type of slot_desc,
/// and writes the result into the tuples's slot.
- /// auxType is used to differentiate between BINARY and STRING types.
/// copy_string indicates whether we need to make a separate copy of the string data:
/// For regular unescaped strings, we point to the original data in the file_buf_.
/// For regular escaped strings, we copy its unescaped string into a separate buffer
@@ -62,9 +61,8 @@ class TextConverter {
/// 'pool' is unused.
/// Unsuccessful conversions are turned into NULLs.
/// Returns true if the value was written successfully.
- bool WriteSlot(const SlotDescriptor* slot_desc, const AuxColumnType* auxType,
- Tuple* tuple, const char* data, int len, bool copy_string, bool need_escape,
- MemPool* pool);
+ bool WriteSlot(const SlotDescriptor* slot_desc, Tuple* tuple, const char* data, int len,
+ bool copy_string, bool need_escape, MemPool* pool);
/// Removes escape characters from len characters of the null-terminated string src,
/// and copies the unescaped string into dest, changing *len to the unescaped length.
@@ -81,21 +79,19 @@ class TextConverter {
/// bool WriteSlot(Tuple* tuple, const char* data, int len);
/// The codegen function returns true if the slot could be written and false
/// otherwise.
- /// auxType is used to differentiate between BINARY and STRING types.
/// If check_null is set, then the codegen'd function sets the target slot to NULL
/// if its input string matches null_vol_val.
/// The codegenerated function does not support escape characters and should not
/// be used for partitions that contain escapes.
/// strict_mode: If set, numerical overflow/underflow are considered to be parse
/// errors.
- static Status CodegenWriteSlot(LlvmCodeGen* codegen,
- TupleDescriptor* tuple_desc, SlotDescriptor* slot_desc,
- const AuxColumnType* auxType, llvm::Function** fn, const char* null_col_val,
- int len, bool check_null, bool strict_mode = false);
+ static Status CodegenWriteSlot(LlvmCodeGen* codegen, TupleDescriptor* tuple_desc,
+ SlotDescriptor* slot_desc, llvm::Function** fn, const char* null_col_val, int len,
+ bool check_null, bool strict_mode = false);
/// Returns whether codegen is supported for the given type.
- static bool SupportsCodegenWriteSlot(const ColumnType& col_type,
- const AuxColumnType& auxType);
+ static bool SupportsCodegenWriteSlot(const ColumnType& col_type);
+
private:
char escape_char_;
/// Special string to indicate NULL column values.
diff --git a/be/src/exec/text-converter.inline.h b/be/src/exec/text-converter.inline.h
index 992029b25..6f4c74ff9 100644
--- a/be/src/exec/text-converter.inline.h
+++ b/be/src/exec/text-converter.inline.h
@@ -39,8 +39,7 @@ namespace impala {
/// Note: this function has a codegen'd version. Changing this function requires
/// corresponding changes to CodegenWriteSlot().
-inline bool TextConverter::WriteSlot(const SlotDescriptor* slot_desc,
- const AuxColumnType* auxType, Tuple* tuple,
+inline bool TextConverter::WriteSlot(const SlotDescriptor* slot_desc, Tuple* tuple,
const char* data, int len, bool copy_string, bool need_escape, MemPool* pool) {
if ((len == 0 && !slot_desc->type().IsStringType()) || data == NULL) {
tuple->SetNull(slot_desc->null_indicator_offset());
@@ -68,7 +67,7 @@ inline bool TextConverter::WriteSlot(const SlotDescriptor* slot_desc,
!(len != 0 && (copy_string || need_escape));
bool base64_decode = false;
- if (auxType->IsBinaryStringSubtype()) {
+ if (type.IsBinaryType()) {
base64_decode = true;
reuse_data = false;
int64_t out_len;
diff --git a/be/src/exec/text/hdfs-text-scanner.cc b/be/src/exec/text/hdfs-text-scanner.cc
index 3429d3a88..db2fcf5f8 100644
--- a/be/src/exec/text/hdfs-text-scanner.cc
+++ b/be/src/exec/text/hdfs-text-scanner.cc
@@ -799,10 +799,8 @@ void HdfsTextScanner::WritePartialTuple(FieldLocation* fields, int num_fields) {
}
const SlotDescriptor* slot_desc = scan_node_->materialized_slots()[slot_idx_];
- const AuxColumnType& aux_type =
- scan_node_->hdfs_table()->GetColumnDesc(slot_desc).auxType();
- if (!text_converter_->WriteSlot(slot_desc, &aux_type, partial_tuple_,
- fields[i].start, len, true, need_escape, boundary_pool_.get())) {
+ if (!text_converter_->WriteSlot(slot_desc, partial_tuple_, fields[i].start, len,
+ true, need_escape, boundary_pool_.get())) {
ReportColumnParseError(slot_desc, fields[i].start, len);
error_in_row_ = true;
}
diff --git a/be/src/runtime/descriptors.cc b/be/src/runtime/descriptors.cc
index b880f6cac..aa716cca8 100644
--- a/be/src/runtime/descriptors.cc
+++ b/be/src/runtime/descriptors.cc
@@ -166,8 +166,7 @@ inline bool SlotDescriptor::IsChildOfStruct() const {
ColumnDescriptor::ColumnDescriptor(const TColumnDescriptor& tdesc)
: name_(tdesc.name),
- type_(ColumnType::FromThrift(tdesc.type)),
- aux_type_(tdesc.type) {
+ type_(ColumnType::FromThrift(tdesc.type)) {
if (tdesc.__isset.icebergFieldId) {
field_id_ = tdesc.icebergFieldId;
// Get key and value field_id for Iceberg table column with Map type.
diff --git a/be/src/runtime/descriptors.h b/be/src/runtime/descriptors.h
index b8df42346..a73420205 100644
--- a/be/src/runtime/descriptors.h
+++ b/be/src/runtime/descriptors.h
@@ -334,7 +334,6 @@ class ColumnDescriptor {
int field_map_key_id() const { return field_map_key_id_; }
int field_map_value_id() const { return field_map_value_id_; }
- const AuxColumnType& auxType() const { return aux_type_; }
std::string DebugString() const;
private:
@@ -344,8 +343,6 @@ class ColumnDescriptor {
int field_id_ = -1;
int field_map_key_id_ = -1;
int field_map_value_id_ = -1;
-
- AuxColumnType aux_type_;
};
/// Base class for table descriptors.
diff --git a/be/src/runtime/types.cc b/be/src/runtime/types.cc
index dd1beeeb1..dfe209fbf 100644
--- a/be/src/runtime/types.cc
+++ b/be/src/runtime/types.cc
@@ -37,14 +37,8 @@ const int ColumnType::MAX_DECIMAL8_PRECISION;
const char* ColumnType::LLVM_CLASS_NAME = "struct.impala::ColumnType";
-AuxColumnType::AuxColumnType(const TColumnType& col_type) {
- if (col_type.types.size() != 1 || !col_type.types[0].__isset.scalar_type) return;
- TPrimitiveType::type primitive_type = col_type.types[0].scalar_type.type;
- if (primitive_type == TPrimitiveType::BINARY) string_subtype = StringSubtype::BINARY;
-}
-
ColumnType::ColumnType(const std::vector<TTypeNode>& types, int* idx)
- : len(-1), precision(-1), scale(-1) {
+ : len(-1), precision(-1), scale(-1), is_binary_(false) {
DCHECK_GE(*idx, 0);
DCHECK_LT(*idx, types.size());
const TTypeNode& node = types[*idx];
@@ -57,6 +51,8 @@ ColumnType::ColumnType(const std::vector<TTypeNode>& types, int* idx)
|| type == TYPE_FIXED_UDA_INTERMEDIATE) {
DCHECK(scalar_type.__isset.len);
len = scalar_type.len;
+ } else if (type == TYPE_STRING) {
+ is_binary_ = scalar_type.type == TPrimitiveType::BINARY;
} else if (type == TYPE_DECIMAL) {
DCHECK(scalar_type.__isset.precision);
DCHECK(scalar_type.__isset.scale);
@@ -120,7 +116,7 @@ PrimitiveType ThriftToType(TPrimitiveType::type ttype) {
}
}
-TPrimitiveType::type ToThrift(PrimitiveType ptype) {
+TPrimitiveType::type ToThrift(PrimitiveType ptype, bool is_binary) {
switch (ptype) {
case INVALID_TYPE: return TPrimitiveType::INVALID_TYPE;
case TYPE_NULL: return TPrimitiveType::NULL_TYPE;
@@ -134,7 +130,8 @@ TPrimitiveType::type ToThrift(PrimitiveType ptype) {
case TYPE_DATE: return TPrimitiveType::DATE;
case TYPE_DATETIME: return TPrimitiveType::DATETIME;
case TYPE_TIMESTAMP: return TPrimitiveType::TIMESTAMP;
- case TYPE_STRING: return TPrimitiveType::STRING;
+ case TYPE_STRING:
+ return is_binary ? TPrimitiveType::BINARY : TPrimitiveType::STRING;
case TYPE_VARCHAR: return TPrimitiveType::VARCHAR;
case TYPE_BINARY:
DCHECK(false) << "STRING should be used instead of BINARY in the backend.";
@@ -184,7 +181,6 @@ string TypeToOdbcString(const TColumnType& type) {
DCHECK(type.types[0].__isset.scalar_type);
TPrimitiveType::type col_type = type.types[0].scalar_type.type;
PrimitiveType primitive_type = ThriftToType(col_type);
- AuxColumnType aux_type(type);
// ODBC driver requires types in lower case
switch (primitive_type) {
case INVALID_TYPE: return "invalid";
@@ -200,7 +196,7 @@ string TypeToOdbcString(const TColumnType& type) {
case TYPE_DATETIME: return "datetime";
case TYPE_TIMESTAMP: return "timestamp";
case TYPE_STRING:
- if(aux_type.IsBinaryStringSubtype()) {
+ if(col_type == TPrimitiveType::BINARY) {
return "binary";
} else {
return "string";
@@ -247,7 +243,7 @@ void ColumnType::ToThrift(TColumnType* thrift_type) const {
node.type = TTypeNodeType::SCALAR;
node.__set_scalar_type(TScalarType());
TScalarType& scalar_type = node.scalar_type;
- scalar_type.__set_type(impala::ToThrift(type));
+ scalar_type.__set_type(impala::ToThrift(type, is_binary_));
if (type == TYPE_CHAR || type == TYPE_VARCHAR
|| type == TYPE_FIXED_UDA_INTERMEDIATE) {
DCHECK_NE(len, -1);
@@ -294,11 +290,12 @@ ostream& operator<<(ostream& os, const ColumnType& type) {
}
llvm::ConstantStruct* ColumnType::ToIR(LlvmCodeGen* codegen) const {
- // ColumnType = { i32, i32, i32, i32, <vector>, <vector> }
+ // ColumnType = { i32, i8, i32, i32, i32, <vector>, <vector>, <vector> }
llvm::StructType* column_type_type = codegen->GetStructType<ColumnType>();
DCHECK_EQ(sizeof(type), sizeof(int32_t));
llvm::Constant* type_field = codegen->GetI32Constant(type);
+
DCHECK_EQ(sizeof(len), sizeof(int32_t));
llvm::Constant* len_field = codegen->GetI32Constant(len);
DCHECK_EQ(sizeof(precision), sizeof(int32_t));
@@ -306,7 +303,7 @@ llvm::ConstantStruct* ColumnType::ToIR(LlvmCodeGen* codegen) const {
DCHECK_EQ(sizeof(scale), sizeof(int32_t));
llvm::Constant* scale_field = codegen->GetI32Constant(scale);
- // Create empty 'children' and 'field_names' vectors
+ // Create empty 'children', 'field_names' and 'field_ids' vectors
DCHECK(children.empty()) << "Nested types NYI";
DCHECK(field_names.empty()) << "Nested types NYI";
DCHECK(field_ids.empty()) << "Nested types NYI";
@@ -317,9 +314,16 @@ llvm::ConstantStruct* ColumnType::ToIR(LlvmCodeGen* codegen) const {
llvm::Constant* field_ids_field =
llvm::Constant::getNullValue(column_type_type->getElementType(6));
+ DCHECK_EQ(sizeof(is_binary_), sizeof(uint8_t));
+ llvm::Constant* is_binary_field = codegen->GetI8Constant(is_binary_);
+
+ llvm::Constant* padding =
+ llvm::Constant::getNullValue(column_type_type->getElementType(8));
+
return llvm::cast<llvm::ConstantStruct>(
llvm::ConstantStruct::get(column_type_type, type_field, len_field, precision_field,
- scale_field, children_field, field_names_field, field_ids_field));
+ scale_field, children_field, field_names_field, field_ids_field,
+ is_binary_field, padding));
}
}
diff --git a/be/src/runtime/types.h b/be/src/runtime/types.h
index d899e20f2..94d8e0258 100644
--- a/be/src/runtime/types.h
+++ b/be/src/runtime/types.h
@@ -47,7 +47,7 @@ enum PrimitiveType {
TYPE_STRING,
TYPE_DATE,
TYPE_DATETIME, // Not implemented
- TYPE_BINARY, // Not used, see AuxColumnType::StringSubtype
+ TYPE_BINARY, // Not used, see ColumnType::is_binary
TYPE_DECIMAL,
TYPE_CHAR,
TYPE_VARCHAR,
@@ -62,28 +62,6 @@ PrimitiveType ThriftToType(TPrimitiveType::type ttype);
TPrimitiveType::type ToThrift(PrimitiveType ptype);
std::string TypeToString(PrimitiveType t);
-// Contains information about a type that generally doesn't affect how it should be
-// handled by backend, but can affect encoding / decoding.
-struct AuxColumnType {
- // Differentiates between STRING and BINARY.
- // As STRING is just a byte array in Impala (no UTF-8 encoding), the two types are
- // practically the same in the backend - only some file format readers/writers
- // differentiate between the two. Instead of using PrimitiveType::TYPE_BINARY BINARY
- // uses TYPE_STRING to ensure that everything that works for STRING also works for
- // BINARY.
- enum class StringSubtype {
- STRING,
- BINARY
- };
- StringSubtype string_subtype = StringSubtype::STRING;
-
- AuxColumnType(const TColumnType& thrift_type);
-
- inline bool IsBinaryStringSubtype() const {
- return string_subtype == StringSubtype::BINARY;
- }
-};
-
std::string TypeToOdbcString(const TColumnType& type);
// Describes a type. Includes the enum, children types, and any type-specific metadata
@@ -91,6 +69,7 @@ std::string TypeToOdbcString(const TColumnType& type);
// TODO for 2.3: rename to TypeDescriptor
struct ColumnType {
PrimitiveType type;
+
/// Only set if type one of TYPE_CHAR, TYPE_VARCHAR, TYPE_FIXED_UDA_INTERMEDIATE.
int len;
static const int MAX_VARCHAR_LENGTH = (1 << 16) - 1; // 65535
@@ -120,7 +99,7 @@ struct ColumnType {
static const char* LLVM_CLASS_NAME;
explicit ColumnType(PrimitiveType type = INVALID_TYPE)
- : type(type), len(-1), precision(-1), scale(-1) {
+ : type(type), len(-1), precision(-1), scale(-1), is_binary_(false) {
DCHECK_NE(type, TYPE_CHAR);
DCHECK_NE(type, TYPE_VARCHAR);
DCHECK_NE(type, TYPE_BINARY);
@@ -234,6 +213,8 @@ struct ColumnType {
return type == TYPE_STRING || type == TYPE_VARCHAR;
}
+ inline bool IsBinaryType() const { return is_binary_; }
+
inline bool IsComplexType() const {
return type == TYPE_STRUCT || type == TYPE_ARRAY || type == TYPE_MAP;
}
@@ -276,6 +257,16 @@ struct ColumnType {
ColumnType(const std::vector<TTypeNode>& types, int* idx);
private:
+ // Differentiates between STRING and BINARY. As STRING is just a byte array in Impala
+ // (no UTF-8 encoding), the two types are practically the same in the backend - only
+ // some code parts, e.g. file format readers/writers differentiate between the two.
+ // Instead of PrimitiveType::TYPE_BINARY, TYPE_STRING is used for the BINARY type to
+ // ensure that everything that works for STRING also works for BINARY.
+ //
+ // This variable is true if 'type' is TYPE_STRING and this object represents the BINARY
+ // type, and false in all other cases.
+ bool is_binary_ = false;
+
/// Recursive implementation of ToThrift() that populates 'thrift_type' with the
/// TTypeNodes for this type and its children.
void ToThrift(TColumnType* thrift_type) const;
diff --git a/be/src/service/hs2-util.cc b/be/src/service/hs2-util.cc
index ea0b51f1e..ce6654db3 100644
--- a/be/src/service/hs2-util.cc
+++ b/be/src/service/hs2-util.cc
@@ -866,7 +866,6 @@ bool impala::isOneFieldSet(const impala::TColumnValue& value) {
thrift::TTypeEntry impala::ColumnToHs2Type(
const TColumnType& columnType) {
const ColumnType& type = ColumnType::FromThrift(columnType);
- AuxColumnType aux_type(columnType);
thrift::TPrimitiveTypeEntry type_entry;
switch (type.type) {
// Map NULL_TYPE to BOOLEAN, otherwise Hive's JDBC driver won't
@@ -902,7 +901,7 @@ thrift::TTypeEntry impala::ColumnToHs2Type(
type_entry.__set_type(thrift::TTypeId::TIMESTAMP_TYPE);
break;
case TYPE_STRING:
- if (aux_type.string_subtype == AuxColumnType::StringSubtype::BINARY) {
+ if (type.IsBinaryType()) {
type_entry.__set_type(thrift::TTypeId::BINARY_TYPE);
} else {
type_entry.__set_type(thrift::TTypeId::STRING_TYPE);
diff --git a/testdata/workloads/functional-query/queries/QueryTest/binary-type.test b/testdata/workloads/functional-query/queries/QueryTest/binary-type.test
index 1462b4820..8d8941d9d 100644
--- a/testdata/workloads/functional-query/queries/QueryTest/binary-type.test
+++ b/testdata/workloads/functional-query/queries/QueryTest/binary-type.test
@@ -22,6 +22,14 @@ INT, STRING
8,'FF4433221100'
====
---- QUERY
+select id, hex(cast(binary_col as string)) from binary_tbl
+where binary_col = cast(unhex("FF4433221100") as binary)
+---- TYPES
+INT, STRING
+---- RESULTS
+8,'FF4433221100'
+====
+---- QUERY
set utf8_mode=0;
select string_col, length(binary_col) from binary_tbl
---- TYPES
(impala) 01/04: IMPALA-12443: Add catalog timeline for all DDL profiles
Posted by st...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
stigahuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git
commit d7b5819f906c19281fdf9594ecf4616f6c9f92a0
Author: stiga-huang <hu...@gmail.com>
AuthorDate: Wed Aug 30 18:47:55 2023 +0800
IMPALA-12443: Add catalog timeline for all DDL profiles
This is a follow-up work of IMPALA-12024 where we add the catalog
timeline for CreateTable statements. Using the same mechanism, this
patch adds catalog timeline for all DDL/DML profiles, including
REFRESH and INSERT.
The goal is to add timeline markers after each step that could be
blocked, e.g. acquiring locks, external RPCs. So we can better debug
slow DDLs with the catalog timeline in profiles.
Tried to add some constant strings for widely used events, e.g. "Fetched
table from Metastore". Didn't do so for events that only occurs once.
Most of the catalog methods now have a new argument for tracking the
execution timeline. To avoid adding null checks everywhere, for code
paths that don't need a catalog profile, e.g. EventProcessor, uses a
static noop EventSequence as the argument. We can replace it in future
works, e.g. expose execution timeline of a slow processing on an HMS
event.
This patch also removes some unused overloads of HdfsTable#load() and
HdfsTable#reloadPartitionsFromNames().
Example timeline for a REFRESH statement on an unloaded table
(IncompleteTable):
Catalog Server Operation: 2s300ms
- Got catalog version read lock: 26.407us (26.407us)
- Start loading table: 314.663us (288.256us)
- Got Metastore client: 629.599us (314.936us)
- Fetched table from Metastore: 7.248ms (6.618ms)
- Loaded table schema: 27.947ms (20.699ms)
- Preloaded permissions cache for 1824 partitions: 1s514ms (1s486ms)
- Got access level: 1s514ms (588.314us)
- Created partition builders: 2s103ms (588.270ms)
- Start loading file metadata: 2s103ms (49.760us)
- Loaded file metadata for 1824 partitions: 2s282ms (179.839ms)
- Async loaded table: 2s289ms (6.931ms)
- Loaded table from scratch: 2s289ms (72.038us)
- Got table read lock: 2s289ms (2.289us)
- Finished resetMetadata request: 2s300ms (10.188ms)
Example timeline for an INSERT statement:
Catalog Server Operation: 178.120ms
- Got catalog version read lock: 4.238us (4.238us)
- Got catalog version write lock and table write lock: 52.768us (48.530us)
- Got Metastore client: 15.768ms (15.715ms)
- Fired Metastore events: 156.650ms (140.882ms)
- Got Metastore client: 163.317ms (6.666ms)
- Fetched table from Metastore: 166.561ms (3.244ms)
- Start refreshing file metadata: 167.961ms (1.399ms)
- Loaded file metadata for 24 partitions: 177.679ms (9.717ms)
- Reloaded table metadata: 178.021ms (342.261us)
- Finished updateCatalog request: 178.120ms (98.929us)
Example timeline for a "COMPUTE STATS tpcds_parquet.store_sales":
Catalog Server Operation: 6s737ms
- Got catalog version read lock: 19.971us (19.971us)
- Got catalog version write lock and table write lock: 50.255us (30.284us)
- Got Metastore client: 171.819us (121.564us)
- Updated column stats: 25.560ms (25.388ms)
- Got Metastore client: 69.298ms (43.738ms)
- Altered 500 partitions in Metastore: 1s894ms (1s825ms)
- Altered 1000 partitions in Metastore: 3s558ms (1s664ms)
- Altered 1500 partitions in Metastore: 5s144ms (1s586ms)
- Altered 1824 partitions in Metastore: 6s205ms (1s060ms)
- Got Metastore client: 6s205ms (329.481us)
- Altered table in Metastore: 6s216ms (11.073ms)
- Got Metastore client: 6s216ms (13.377us)
- Fetched table from Metastore: 6s219ms (2.419ms)
- Loaded table schema: 6s223ms (4.130ms)
- Got current Metastore event id 19017: 6s639ms (415.690ms)
- Start loading file metadata: 6s639ms (9.591us)
- Loaded file metadata for 1824 partitions: 6s729ms (90.196ms)
- Reloaded table metadata: 6s735ms (5.865ms)
- DDL finished: 6s737ms (2.255ms)
Example timeline for a global INVALIDATE METADATA:
Catalog Server Operation: 301.618ms
- Got catalog version write lock: 9.908ms (9.908ms)
- Got Metastore client: 9.922ms (14.013us)
- Got database list: 11.396ms (1.473ms)
- Loaded functions of default: 44.919ms (33.523ms)
- Loaded TableMeta of 82 tables in database default: 47.524ms (2.604ms)
- Loaded functions of functional: 50.846ms (3.321ms)
- Loaded TableMeta of 101 tables in database functional: 52.580ms (1.734ms)
- Loaded functions of functional_avro: 54.861ms (2.281ms)
- Loaded TableMeta of 35 tables in database functional_avro: 55.789ms (928.120us)
...
- Loaded functions of tpch_text_gzip: 299.503ms (1.710ms)
- Loaded TableMeta of 8 tables in database tpch_text_gzip: 300.288ms (784.725us)
- Updated catalog cache: 300.366ms (78.045us)
- Finished resetMetadata request: 301.618ms (1.251ms)
Tests:
- Add e2e test to verify the catalog timeline in some DDLs.
- Ran CORE tests
Change-Id: Ifbceefaeb24c66eb1a064c449d6f56077ea347c5
Reviewed-on: http://gerrit.cloudera.org:8080/20491
Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
be/src/exec/catalog-op-executor.cc | 10 +-
be/src/exec/catalog-op-executor.h | 7 +
be/src/service/client-request-state.cc | 38 +-
be/src/service/client-request-state.h | 3 +
be/src/service/impala-server.cc | 8 +-
common/thrift/CatalogService.thrift | 6 +
.../java/org/apache/impala/catalog/Catalog.java | 18 +-
.../impala/catalog/CatalogServiceCatalog.java | 171 +++--
.../impala/catalog/CatalogdTableInvalidator.java | 7 +-
.../org/apache/impala/catalog/DataSourceTable.java | 5 +-
.../java/org/apache/impala/catalog/HBaseTable.java | 10 +-
.../java/org/apache/impala/catalog/HdfsTable.java | 196 ++---
.../org/apache/impala/catalog/IcebergTable.java | 19 +-
.../org/apache/impala/catalog/IncompleteTable.java | 5 +-
.../java/org/apache/impala/catalog/KuduTable.java | 19 +-
.../impala/catalog/MaterializedViewHdfsTable.java | 7 +-
.../main/java/org/apache/impala/catalog/Table.java | 9 +-
.../org/apache/impala/catalog/TableLoader.java | 16 +-
.../org/apache/impala/catalog/TableLoadingMgr.java | 10 +-
.../main/java/org/apache/impala/catalog/View.java | 5 +-
.../impala/catalog/events/MetastoreEvents.java | 6 +-
.../catalog/events/MetastoreEventsProcessor.java | 3 +-
.../metastore/CatalogMetastoreServiceHandler.java | 19 +-
.../apache/impala/service/CatalogOpExecutor.java | 853 ++++++++++++---------
.../java/org/apache/impala/service/JniCatalog.java | 4 +-
.../impala/service/KuduCatalogOpExecutor.java | 67 +-
.../java/org/apache/impala/util/EventSequence.java | 9 +
.../main/java/org/apache/impala/util/KuduUtil.java | 11 +
.../org/apache/impala/util/NoOpEventSequence.java | 36 +
.../org/apache/impala/catalog/CatalogTest.java | 15 +-
.../catalog/CatalogdTableInvalidatorTest.java | 4 +-
.../catalog/PartialCatalogInfoWriteIdTest.java | 12 +-
.../catalog/events/EventsProcessorStressTest.java | 5 +-
.../events/MetastoreEventsProcessorTest.java | 24 +-
.../org/apache/impala/common/FrontendFixture.java | 3 +-
.../impala/testutil/CatalogServiceTestCatalog.java | 5 +-
.../apache/impala/testutil/ImpaladTestCatalog.java | 5 +-
tests/query_test/test_observability.py | 69 +-
38 files changed, 1068 insertions(+), 651 deletions(-)
diff --git a/be/src/exec/catalog-op-executor.cc b/be/src/exec/catalog-op-executor.cc
index 4039a31f9..985928a9c 100644
--- a/be/src/exec/catalog-op-executor.cc
+++ b/be/src/exec/catalog-op-executor.cc
@@ -114,9 +114,9 @@ Status CatalogOpExecutor::Exec(const TCatalogOpRequest& request) {
FLAGS_catalog_client_rpc_retry_interval_ms,
[&attempt]() { return CatalogRpcDebugFn(&attempt); }, exec_response_.get());
RETURN_IF_ERROR(rpc_status.status);
- if (FLAGS_use_local_catalog) VerifyMinimalResponse(exec_response_.get()->result);
+ if (FLAGS_use_local_catalog) VerifyMinimalResponse(exec_response_->result);
catalog_update_result_.reset(
- new TCatalogUpdateResult(exec_response_.get()->result));
+ new TCatalogUpdateResult(exec_response_->result));
Status status(exec_response_->result.status);
if (status.ok()) {
if (request.ddl_params.ddl_type == TDdlType::DROP_FUNCTION) {
@@ -125,6 +125,9 @@ Status CatalogOpExecutor::Exec(const TCatalogOpRequest& request) {
HandleDropDataSource(request.ddl_params.drop_data_source_params);
}
}
+ if (exec_response_->__isset.profile) {
+ catalog_profile_ = make_unique<TRuntimeProfileNode>(exec_response_->profile);
+ }
return status;
}
case TCatalogOpType::RESET_METADATA: {
@@ -139,6 +142,9 @@ Status CatalogOpExecutor::Exec(const TCatalogOpRequest& request) {
[&attempt]() { return CatalogRpcDebugFn(&attempt); }, &response);
RETURN_IF_ERROR(rpc_status.status);
if (FLAGS_use_local_catalog) VerifyMinimalResponse(response.result);
+ if (response.__isset.profile) {
+ catalog_profile_ = make_unique<TRuntimeProfileNode>(response.profile);
+ }
catalog_update_result_.reset(new TCatalogUpdateResult(response.result));
return Status(response.result.status);
}
diff --git a/be/src/exec/catalog-op-executor.h b/be/src/exec/catalog-op-executor.h
index 12bf2e0f1..9a872744e 100644
--- a/be/src/exec/catalog-op-executor.h
+++ b/be/src/exec/catalog-op-executor.h
@@ -102,6 +102,10 @@ class CatalogOpExecutor {
return catalog_update_result_.get();
}
+ /// Set in Exec(), for operations that are executed using the CatalogServer. Returns
+ /// a pointer to the profile of the execution in catalogd.
+ const TRuntimeProfileNode* catalog_profile() const { return catalog_profile_.get(); }
+
private:
/// Helper functions used in ExecComputeStats() for setting the thrift structs in params
/// for the table/column stats based on the results of the corresponding child query.
@@ -121,6 +125,9 @@ class CatalogOpExecutor {
/// Result of executing a DDL request using the CatalogService
boost::scoped_ptr<TCatalogUpdateResult> catalog_update_result_;
+ /// Profile of the execution on Catalog Server side
+ std::unique_ptr<TRuntimeProfileNode> catalog_profile_;
+
ExecEnv* env_;
Frontend* fe_;
RuntimeProfile* profile_;
diff --git a/be/src/service/client-request-state.cc b/be/src/service/client-request-state.cc
index 26f6c1139..538fde8c1 100644
--- a/be/src/service/client-request-state.cc
+++ b/be/src/service/client-request-state.cc
@@ -714,19 +714,12 @@ void ClientRequestState::ExecDdlRequestImpl(bool exec_in_worker_thread) {
Status status = catalog_op_executor_->Exec(exec_req.catalog_op_request);
query_events_->MarkEvent("CatalogDdlRequest finished");
+ AddCatalogTimeline();
{
lock_guard<mutex> l(lock_);
RETURN_VOID_IF_ERROR(UpdateQueryStatus(status, exec_in_worker_thread));
}
- if (catalog_op_executor_->ddl_exec_response() != nullptr &&
- catalog_op_executor_->ddl_exec_response()->__isset.profile) {
- for (const TEventSequence& catalog_timeline :
- catalog_op_executor_->ddl_exec_response()->profile.event_sequences) {
- summary_profile_->AddEventSequence(catalog_timeline.name, catalog_timeline);
- }
- }
-
// If this is a CTAS request, there will usually be more work to do
// after executing the CREATE TABLE statement (the INSERT portion of the operation).
// The exception is if the user specified IF NOT EXISTS and the table already
@@ -854,6 +847,12 @@ void ClientRequestState::ExecLoadDataRequestImpl(bool exec_in_worker_thread) {
TUpdateCatalogResponse resp;
status = client.DoRpc(
&CatalogServiceClientWrapper::UpdateCatalog, catalog_update, &resp);
+ query_events_->MarkEvent("UpdateCatalog finished");
+ if (resp.__isset.profile) {
+ for (const TEventSequence& catalog_timeline : resp.profile.event_sequences) {
+ summary_profile_->AddEventSequence(catalog_timeline.name, catalog_timeline);
+ }
+ }
{
lock_guard<mutex> l(lock_);
RETURN_VOID_IF_ERROR(UpdateQueryStatus(status, exec_in_worker_thread));
@@ -1577,6 +1576,18 @@ Status ClientRequestState::UpdateCatalog() {
if (status.ok()) {
status = client.DoRpc(
&CatalogServiceClientWrapper::UpdateCatalog, catalog_update, &resp);
+ query_events_->MarkEvent("UpdateCatalog finished");
+ }
+ if (resp.__isset.profile) {
+ for (const TEventSequence& catalog_timeline : resp.profile.event_sequences) {
+ string timeline_name = catalog_timeline.name;
+ // For CTAS, we already have a timeline for the CreateTable execution.
+ // Use another name for the INSERT timeline.
+ if (summary_profile_->GetEventSequence(timeline_name) != nullptr) {
+ timeline_name += " 2";
+ }
+ summary_profile_->AddEventSequence(timeline_name, catalog_timeline);
+ }
}
if (status.ok()) status = Status(resp.result.status);
if (!status.ok()) {
@@ -1790,6 +1801,7 @@ Status ClientRequestState::UpdateTableAndColumnStats(
child_queries[0]->result_data(),
col_stats_schema,
col_stats_data);
+ AddCatalogTimeline();
{
lock_guard<mutex> l(lock_);
RETURN_IF_ERROR(UpdateQueryStatus(status));
@@ -2398,4 +2410,14 @@ int64_t ClientRequestState::row_materialization_timer() const {
return 0;
}
+void ClientRequestState::AddCatalogTimeline() {
+ if (catalog_op_executor_ != nullptr
+ && catalog_op_executor_->catalog_profile() != nullptr) {
+ for (const TEventSequence& catalog_timeline :
+ catalog_op_executor_->catalog_profile()->event_sequences) {
+ summary_profile_->AddEventSequence(catalog_timeline.name, catalog_timeline);
+ }
+ }
+}
+
}
diff --git a/be/src/service/client-request-state.h b/be/src/service/client-request-state.h
index e92a23b71..d0d1b3d78 100644
--- a/be/src/service/client-request-state.h
+++ b/be/src/service/client-request-state.h
@@ -924,5 +924,8 @@ class ClientRequestState {
/// hints about how to reset the original table name. 'params' holds the SQL query
/// string the user should run.
void AddTableResetHints(const TConvertTableRequest& params, Status* status) const;
+
+ /// Adds the catalog execution timeline returned from catalog RPCs into the profile.
+ void AddCatalogTimeline();
};
}
diff --git a/be/src/service/impala-server.cc b/be/src/service/impala-server.cc
index 6e5c3d325..243c52843 100644
--- a/be/src/service/impala-server.cc
+++ b/be/src/service/impala-server.cc
@@ -2228,9 +2228,9 @@ void ImpalaServer::WaitForCatalogUpdate(const int64_t catalog_update_version,
timeline->MarkEvent("Detected change in catalog service ID");
VLOG_QUERY << "Detected change in catalog service ID";
} else {
- timeline->MarkEvent(Substitute("Received catalog version $0",
+ timeline->MarkEvent(Substitute("Applied catalog version $0",
catalog_update_version));
- VLOG_QUERY << "Received catalog version: " << catalog_update_version;
+ VLOG_QUERY << "Applied catalog version: " << catalog_update_version;
}
}
@@ -2251,9 +2251,9 @@ void ImpalaServer::WaitForCatalogUpdateTopicPropagation(
timeline->MarkEvent("Detected change in catalog service ID");
VLOG_QUERY << "Detected change in catalog service ID";
} else {
- timeline->MarkEvent(Substitute("Received min subscriber topic version $0",
+ timeline->MarkEvent(Substitute("Min catalog topic version of coordinators reached $0",
min_req_subscriber_topic_version));
- VLOG_QUERY << "Received min subscriber topic version: "
+ VLOG_QUERY << "Min catalog topic version of coordinators: "
<< min_req_subscriber_topic_version;
}
}
diff --git a/common/thrift/CatalogService.thrift b/common/thrift/CatalogService.thrift
index e8d2f7647..ce14337a9 100644
--- a/common/thrift/CatalogService.thrift
+++ b/common/thrift/CatalogService.thrift
@@ -299,6 +299,9 @@ struct TUpdateCatalogRequest {
// Response from a TUpdateCatalogRequest
struct TUpdateCatalogResponse {
1: required TCatalogUpdateResult result
+
+ // Profile of the DDL/DML execution in catalogd
+ 2: optional RuntimeProfile.TRuntimeProfileNode profile
}
// Parameters of REFRESH/INVALIDATE METADATA commands
@@ -341,6 +344,9 @@ struct TResetMetadataRequest {
// Response from TResetMetadataRequest
struct TResetMetadataResponse {
1: required TCatalogUpdateResult result
+
+ // Profile of the DDL execution in catalogd
+ 2: optional RuntimeProfile.TRuntimeProfileNode profile
}
// Request to GetFunctions()
diff --git a/fe/src/main/java/org/apache/impala/catalog/Catalog.java b/fe/src/main/java/org/apache/impala/catalog/Catalog.java
index 540590c5f..d24b7567f 100644
--- a/fe/src/main/java/org/apache/impala/catalog/Catalog.java
+++ b/fe/src/main/java/org/apache/impala/catalog/Catalog.java
@@ -416,23 +416,23 @@ public abstract class Catalog implements AutoCloseable {
*/
public MetaStoreClient getMetaStoreClient() { return metaStoreClientPool_.getClient(); }
- public int getNumHmsClientsIdle() {
- return metaStoreClientPool_.getNumHmsClientsIdle();
- }
-
- public int getNumHmsClientsInUse() {
- return metaStoreClientPool_.getNumHmsClientsInUse();
- }
-
/**
* Same as the above but also update the given 'timeline'.
*/
public MetaStoreClient getMetaStoreClient(EventSequence timeline) {
MetaStoreClient client = getMetaStoreClient();
- if (timeline != null) timeline.markEvent("Got Metastore client");
+ timeline.markEvent("Got Metastore client");
return client;
}
+ public int getNumHmsClientsIdle() {
+ return metaStoreClientPool_.getNumHmsClientsIdle();
+ }
+
+ public int getNumHmsClientsInUse() {
+ return metaStoreClientPool_.getNumHmsClientsInUse();
+ }
+
/**
* Return all members of 'candidates' that match 'matcher'.
* The results are sorted in String.CASE_INSENSITIVE_ORDER.
diff --git a/fe/src/main/java/org/apache/impala/catalog/CatalogServiceCatalog.java b/fe/src/main/java/org/apache/impala/catalog/CatalogServiceCatalog.java
index 62f95cd0d..817f97f50 100644
--- a/fe/src/main/java/org/apache/impala/catalog/CatalogServiceCatalog.java
+++ b/fe/src/main/java/org/apache/impala/catalog/CatalogServiceCatalog.java
@@ -22,6 +22,12 @@ import static org.apache.impala.catalog.monitor.TableLoadingTimeHistogram.Quanti
import static org.apache.impala.catalog.monitor.TableLoadingTimeHistogram.Quantile.P75;
import static org.apache.impala.catalog.monitor.TableLoadingTimeHistogram.Quantile.P95;
import static org.apache.impala.catalog.monitor.TableLoadingTimeHistogram.Quantile.P99;
+import static org.apache.impala.service.CatalogOpExecutor.FETCHED_HMS_DB;
+import static org.apache.impala.service.CatalogOpExecutor.FETCHED_HMS_PARTITION;
+import static org.apache.impala.service.CatalogOpExecutor.FETCHED_HMS_TABLE;
+import static org.apache.impala.service.CatalogOpExecutor.FETCHED_LATEST_HMS_EVENT_ID;
+import static org.apache.impala.service.CatalogOpExecutor.GOT_TABLE_READ_LOCK;
+import static org.apache.impala.service.CatalogOpExecutor.GOT_TABLE_WRITE_LOCK;
import static org.apache.impala.thrift.TCatalogObjectType.HDFS_PARTITION;
import static org.apache.impala.thrift.TCatalogObjectType.TABLE;
@@ -128,7 +134,9 @@ import org.apache.impala.thrift.TTableUsageMetrics;
import org.apache.impala.thrift.TUpdateTableUsageRequest;
import org.apache.impala.util.AcidUtils;
import org.apache.impala.util.CatalogBlacklistUtils;
+import org.apache.impala.util.EventSequence;
import org.apache.impala.util.FunctionUtils;
+import org.apache.impala.util.NoOpEventSequence;
import org.apache.impala.util.PatternMatcher;
import org.apache.impala.util.TUniqueIdUtil;
import org.apache.impala.util.ThreadNameAnnotator;
@@ -230,6 +238,11 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder;
public class CatalogServiceCatalog extends Catalog {
public static final Logger LOG = LoggerFactory.getLogger(CatalogServiceCatalog.class);
+ public static final String GOT_CATALOG_VERSION_READ_LOCK =
+ "Got catalog version read lock";
+ public static final String GOT_CATALOG_VERSION_WRITE_LOCK =
+ "Got catalog version write lock";
+
public static final int INITIAL_META_STORE_CLIENT_POOL_SIZE = 10;
private static final int MAX_NUM_SKIPPED_TOPIC_UPDATES = 2;
private final int maxSkippedUpdatesLockContention_;
@@ -467,6 +480,14 @@ public class CatalogServiceCatalog extends Catalog {
.equals(((MetastoreEventsProcessor) metastoreEventProcessor_).getStatus());
}
+ /**
+ * Acquires the table read lock and update the 'catalogTimeline'.
+ */
+ public void readLock(Table tbl, EventSequence catalogTimeline) {
+ tbl.readLock().lock();
+ catalogTimeline.markEvent(GOT_TABLE_READ_LOCK);
+ }
+
/**
* Tries to acquire versionLock_ and the lock of 'tbl' in that order. Returns true if it
* successfully acquires both within LOCK_RETRY_TIMEOUT_MS millisecs; both locks are
@@ -477,6 +498,19 @@ public class CatalogServiceCatalog extends Catalog {
return tryLock(tbl, true, LOCK_RETRY_TIMEOUT_MS);
}
+ /**
+ * Same as the above but also updates 'catalogTimeline' when the operation finishes.
+ */
+ public boolean tryWriteLock(Table tbl, EventSequence catalogTimeline) {
+ boolean success = tryWriteLock(tbl);
+ if (success) {
+ catalogTimeline.markEvent(GOT_TABLE_WRITE_LOCK);
+ } else {
+ catalogTimeline.markEvent("Failed to acquire table write lock");
+ }
+ return success;
+ }
+
/**
* Acquire write lock on multiple tables. If the lock couldn't be acquired on any
* table, then release the table lock as well as version lock held due previous tables
@@ -746,7 +780,8 @@ public class CatalogServiceCatalog extends Catalog {
}
long tableId = request.getTable_id();
Table table = getOrLoadTable(tableName.db_name, tableName.table_name,
- "needed to fetch partition stats", writeIdList, tableId);
+ "needed to fetch partition stats", writeIdList, tableId,
+ NoOpEventSequence.INSTANCE);
// Table could be null if it does not exist anymore.
if (table == null) {
@@ -1991,7 +2026,8 @@ public class CatalogServiceCatalog extends Catalog {
* Returns null if the method encounters an exception during invalidation.
*/
private Pair<Db, List<TTableName>> invalidateDb(
- MetaStoreClient msClient, String dbName, Db existingDb) {
+ MetaStoreClient msClient, String dbName, Db existingDb,
+ EventSequence catalogTimeline) {
try {
List<org.apache.hadoop.hive.metastore.api.Function> javaFns =
new ArrayList<>();
@@ -2016,6 +2052,7 @@ public class CatalogServiceCatalog extends Catalog {
// Reload Java UDFs from HMS.
loadJavaFunctions(newDb, javaFns);
newDb.setCatalogVersion(incrementAndGetCatalogVersion());
+ catalogTimeline.markEvent("Loaded functions of " + dbName);
LOG.info("Loading table list for database: {}", dbName);
int numTables = 0;
@@ -2037,6 +2074,8 @@ public class CatalogServiceCatalog extends Catalog {
tblsToBackgroundLoad.add(new TTableName(dbName, tableName));
}
}
+ catalogTimeline.markEvent(String.format(
+ "Loaded %d table names of database %s", numTables, dbName));
LOG.info("Loaded table list for database: {}. Number of tables: {}",
dbName, numTables);
@@ -2092,7 +2131,7 @@ public class CatalogServiceCatalog extends Catalog {
* requesting impalad will use that version to determine when the
* effects of reset have been applied to its local catalog cache.
*/
- public long reset() throws CatalogException {
+ public long reset(EventSequence catalogTimeline) throws CatalogException {
long startVersion = getCatalogVersion();
LOG.info("Invalidating all metadata. Version: " + startVersion);
// First update the policy metadata.
@@ -2128,6 +2167,7 @@ public class CatalogServiceCatalog extends Catalog {
LOG.error("Couldn't identify the default FS. Cache Pool reader will be disabled.");
}
versionLock_.writeLock().lock();
+ catalogTimeline.markEvent(GOT_CATALOG_VERSION_WRITE_LOCK);
// In case of an empty new catalog, the version should still change to reflect the
// reset operation itself and to unblock impalads by making the catalog version >
// INITIAL_CATALOG_VERSION. See Frontend.waitForCatalog()
@@ -2146,8 +2186,9 @@ public class CatalogServiceCatalog extends Catalog {
// step.
Map<String, Db> newDbCache = new ConcurrentHashMap<String, Db>();
List<TTableName> tblsToBackgroundLoad = new ArrayList<>();
- try (MetaStoreClient msClient = getMetaStoreClient()) {
+ try (MetaStoreClient msClient = getMetaStoreClient(catalogTimeline)) {
List<String> allDbs = msClient.getHiveClient().getAllDatabases();
+ catalogTimeline.markEvent("Got database list");
int numComplete = 0;
for (String dbName: allDbs) {
if (isBlacklistedDb(dbName)) {
@@ -2160,7 +2201,7 @@ public class CatalogServiceCatalog extends Catalog {
dbName = dbName.toLowerCase();
Db oldDb = oldDbCache.get(dbName);
Pair<Db, List<TTableName>> invalidatedDb = invalidateDb(msClient,
- dbName, oldDb);
+ dbName, oldDb, catalogTimeline);
if (invalidatedDb == null) continue;
newDbCache.put(dbName, invalidatedDb.first);
tblsToBackgroundLoad.addAll(invalidatedDb.second);
@@ -2168,6 +2209,7 @@ public class CatalogServiceCatalog extends Catalog {
}
}
dbCache_.set(newDbCache);
+ catalogTimeline.markEvent("Updated catalog cache");
// Identify any deleted databases and add them to the delta log.
Set<String> oldDbNames = oldDbCache.keySet();
@@ -2309,11 +2351,11 @@ public class CatalogServiceCatalog extends Catalog {
return table;
}
-
public Table getOrLoadTable(String dbName, String tblName, String reason,
- ValidWriteIdList validWriteIdList) throws CatalogException {
+ ValidWriteIdList validWriteIdList)
+ throws CatalogException {
return getOrLoadTable(dbName, tblName, reason, validWriteIdList,
- TABLE_ID_UNAVAILABLE);
+ TABLE_ID_UNAVAILABLE, NoOpEventSequence.INSTANCE);
}
/**
@@ -2326,7 +2368,8 @@ public class CatalogServiceCatalog extends Catalog {
* (not yet loaded table) will be returned.
*/
public Table getOrLoadTable(String dbName, String tblName, String reason,
- ValidWriteIdList validWriteIdList, long tableId) throws CatalogException {
+ ValidWriteIdList validWriteIdList, long tableId, EventSequence catalogTimeline)
+ throws CatalogException {
TTableName tableName = new TTableName(dbName.toLowerCase(), tblName.toLowerCase());
Table tbl;
TableLoadingMgr.LoadRequest loadReq = null;
@@ -2334,7 +2377,7 @@ public class CatalogServiceCatalog extends Catalog {
long previousCatalogVersion = -1;
// Return the table if it is already loaded or submit a new load request.
- versionLock_.readLock().lock();
+ acquireVersionReadLock(catalogTimeline);
try {
tbl = getTable(dbName, tblName);
// tbl doesn't exist in the catalog
@@ -2368,7 +2411,7 @@ public class CatalogServiceCatalog extends Catalog {
AcidUtils.isTransactionalTable(tbl.getMetaStoreTable().getParameters()),
"Compaction id check cannot be done for non-transactional table "
+ tbl.getFullName());
- tbl.readLock().lock();
+ readLock(tbl, catalogTimeline);
try {
partsToBeRefreshed =
AcidUtils.getPartitionsForRefreshingFileMetadata(this, (HdfsTable) tbl);
@@ -2392,19 +2435,22 @@ public class CatalogServiceCatalog extends Catalog {
}
previousCatalogVersion = tbl.getCatalogVersion();
LOG.trace("Loading full table {}", tbl.getFullName());
- loadReq = tableLoadingMgr_.loadAsync(tableName, tbl.getCreateEventId(), reason);
+ loadReq = tableLoadingMgr_.loadAsync(tableName, tbl.getCreateEventId(), reason,
+ catalogTimeline);
}
} finally {
versionLock_.readLock().unlock();
}
if (!partsToBeRefreshed.isEmpty()) {
- return refreshFileMetadata((HdfsTable) tbl, partsToBeRefreshed);
+ return refreshFileMetadata((HdfsTable) tbl, partsToBeRefreshed, catalogTimeline);
}
Preconditions.checkNotNull(loadReq);
try {
+ Table t = loadReq.get();
+ catalogTimeline.markEvent("Async loaded table");
// The table may have been dropped/modified while the load was in progress, so only
// apply the update if the existing table hasn't changed.
- return replaceTableIfUnchanged(loadReq.get(), previousCatalogVersion, tableId);
+ return replaceTableIfUnchanged(t, previousCatalogVersion, tableId);
} finally {
loadReq.close();
}
@@ -2612,36 +2658,40 @@ public class CatalogServiceCatalog extends Catalog {
}
/**
- * Wrapper around {@link #reloadTable(Table, boolean, CatalogObject.ThriftObjectType,
- * String, long)} which passes false for {@code refreshUpdatedPartitions} argument
+ * Wrapper around {@link #reloadTable(Table, String, long, boolean, EventSequence)}
+ * which passes false for {@code isSkipFileMetadataReload} argument
* and ignore the result.
*/
- public void reloadTable(Table tbl, String reason) throws CatalogException {
- reloadTable(tbl, reason, -1, false);
+ public void reloadTable(Table tbl, String reason, EventSequence catalogTimeline)
+ throws CatalogException {
+ reloadTable(tbl, reason, -1, false, catalogTimeline);
}
/**
- * Wrapper around {@link #reloadTable(Table, boolean, CatalogObject.ThriftObjectType,
- * String, long)} which passes false for {@code refreshUpdatedPartitions} argument
- * and ignore the result.
+ * Wrapper around {@link #reloadTable(Table, TResetMetadataRequest,
+ * CatalogObject.ThriftObjectType, String, long, boolean, EventSequence)} which passes
+ * an empty TResetMetadataRequest and NONE for {@code resultType} argument, ignores the
+ * result.
* eventId: HMS event id which triggered reload
*/
public void reloadTable(Table tbl, String reason, long eventId,
- boolean isSkipFileMetadataReload) throws CatalogException {
+ boolean isSkipFileMetadataReload, EventSequence catalogTimeline)
+ throws CatalogException {
reloadTable(tbl, new TResetMetadataRequest(), CatalogObject.ThriftObjectType.NONE,
- reason, eventId, isSkipFileMetadataReload);
+ reason, eventId, isSkipFileMetadataReload, catalogTimeline);
}
/**
- * Wrapper around {@link #reloadTable(Table, boolean, CatalogObject.ThriftObjectType,
- * String, long)} which passes false for {@code refreshUpdatedPartitions} argument.
+ * Wrapper around {@link #reloadTable(Table, TResetMetadataRequest,
+ * CatalogObject.ThriftObjectType, String, long, boolean, EventSequence)} which passes
+ * false for {@code isSkipFileMetadataReload} argument.
* eventId: HMS event id which triggered reload
*/
public TCatalogObject reloadTable(Table tbl, TResetMetadataRequest request,
- CatalogObject.ThriftObjectType resultType, String reason, long eventId)
- throws CatalogException {
+ CatalogObject.ThriftObjectType resultType, String reason, long eventId,
+ EventSequence catalogTimeline) throws CatalogException {
return reloadTable(tbl, request, resultType, reason, eventId,
- /*isSkipFileMetadataReload*/false);
+ /*isSkipFileMetadataReload*/false, catalogTimeline);
}
/**
@@ -2650,22 +2700,20 @@ public class CatalogServiceCatalog extends Catalog {
* TCatalogObject representing 'tbl'. Applies proper synchronization to protect the
* metadata load from concurrent table modifications and assigns a new catalog version.
* Throws a CatalogException if there is an error loading table metadata.
- * If {@code refreshUpdatedParts} is true, the refresh logic detects updated
- * partitions in metastore and reloads them too.
- * if {@code wantMinimalResult} is true, returns the result in the minimal form.
- * if this reload is triggered while processing some HMS event (from example from
+ * If this reload is triggered while processing some HMS event (for example from
* MetastoreEventProcessor), then eventId passed would be > -1. In that case
* check table's last synced event id and if it is >= eventId then skip reloading
- * table. Otherwise, set the eventId as table's last synced id after reload is done
+ * table. Otherwise, set the eventId as table's last synced id after reload is done.
*/
public TCatalogObject reloadTable(Table tbl, TResetMetadataRequest request,
CatalogObject.ThriftObjectType resultType, String reason, long eventId,
- boolean isSkipFileMetadataReload) throws CatalogException {
+ boolean isSkipFileMetadataReload, EventSequence catalogTimeline)
+ throws CatalogException {
LOG.info(String.format("Refreshing table metadata: %s", tbl.getFullName()));
Preconditions.checkState(!(tbl instanceof IncompleteTable));
String dbName = tbl.getDb().getName();
String tblName = tbl.getName();
- if (!tryWriteLock(tbl)) {
+ if (!tryWriteLock(tbl, catalogTimeline)) {
throw new CatalogException(String.format("Error refreshing metadata for table " +
"%s due to lock contention", tbl.getFullName()));
}
@@ -2683,11 +2731,12 @@ public class CatalogServiceCatalog extends Catalog {
return tbl.toTCatalogObject(resultType);
}
long currentHmsEventId = -1;
- try (MetaStoreClient msClient = getMetaStoreClient()) {
+ try (MetaStoreClient msClient = getMetaStoreClient(catalogTimeline)) {
if (syncToLatestEventId) {
try {
currentHmsEventId = msClient.getHiveClient().getCurrentNotificationEventId()
.getEventId();
+ catalogTimeline.markEvent(FETCHED_LATEST_HMS_EVENT_ID + currentHmsEventId);
} catch (TException e) {
throw new CatalogException("Failed to reload table: " + tbl.getFullName() +
" as there was an error in fetching current event id from HMS", e);
@@ -2696,6 +2745,7 @@ public class CatalogServiceCatalog extends Catalog {
org.apache.hadoop.hive.metastore.api.Table msTbl = null;
try {
msTbl = msClient.getHiveClient().getTable(dbName, tblName);
+ catalogTimeline.markEvent(FETCHED_HMS_TABLE);
} catch (Exception e) {
throw new TableLoadingException("Error loading metadata for table: " +
dbName + "." + tblName, e);
@@ -2705,10 +2755,11 @@ public class CatalogServiceCatalog extends Catalog {
.load(true, msClient.getHiveClient(), msTbl, !isSkipFileMetadataReload,
/* loadTableSchema*/true, request.refresh_updated_hms_partitions,
/* partitionsToUpdate*/null, request.debug_action,
- /*partitionToEventId*/null, reason);
+ /*partitionToEventId*/null, reason, catalogTimeline);
} else {
- tbl.load(true, msClient.getHiveClient(), msTbl, reason);
+ tbl.load(true, msClient.getHiveClient(), msTbl, reason, catalogTimeline);
}
+ catalogTimeline.markEvent("Loaded table");
}
if (currentHmsEventId != -1 && syncToLatestEventId) {
// fetch latest event id from HMS before starting table load and set that event
@@ -2787,7 +2838,8 @@ public class CatalogServiceCatalog extends Catalog {
* cache.
*/
public TCatalogObject invalidateTable(TTableName tableName,
- Reference<Boolean> tblWasRemoved, Reference<Boolean> dbWasAdded) {
+ Reference<Boolean> tblWasRemoved, Reference<Boolean> dbWasAdded,
+ EventSequence catalogTimeline) {
tblWasRemoved.setRef(false);
dbWasAdded.setRef(false);
String dbName = tableName.getDb_name();
@@ -2805,11 +2857,12 @@ public class CatalogServiceCatalog extends Catalog {
List<TableMeta> metaRes = null;
org.apache.hadoop.hive.metastore.api.Table msTbl = null;
Db db = null;
- try (MetaStoreClient msClient = getMetaStoreClient()) {
+ try (MetaStoreClient msClient = getMetaStoreClient(catalogTimeline)) {
org.apache.hadoop.hive.metastore.api.Database msDb = null;
try {
metaRes = getTableMetaFromHive(msClient, dbName, tblName);
msTbl = msClient.getHiveClient().getTable(dbName, tblName);
+ catalogTimeline.markEvent(FETCHED_HMS_TABLE);
} catch (UnknownDBException | NoSuchObjectException e) {
// The parent database does not exist in the metastore. Treat this the same
// as if the table does not exist.
@@ -2820,6 +2873,7 @@ public class CatalogServiceCatalog extends Catalog {
if (metaRes != null && metaRes.isEmpty()) {
Table result = removeTable(dbName, tblName);
+ catalogTimeline.markEvent("Removed table in catalog cache");
if (result == null) return null;
tblWasRemoved.setRef(true);
result.takeReadLock();
@@ -2841,8 +2895,10 @@ public class CatalogServiceCatalog extends Catalog {
// must be valid since tableExistsInMetaStore is true.
try {
msDb = msClient.getHiveClient().getDatabase(dbName);
+ catalogTimeline.markEvent(FETCHED_HMS_DB);
Preconditions.checkNotNull(msDb);
addDb(dbName, msDb);
+ catalogTimeline.markEvent("Added database in catalog cache");
dbWasAdded.setRef(true);
} catch (TException e) {
// The Metastore database cannot be get. Log the error and return.
@@ -2920,7 +2976,8 @@ public class CatalogServiceCatalog extends Catalog {
+ "event {}.", dbName, tblName, eventId, table.getCreateEventId());
return false;
}
- reloadTable(table, reason, eventId, isSkipFileMetadataReload);
+ reloadTable(table, reason, eventId, isSkipFileMetadataReload,
+ NoOpEventSequence.INSTANCE);
} catch (DatabaseNotFoundException | TableLoadingException e) {
LOG.info(String.format("Reload table if exists failed with: %s", e.getMessage()));
return false;
@@ -3234,6 +3291,11 @@ public class CatalogServiceCatalog extends Catalog {
}
}
+ private void acquireVersionReadLock(EventSequence catalogTimeline) {
+ versionLock_.readLock().lock();
+ catalogTimeline.markEvent(GOT_CATALOG_VERSION_READ_LOCK);
+ }
+
public ReentrantReadWriteLock getLock() { return versionLock_; }
public AuthorizationPolicy getAuthPolicy() { return authPolicy_; }
@@ -3244,8 +3306,8 @@ public class CatalogServiceCatalog extends Catalog {
*/
public TCatalogObject reloadPartition(Table tbl, List<TPartitionKeyValue> partitionSpec,
Reference<Boolean> wasPartitionReloaded, CatalogObject.ThriftObjectType resultType,
- String reason) throws CatalogException {
- if (!tryWriteLock(tbl)) {
+ String reason, EventSequence catalogTimeline) throws CatalogException {
+ if (!tryWriteLock(tbl, catalogTimeline)) {
throw new CatalogException(String.format("Error reloading partition of table %s " +
"due to lock contention", tbl.getFullName()));
}
@@ -3262,7 +3324,7 @@ public class CatalogServiceCatalog extends Catalog {
? HdfsTable.constructPartitionName(partitionSpec)
: hdfsPartition.getPartitionName();
return reloadHdfsPartition(hdfsTable, partitionName, wasPartitionReloaded,
- resultType, reason, newCatalogVersion, hdfsPartition);
+ resultType, reason, newCatalogVersion, hdfsPartition, catalogTimeline);
} finally {
UnlockWriteLockIfErroneouslyLocked();
tbl.releaseWriteLock();
@@ -3278,16 +3340,17 @@ public class CatalogServiceCatalog extends Catalog {
*/
public TCatalogObject reloadHdfsPartition(HdfsTable hdfsTable, String partitionName,
Reference<Boolean> wasPartitionReloaded, CatalogObject.ThriftObjectType resultType,
- String reason, long newCatalogVersion, @Nullable HdfsPartition hdfsPartition)
- throws CatalogException {
+ String reason, long newCatalogVersion, @Nullable HdfsPartition hdfsPartition,
+ EventSequence catalogTimeline) throws CatalogException {
Preconditions.checkState(hdfsTable.isWriteLockedByCurrentThread());
LOG.info(String.format("Refreshing partition metadata: %s %s (%s)",
hdfsTable.getFullName(), partitionName, reason));
- try (MetaStoreClient msClient = getMetaStoreClient()) {
+ try (MetaStoreClient msClient = getMetaStoreClient(catalogTimeline)) {
org.apache.hadoop.hive.metastore.api.Partition hmsPartition = null;
try {
hmsPartition = msClient.getHiveClient().getPartition(
hdfsTable.getDb().getName(), hdfsTable.getName(), partitionName);
+ catalogTimeline.markEvent(FETCHED_HMS_PARTITION);
} catch (NoSuchObjectException e) {
// If partition does not exist in Hive Metastore, remove it from the
// catalog
@@ -3310,7 +3373,8 @@ public class CatalogServiceCatalog extends Catalog {
// note that hdfsPartition can be null here which is a valid input argument
// in such a case a new hdfsPartition is added and nothing is removed.
hmsPartToHdfsPart.put(hmsPartition, hdfsPartition);
- hdfsTable.reloadPartitions(msClient.getHiveClient(), hmsPartToHdfsPart, true);
+ hdfsTable.reloadPartitions(msClient.getHiveClient(), hmsPartToHdfsPart, true,
+ catalogTimeline);
}
hdfsTable.setCatalogVersion(newCatalogVersion);
wasPartitionReloaded.setRef(true);
@@ -3694,7 +3758,7 @@ public class CatalogServiceCatalog extends Catalog {
}
table = getOrLoadTable(
objectDesc.getTable().getDb_name(), objectDesc.getTable().getTbl_name(),
- tableLoadReason, writeIdList, tableId);
+ tableLoadReason, writeIdList, tableId, NoOpEventSequence.INSTANCE);
} catch (DatabaseNotFoundException e) {
return createGetPartialCatalogObjectError(req, CatalogLookupStatus.DB_NOT_FOUND);
}
@@ -3848,10 +3912,11 @@ public class CatalogServiceCatalog extends Catalog {
* @return the updated table
*/
private Table refreshFileMetadata(HdfsTable hdfsTable,
- List<HdfsPartition.Builder> partBuilders) throws CatalogException {
+ List<HdfsPartition.Builder> partBuilders, EventSequence catalogTimeline)
+ throws CatalogException {
Preconditions.checkState(!partBuilders.isEmpty());
- if (!tryWriteLock(hdfsTable)) {
+ if (!tryWriteLock(hdfsTable, catalogTimeline)) {
throw new CatalogException(String.format(
"Error during refreshing file metadata for table %s due to lock contention",
hdfsTable.getFullName()));
@@ -3859,9 +3924,9 @@ public class CatalogServiceCatalog extends Catalog {
long newVersion = incrementAndGetCatalogVersion();
versionLock_.writeLock().unlock();
try {
- try (MetaStoreClient client = getMetaStoreClient()) {
+ try (MetaStoreClient client = getMetaStoreClient(catalogTimeline)) {
hdfsTable.loadFileMetadataForPartitions(
- client.getHiveClient(), partBuilders, true);
+ client.getHiveClient(), partBuilders, true, catalogTimeline);
}
hdfsTable.updatePartitions(partBuilders);
hdfsTable.setCatalogVersion(newVersion);
diff --git a/fe/src/main/java/org/apache/impala/catalog/CatalogdTableInvalidator.java b/fe/src/main/java/org/apache/impala/catalog/CatalogdTableInvalidator.java
index a319c4d8d..ee585a439 100644
--- a/fe/src/main/java/org/apache/impala/catalog/CatalogdTableInvalidator.java
+++ b/fe/src/main/java/org/apache/impala/catalog/CatalogdTableInvalidator.java
@@ -26,6 +26,7 @@ import com.sun.management.GcInfo;
import org.apache.impala.common.Reference;
import org.apache.impala.service.BackendConfig;
import org.apache.impala.thrift.TTableName;
+import org.apache.impala.util.NoOpEventSequence;
import org.apache.log4j.Logger;
import javax.management.Notification;
@@ -215,7 +216,8 @@ public class CatalogdTableInvalidator {
TTableName tTableName = tables.get(i).getTableName().toThrift();
Reference<Boolean> tblWasRemoved = new Reference<>();
Reference<Boolean> dbWasAdded = new Reference<>();
- catalog_.invalidateTable(tTableName, tblWasRemoved, dbWasAdded);
+ catalog_.invalidateTable(tTableName, tblWasRemoved, dbWasAdded,
+ NoOpEventSequence.INSTANCE);
LOG.info("Table " + tables.get(i).getFullName() + " invalidated due to memory " +
"pressure.");
}
@@ -231,7 +233,8 @@ public class CatalogdTableInvalidator {
Reference<Boolean> tblWasRemoved = new Reference<>();
Reference<Boolean> dbWasAdded = new Reference<>();
TTableName tTableName = table.getTableName().toThrift();
- catalog_.invalidateTable(tTableName, tblWasRemoved, dbWasAdded);
+ catalog_.invalidateTable(tTableName, tblWasRemoved, dbWasAdded,
+ NoOpEventSequence.INSTANCE);
LOG.info(
"Invalidated " + table.getFullName() + " due to inactivity for " +
TimeUnit.NANOSECONDS.toSeconds(inactivityTime) + " seconds.");
diff --git a/fe/src/main/java/org/apache/impala/catalog/DataSourceTable.java b/fe/src/main/java/org/apache/impala/catalog/DataSourceTable.java
index 2be5411ae..2bddfacc1 100644
--- a/fe/src/main/java/org/apache/impala/catalog/DataSourceTable.java
+++ b/fe/src/main/java/org/apache/impala/catalog/DataSourceTable.java
@@ -26,6 +26,7 @@ import java.util.stream.Collectors;
import org.apache.hadoop.hive.common.ValidWriteIdList;
import org.apache.hadoop.hive.metastore.IMetaStoreClient;
import org.apache.hadoop.hive.metastore.api.FieldSchema;
+import org.apache.impala.util.EventSequence;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.impala.common.ImpalaRuntimeException;
@@ -234,8 +235,8 @@ public class DataSourceTable extends Table implements FeDataSourceTable {
@Override
public void load(boolean reuseMetadata, IMetaStoreClient client,
- org.apache.hadoop.hive.metastore.api.Table msTbl, String reason)
- throws TableLoadingException {
+ org.apache.hadoop.hive.metastore.api.Table msTbl, String reason,
+ EventSequence catalogTimeline) throws TableLoadingException {
Preconditions.checkNotNull(msTbl);
Table.LOADING_TABLES.incrementAndGet();
msTable_ = msTbl;
diff --git a/fe/src/main/java/org/apache/impala/catalog/HBaseTable.java b/fe/src/main/java/org/apache/impala/catalog/HBaseTable.java
index 4248f0395..b32dc1989 100644
--- a/fe/src/main/java/org/apache/impala/catalog/HBaseTable.java
+++ b/fe/src/main/java/org/apache/impala/catalog/HBaseTable.java
@@ -30,6 +30,7 @@ import org.apache.impala.thrift.TResultSet;
import org.apache.impala.thrift.TTable;
import org.apache.impala.thrift.TTableDescriptor;
import org.apache.impala.thrift.TTableType;
+import org.apache.impala.util.EventSequence;
import com.codahale.metrics.Timer;
import com.google.common.base.Preconditions;
@@ -98,8 +99,8 @@ public class HBaseTable extends Table implements FeHBaseTable {
*/
@Override
public void load(boolean reuseMetadata, IMetaStoreClient client,
- org.apache.hadoop.hive.metastore.api.Table msTbl, String reason)
- throws TableLoadingException {
+ org.apache.hadoop.hive.metastore.api.Table msTbl, String reason,
+ EventSequence catalogTimeline) throws TableLoadingException {
Preconditions.checkNotNull(getMetaStoreTable());
Table.LOADING_TABLES.incrementAndGet();
try (Timer.Context timer = getMetrics().getTimer(Table.LOAD_DURATION_METRIC).time()) {
@@ -109,6 +110,9 @@ public class HBaseTable extends Table implements FeHBaseTable {
List<Column> cols;
try {
hbaseTableName_ = Util.getHBaseTableName(getMetaStoreTable());
+ // Warm up the connection and verify the table exists.
+ Util.getHBaseTable(hbaseTableName_).close();
+ catalogTimeline.markEvent("Checked HBase table exists");
columnFamilies_ = null;
// Warm up the connection and verify the table exists.
getColumnFamilies();
@@ -123,7 +127,7 @@ public class HBaseTable extends Table implements FeHBaseTable {
// since we don't support composite hbase rowkeys yet, all hbase tables have a
// single clustering col
numClusteringCols_ = 1;
- loadAllColumnStats(client);
+ loadAllColumnStats(client, catalogTimeline);
refreshLastUsedTime();
} catch (Exception e) {
throw new TableLoadingException("Failed to load metadata for HBase table: " + name_,
diff --git a/fe/src/main/java/org/apache/impala/catalog/HdfsTable.java b/fe/src/main/java/org/apache/impala/catalog/HdfsTable.java
index 0468bbd9e..044a945d8 100644
--- a/fe/src/main/java/org/apache/impala/catalog/HdfsTable.java
+++ b/fe/src/main/java/org/apache/impala/catalog/HdfsTable.java
@@ -94,11 +94,13 @@ import org.apache.impala.util.AcidUtils;
import org.apache.impala.util.AvroSchemaConverter;
import org.apache.impala.util.AvroSchemaUtils;
import org.apache.impala.util.DebugUtils;
+import org.apache.impala.util.EventSequence;
import org.apache.impala.util.FsPermissionCache;
import org.apache.impala.util.FsPermissionChecker;
import org.apache.impala.util.HdfsCachingUtil;
import org.apache.impala.util.ListMap;
import org.apache.impala.util.MetaStoreUtil;
+import org.apache.impala.util.NoOpEventSequence;
import org.apache.impala.util.TAccessLevelUtil;
import org.apache.impala.util.TResultRowBuilder;
import org.apache.impala.util.ThreadNameAnnotator;
@@ -122,6 +124,8 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Multiset;
import com.google.common.collect.Sets;
+import static org.apache.impala.service.CatalogOpExecutor.FETCHED_LATEST_HMS_EVENT_ID;
+
/**
* Internal representation of table-related metadata of a file-resident table on a
* Hadoop filesystem. The table data can be accessed through libHDFS (which is more of
@@ -700,16 +704,17 @@ public class HdfsTable extends Table implements FeFsTable {
* partition keys.
*/
private long loadAllPartitions(IMetaStoreClient client, List<Partition> msPartitions,
- org.apache.hadoop.hive.metastore.api.Table msTbl) throws IOException,
- CatalogException {
+ org.apache.hadoop.hive.metastore.api.Table msTbl, EventSequence catalogTimeline)
+ throws IOException, CatalogException {
Preconditions.checkNotNull(msTbl);
final Clock clock = Clock.defaultClock();
long startTime = clock.getTick();
initializePartitionMetadata(msTbl);
- FsPermissionCache permCache = preloadPermissionsCache(msPartitions);
+ FsPermissionCache permCache = preloadPermissionsCache(msPartitions, catalogTimeline);
Path tblLocation = FileSystemUtil.createFullyQualifiedPath(getHdfsBaseDirPath());
accessLevel_ = getAvailableAccessLevel(getFullName(), tblLocation, permCache);
+ catalogTimeline.markEvent("Got access level");
List<HdfsPartition.Builder> partBuilders = new ArrayList<>();
if (msTbl.getPartitionKeysSize() == 0) {
@@ -731,11 +736,14 @@ public class HdfsTable extends Table implements FeFsTable {
partBuilders.add(createPartitionBuilder(
msPartition.getSd(), msPartition, permCache));
}
+ // Most of the time spent in getAvailableAccessLevel() for each partition.
+ catalogTimeline.markEvent("Created partition builders");
}
// Load the file metadata from scratch.
Timer.Context fileMetadataLdContext = getMetrics().getTimer(
HdfsTable.LOAD_DURATION_FILE_METADATA_ALL_PARTITIONS).time();
- loadFileMetadataForPartitions(client, partBuilders, /*isRefresh=*/false);
+ loadFileMetadataForPartitions(client, partBuilders, /*isRefresh=*/false,
+ catalogTimeline);
fileMetadataLdContext.stop();
for (HdfsPartition.Builder p : partBuilders) addPartition(p.build());
return clock.getTick() - startTime;
@@ -754,13 +762,14 @@ public class HdfsTable extends Table implements FeFsTable {
/**
* Similar to
- * {@link #loadFileMetadataForPartitions(IMetaStoreClient, Collection, boolean)}
- * but without any injecting the debug actions.
+ * {@link #loadFileMetadataForPartitions(IMetaStoreClient, Collection, boolean, String,
+ * EventSequence)} but without any injecting the debug actions.
*/
public long loadFileMetadataForPartitions(IMetaStoreClient client,
- Collection<HdfsPartition.Builder> partBuilders, boolean isRefresh)
- throws CatalogException {
- return loadFileMetadataForPartitions(client, partBuilders, isRefresh, null);
+ Collection<HdfsPartition.Builder> partBuilders, boolean isRefresh,
+ EventSequence catalogTimeline) throws CatalogException {
+ return loadFileMetadataForPartitions(client, partBuilders, isRefresh, null,
+ catalogTimeline);
}
/**
@@ -773,10 +782,12 @@ public class HdfsTable extends Table implements FeFsTable {
*/
private long loadFileMetadataForPartitions(IMetaStoreClient client,
Collection<HdfsPartition.Builder> partBuilders, boolean isRefresh,
- String debugActions) throws CatalogException {
+ String debugActions, EventSequence catalogTimeline) throws CatalogException {
getMetrics().getCounter(NUM_LOAD_FILEMETADATA_METRIC).inc();
final Clock clock = Clock.defaultClock();
long startTime = clock.getTick();
+ catalogTimeline.markEvent(String.format("Start %s file metadata",
+ isRefresh ? "refreshing" : "loading"));
if (DebugUtils.hasDebugAction(debugActions,
DebugUtils.LOAD_FILE_METADATA_THROW_EXCEPTION)) {
@@ -819,6 +830,8 @@ public class HdfsTable extends Table implements FeFsTable {
Iterables.size(partBuilders) - 3);
}
+ catalogTimeline.markEvent(String.format("Loaded file metadata for %d partitions",
+ partBuilders.size()));
long duration = clock.getTick() - startTime;
LOG.info("Loaded file and block metadata for {} partitions: {}. Time taken: {}",
getFullName(), partNames, PrintUtils.printTimeNs(duration));
@@ -916,9 +929,10 @@ public class HdfsTable extends Table implements FeFsTable {
*/
public List<HdfsPartition> createAndLoadPartitions(IMetaStoreClient client,
List<org.apache.hadoop.hive.metastore.api.Partition> msPartitions,
- @Nullable Map<String, Long> msPartitionsToEventId) throws CatalogException {
+ @Nullable Map<String, Long> msPartitionsToEventId, EventSequence catalogTimeline)
+ throws CatalogException {
List<HdfsPartition.Builder> addedPartBuilders = new ArrayList<>();
- FsPermissionCache permCache = preloadPermissionsCache(msPartitions);
+ FsPermissionCache permCache = preloadPermissionsCache(msPartitions, catalogTimeline);
for (org.apache.hadoop.hive.metastore.api.Partition partition: msPartitions) {
HdfsPartition.Builder partBuilder = createPartitionBuilder(partition.getSd(),
partition, permCache);
@@ -934,7 +948,8 @@ public class HdfsTable extends Table implements FeFsTable {
partBuilder.setCreateEventId(eventId);
addedPartBuilders.add(partBuilder);
}
- loadFileMetadataForPartitions(client, addedPartBuilders, /*isRefresh=*/false);
+ loadFileMetadataForPartitions(client, addedPartBuilders, /*isRefresh=*/false,
+ catalogTimeline);
return addedPartBuilders.stream()
.map(HdfsPartition.Builder::build)
.collect(Collectors.toList());
@@ -1189,28 +1204,11 @@ public class HdfsTable extends Table implements FeFsTable {
@Override
public void load(boolean reuseMetadata, IMetaStoreClient client,
- org.apache.hadoop.hive.metastore.api.Table msTbl, String reason)
- throws TableLoadingException {
+ org.apache.hadoop.hive.metastore.api.Table msTbl, String reason,
+ EventSequence catalogTimeline) throws TableLoadingException {
load(reuseMetadata, client, msTbl, /* loadPartitionFileMetadata */
true, /* loadTableSchema*/true, false,
- /* partitionsToUpdate*/null, null, null, reason);
- }
-
- public void load(boolean reuseMetadata, IMetaStoreClient client,
- org.apache.hadoop.hive.metastore.api.Table msTbl, boolean refreshUpdatedPartitions,
- String reason) throws TableLoadingException {
- load(reuseMetadata, client, msTbl, /* loadPartitionFileMetadata */
- true, /* loadTableSchema*/true, refreshUpdatedPartitions,
- /* partitionsToUpdate*/null, null, null, reason);
- }
-
- public void load(boolean reuseMetadata, IMetaStoreClient hiveClient,
- org.apache.hadoop.hive.metastore.api.Table msTbl,
- boolean refreshUpdatedPartitions, String debugAction, String reason)
- throws CatalogException {
- load(reuseMetadata, hiveClient, msTbl, /* loadPartitionFileMetadata */
- true, /* loadTableSchema*/true, refreshUpdatedPartitions,
- /* partitionsToUpdate*/null, debugAction, null, reason);
+ /* partitionsToUpdate*/null, null, null, reason, catalogTimeline);
}
/**
@@ -1242,7 +1240,7 @@ public class HdfsTable extends Table implements FeFsTable {
boolean loadPartitionFileMetadata, boolean loadTableSchema,
boolean refreshUpdatedPartitions, Set<String> partitionsToUpdate,
@Nullable String debugAction, @Nullable Map<String, Long> partitionToEventId,
- String reason) throws TableLoadingException {
+ String reason, EventSequence catalogTimeline) throws TableLoadingException {
final Timer.Context context =
getMetrics().getTimer(Table.LOAD_DURATION_METRIC).time();
String annotation = String.format("%s metadata for %s%s partition(s) of %s.%s (%s)",
@@ -1264,8 +1262,9 @@ public class HdfsTable extends Table implements FeFsTable {
nullPartitionKeyValue_ =
MetaStoreUtil.getNullPartitionKeyValue(client).intern();
loadSchema(msTbl);
- loadAllColumnStats(client);
+ loadAllColumnStats(client, catalogTimeline);
loadConstraintsInfo(client, msTbl);
+ catalogTimeline.markEvent("Loaded table schema");
}
loadValidWriteIdList(client);
// Set table-level stats first so partition stats can inherit it.
@@ -1279,14 +1278,15 @@ public class HdfsTable extends Table implements FeFsTable {
if (msTbl.getPartitionKeysSize() == 0) {
if (loadPartitionFileMetadata) {
storageMetadataLoadTime_ += updateUnpartitionedTableFileMd(client,
- debugAction);
+ debugAction, catalogTimeline);
} else { // Update the single partition stats in case table stats changes.
updateUnpartitionedTableStats();
}
} else {
storageMetadataLoadTime_ += updatePartitionsFromHms(
client, partitionsToUpdate, loadPartitionFileMetadata,
- refreshUpdatedPartitions, partitionToEventId, debugAction);
+ refreshUpdatedPartitions, partitionToEventId, debugAction,
+ catalogTimeline);
}
LOG.info("Incrementally loaded table metadata for: " + getFullName());
} else {
@@ -1298,10 +1298,11 @@ public class HdfsTable extends Table implements FeFsTable {
MetaStoreUtil.fetchAllPartitions(
client, msTbl, NUM_PARTITION_FETCH_RETRIES);
LOG.info("Fetched partition metadata from the Metastore: " + getFullName());
- storageMetadataLoadTime_ = loadAllPartitions(client, msPartitions, msTbl);
+ storageMetadataLoadTime_ = loadAllPartitions(client, msPartitions, msTbl,
+ catalogTimeline);
allPartitionsLdContext.stop();
}
- if (loadTableSchema) setAvroSchema(client, msTbl);
+ if (loadTableSchema) setAvroSchema(client, msTbl, catalogTimeline);
fileMetadataStats_.unset();
refreshLastUsedTime();
// Make sure all the partition modifications are done.
@@ -1324,12 +1325,6 @@ public class HdfsTable extends Table implements FeFsTable {
}
}
- public void load(IMetaStoreClient client,
- org.apache.hadoop.hive.metastore.api.Table msTbl, String reason)
- throws TableLoadingException {
- load(false, client, msTbl, true, true, false, null, null, null, reason);
- }
-
/**
* Load Primary Key and Foreign Key information for table. Throws TableLoadingException
* if the load fails. Declared as protected to allow third party extensions on this
@@ -1378,8 +1373,8 @@ public class HdfsTable extends Table implements FeFsTable {
* This is optimized for the case where few files have changed. See
* {@link FileMetadataLoader#load} for details.
*/
- private long updateUnpartitionedTableFileMd(IMetaStoreClient client, String debugAction)
- throws CatalogException {
+ private long updateUnpartitionedTableFileMd(IMetaStoreClient client, String debugAction,
+ EventSequence catalogTimeline) throws CatalogException {
Preconditions.checkState(getNumClusteringCols() == 0);
if (LOG.isTraceEnabled()) {
LOG.trace("update unpartitioned table: " + getFullName());
@@ -1399,7 +1394,7 @@ public class HdfsTable extends Table implements FeFsTable {
// partition instance to local catalog coordinators.
partBuilder.setPrevId(oldPartition.getId());
long fileMdLoadTime = loadFileMetadataForPartitions(client,
- ImmutableList.of(partBuilder), /*isRefresh=*/true, debugAction);
+ ImmutableList.of(partBuilder), /*isRefresh=*/true, debugAction, catalogTimeline);
// Step 2: update internal fields
resetPartitions();
setPrototypePartition(msTbl.getSd());
@@ -1435,7 +1430,7 @@ public class HdfsTable extends Table implements FeFsTable {
private long updatePartitionsFromHms(IMetaStoreClient client,
Set<String> partitionsToUpdate, boolean loadPartitionFileMetadata,
boolean refreshUpdatedPartitions, Map<String, Long> partitionToEventId,
- String debugAction) throws Exception {
+ String debugAction, EventSequence catalogTimeline) throws Exception {
if (LOG.isTraceEnabled()) LOG.trace("Sync table partitions: " + getFullName());
org.apache.hadoop.hive.metastore.api.Table msTbl = getMetaStoreTable();
Preconditions.checkNotNull(msTbl);
@@ -1445,10 +1440,10 @@ public class HdfsTable extends Table implements FeFsTable {
if (refreshUpdatedPartitions) {
deltaUpdater = new PartBasedDeltaUpdater(client,
loadPartitionFileMetadata, partitionsToUpdate, partitionToEventId,
- debugAction);
+ debugAction, catalogTimeline);
} else {
deltaUpdater = new PartNameBasedDeltaUpdater(client, loadPartitionFileMetadata,
- partitionsToUpdate, partitionToEventId, debugAction);
+ partitionsToUpdate, partitionToEventId, debugAction, catalogTimeline);
}
deltaUpdater.apply();
return deltaUpdater.loadTimeForFileMdNs_;
@@ -1474,15 +1469,17 @@ public class HdfsTable extends Table implements FeFsTable {
private final Set<String> partitionsToUpdate_;
private final String debugAction_;
protected final Map<String, Long> partitionToEventId_;
+ protected final EventSequence catalogTimeline_;
PartitionDeltaUpdater(IMetaStoreClient client, boolean loadPartitionFileMetadata,
Set<String> partitionsToUpdate, @Nullable Map<String, Long> partitionToEventId,
- String debugAction) {
+ String debugAction, EventSequence catalogTimeline) {
this.client_ = client;
this.loadFileMd_ = loadPartitionFileMetadata;
this.partitionsToUpdate_ = partitionsToUpdate;
this.debugAction_ = debugAction;
- partitionToEventId_ = partitionToEventId;
+ this.partitionToEventId_ = partitionToEventId;
+ this.catalogTimeline_ = catalogTimeline;
}
/**
@@ -1573,9 +1570,11 @@ public class HdfsTable extends Table implements FeFsTable {
partitionsToLoadFiles = parts.stream().map(HdfsPartition.Builder::new)
.collect(Collectors.toList());
}
- loadTimeForFileMdNs_ += loadFileMetadataForPartitions(client_,
- partitionsToLoadFiles,/* isRefresh=*/true, debugAction_);
- updatePartitions(partitionsToLoadFiles);
+ if (!partitionsToLoadFiles.isEmpty()) {
+ loadTimeForFileMdNs_ += loadFileMetadataForPartitions(client_,
+ partitionsToLoadFiles, /*isRefresh=*/true, debugAction_, catalogTimeline_);
+ updatePartitions(partitionsToLoadFiles);
+ }
}
}
@@ -1602,9 +1601,9 @@ public class HdfsTable extends Table implements FeFsTable {
public PartBasedDeltaUpdater(
IMetaStoreClient client, boolean loadPartitionFileMetadata,
Set<String> partitionsToUpdate, Map<String, Long> partitionToEventId,
- String debugAction) throws Exception {
+ String debugAction, EventSequence catalogTimeline) throws Exception {
super(client, loadPartitionFileMetadata, partitionsToUpdate, partitionToEventId,
- debugAction);
+ debugAction, catalogTimeline);
Stopwatch sw = Stopwatch.createStarted();
List<Partition> partitionList;
if (partitionsToUpdate != null) {
@@ -1675,7 +1674,8 @@ public class HdfsTable extends Table implements FeFsTable {
}
}
return loadPartitionsFromMetastore(newMsPartitions,
- /*inprogressPartBuilders=*/null, partitionToEventId_, client_);
+ /*inprogressPartBuilders=*/null, partitionToEventId_, client_,
+ catalogTimeline_);
}
@Override
@@ -1689,7 +1689,7 @@ public class HdfsTable extends Table implements FeFsTable {
// we pass partitionToEventId argument as null below because updated partitions
// partitions were preexisting before load and just modified from outside.
return loadPartitionsFromMetastore(updatedPartitions, updatedPartBuilders,
- null, client_);
+ null, client_, catalogTimeline_);
}
}
@@ -1706,9 +1706,9 @@ public class HdfsTable extends Table implements FeFsTable {
public PartNameBasedDeltaUpdater(
IMetaStoreClient client, boolean loadPartitionFileMetadata,
Set<String> partitionsToUpdate, Map<String, Long> partitionToEventId,
- String debugAction) throws Exception {
+ String debugAction, EventSequence catalogTimeline) throws Exception {
super(client, loadPartitionFileMetadata, partitionsToUpdate, partitionToEventId,
- debugAction);
+ debugAction, catalogTimeline);
// Retrieve all the partition names from the Hive Metastore. We need this to
// identify the delta between partitions of the local HdfsTable and the table entry
// in the Hive Metastore. Note: This is a relatively "cheap" operation
@@ -1735,7 +1735,8 @@ public class HdfsTable extends Table implements FeFsTable {
addedPartNames.addAll(Sets
.difference(partitionNamesFromHms_, knownPartitionNames));
return loadPartitionsFromMetastore(addedPartNames,
- /*inprogressPartBuilders=*/null, partitionToEventId_, client_);
+ /*inprogressPartBuilders=*/null, partitionToEventId_, client_,
+ catalogTimeline_);
}
@Override
@@ -1744,7 +1745,7 @@ public class HdfsTable extends Table implements FeFsTable {
// we pass partitionToEventId argument as null below because updated partitions
// partitions were preexisting before load and just modified from outside.
return loadPartitionsFromMetastore(updatedPartitionBuilders.keySet(),
- updatedPartitionBuilders, null, client_);
+ updatedPartitionBuilders, null, client_, catalogTimeline_);
}
}
@@ -1798,13 +1799,14 @@ public class HdfsTable extends Table implements FeFsTable {
* If so, calls setAvroSchemaInternal to set avroSchema_.
*/
protected void setAvroSchema(IMetaStoreClient client,
- org.apache.hadoop.hive.metastore.api.Table msTbl) throws Exception {
+ org.apache.hadoop.hive.metastore.api.Table msTbl, EventSequence catalogTimeline)
+ throws Exception {
Preconditions.checkState(isSchemaLoaded_);
String inputFormat = msTbl.getSd().getInputFormat();
String serDeLib = msTbl.getSd().getSerdeInfo().getSerializationLib();
if (HdfsFileFormat.fromJavaClassName(inputFormat, serDeLib) == HdfsFileFormat.AVRO
|| hasAvroData_) {
- setAvroSchemaInternal(client, msTable_);
+ setAvroSchemaInternal(client, msTable_, catalogTimeline);
}
}
@@ -1813,7 +1815,8 @@ public class HdfsTable extends Table implements FeFsTable {
* definitions from the metastore differ from the Avro schema.
*/
protected void setAvroSchemaInternal(IMetaStoreClient client,
- org.apache.hadoop.hive.metastore.api.Table msTbl) throws Exception {
+ org.apache.hadoop.hive.metastore.api.Table msTbl, EventSequence catalogTimeline)
+ throws Exception {
// Look for Avro schema in TBLPROPERTIES and in SERDEPROPERTIES, with the latter
// taking precedence.
List<Map<String, String>> schemaSearchLocations = new ArrayList<>();
@@ -1833,6 +1836,7 @@ public class HdfsTable extends Table implements FeFsTable {
// schema in the case of Avro-formatted tables. This has the side effect
// of promoting types like TINYINT to INT.
}
+ catalogTimeline.markEvent("Loaded avro schema");
String serdeLib = msTbl.getSd().getSerdeInfo().getSerializationLib();
if (serdeLib == null ||
serdeLib.equals("org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe")) {
@@ -1853,7 +1857,7 @@ public class HdfsTable extends Table implements FeFsTable {
addColumnsFromFieldSchemas(msTbl.getPartitionKeys());
addColumnsFromFieldSchemas(nonPartFieldSchemas_);
addVirtualColumns();
- loadAllColumnStats(client);
+ loadAllColumnStats(client, catalogTimeline);
}
}
@@ -1900,8 +1904,8 @@ public class HdfsTable extends Table implements FeFsTable {
*/
private long loadPartitionsFromMetastore(Set<String> partitionNames,
Map<String, HdfsPartition.Builder> inprogressPartBuilders,
- @Nullable Map<String, Long> partitionToEventId, IMetaStoreClient client)
- throws Exception {
+ @Nullable Map<String, Long> partitionToEventId, IMetaStoreClient client,
+ EventSequence catalogTimeline) throws Exception {
Preconditions.checkNotNull(partitionNames);
if (partitionNames.isEmpty()) return 0;
// Load partition metadata from Hive Metastore.
@@ -1909,14 +1913,14 @@ public class HdfsTable extends Table implements FeFsTable {
MetaStoreUtil.fetchPartitionsByName(
client, Lists.newArrayList(partitionNames), msTable_));
return loadPartitionsFromMetastore(msPartitions, inprogressPartBuilders,
- partitionToEventId, client);
+ partitionToEventId, client, catalogTimeline);
}
private long loadPartitionsFromMetastore(List<Partition> msPartitions,
Map<String, HdfsPartition.Builder> inprogressPartBuilders,
- @Nullable Map<String, Long> partitionToEventId, IMetaStoreClient client)
- throws Exception {
- FsPermissionCache permCache = preloadPermissionsCache(msPartitions);
+ @Nullable Map<String, Long> partitionToEventId, IMetaStoreClient client,
+ EventSequence catalogTimeline) throws Exception {
+ FsPermissionCache permCache = preloadPermissionsCache(msPartitions, catalogTimeline);
List<HdfsPartition.Builder> partBuilders = new ArrayList<>(msPartitions.size());
for (org.apache.hadoop.hive.metastore.api.Partition msPartition: msPartitions) {
String partName = FeCatalogUtils.getPartitionName(this, msPartition.getValues());
@@ -1934,8 +1938,9 @@ public class HdfsTable extends Table implements FeFsTable {
partBuilders.add(partBuilder);
}
long latestEventId = MetastoreEventsProcessor.getCurrentEventIdNoThrow(client);
+ catalogTimeline.markEvent(FETCHED_LATEST_HMS_EVENT_ID + latestEventId);
long fileMdLoadTime = loadFileMetadataForPartitions(client, partBuilders,
- /* isRefresh=*/false);
+ /* isRefresh=*/false, catalogTimeline);
for (HdfsPartition.Builder p : partBuilders) {
if (inprogressPartBuilders == null) {
addPartition(p.build());
@@ -1958,7 +1963,8 @@ public class HdfsTable extends Table implements FeFsTable {
* be in the same parent directories, and we can bulk fetch the permissions with a
* single round trip to the filesystem instead of individually looking up each.
*/
- private FsPermissionCache preloadPermissionsCache(List<Partition> msPartitions) {
+ private FsPermissionCache preloadPermissionsCache(List<Partition> msPartitions,
+ EventSequence catalogTimeline) {
FsPermissionCache permCache = new FsPermissionCache();
// Only preload permissions if the number of partitions to be added is
// large (3x) relative to the number of existing partitions. This covers
@@ -1972,7 +1978,8 @@ public class HdfsTable extends Table implements FeFsTable {
// potentially fetch a bunch of irrelevant information about existing
// partitions when we only want to know about a small number of newly-added
// partitions.
- if (msPartitions.size() < partitionMap_.size() * 3) return permCache;
+ // Using '<=' to skip unpartitioned tables, i.e. both sides are 0.
+ if (msPartitions.size() <= partitionMap_.size() * 3) return permCache;
// TODO(todd): when HDFS-13616 (batch listing of multiple directories)
// is implemented, we could likely implement this with a single round
@@ -2008,6 +2015,8 @@ public class HdfsTable extends Table implements FeFsTable {
LOG.debug("Unable to bulk-load permissions for parent path: " + p, ioe);
}
}
+ catalogTimeline.markEvent(String.format(
+ "Preloaded permissions cache for %d partitions", msPartitions.size()));
return permCache;
}
@@ -2827,17 +2836,6 @@ public class HdfsTable extends Table implements FeFsTable {
return result;
}
- /**
- * Reloads the HdfsPartitions which correspond to the given partNames. Returns the
- * number of partitions which were reloaded. This method also reloads file metadata
- * of all the partitions for the given partNames
- */
- public int reloadPartitionsFromNames(IMetaStoreClient client,
- List<String> partNames, String reason) throws CatalogException {
- return reloadPartitionsFromNames(client, partNames, reason,
- FileMetadataLoadOpts.FORCE_LOAD);
- }
-
/**
* Reloads the HdfsPartitions which correspond to the given partNames. Returns the
* number of partitions which were reloaded.
@@ -2860,7 +2858,8 @@ public class HdfsTable extends Table implements FeFsTable {
hmsPartToHdfsPart.put(partition, hdfsPartition);
}
}
- reloadPartitions(client, hmsPartToHdfsPart, fileMetadataLoadOpts);
+ reloadPartitions(client, hmsPartToHdfsPart, fileMetadataLoadOpts,
+ NoOpEventSequence.INSTANCE);
return hmsPartToHdfsPart.size();
} catch (NoSuchObjectException | InvalidObjectException e) {
// HMS throws a NoSuchObjectException if the table does not exist
@@ -2903,7 +2902,8 @@ public class HdfsTable extends Table implements FeFsTable {
hmsPartToHdfsPart.put(partition, hdfsPartition);
}
}
- reloadPartitions(client, hmsPartToHdfsPart, loadFileMetadata);
+ reloadPartitions(client, hmsPartToHdfsPart, loadFileMetadata,
+ NoOpEventSequence.INSTANCE);
return hmsPartToHdfsPart.size();
}
@@ -2920,12 +2920,14 @@ public class HdfsTable extends Table implements FeFsTable {
* reloaded.
*/
public void reloadPartitions(IMetaStoreClient client,
- Map<Partition, HdfsPartition> hmsPartsToHdfsParts, boolean loadFileMetadata)
- throws CatalogException {
+ Map<Partition, HdfsPartition> hmsPartsToHdfsParts, boolean loadFileMetadata,
+ EventSequence catalogTimeline) throws CatalogException {
if (loadFileMetadata) {
- reloadPartitions(client, hmsPartsToHdfsParts, FileMetadataLoadOpts.FORCE_LOAD);
+ reloadPartitions(client, hmsPartsToHdfsParts, FileMetadataLoadOpts.FORCE_LOAD,
+ catalogTimeline);
} else {
- reloadPartitions(client, hmsPartsToHdfsParts, FileMetadataLoadOpts.NO_LOAD);
+ reloadPartitions(client, hmsPartsToHdfsParts, FileMetadataLoadOpts.NO_LOAD,
+ catalogTimeline);
}
}
@@ -2942,13 +2944,15 @@ public class HdfsTable extends Table implements FeFsTable {
*/
public void reloadPartitions(IMetaStoreClient client,
Map<Partition, HdfsPartition> hmsPartsToHdfsParts,
- FileMetadataLoadOpts fileMetadataLoadOpts) throws CatalogException {
+ FileMetadataLoadOpts fileMetadataLoadOpts, EventSequence catalogTimeline)
+ throws CatalogException {
Preconditions.checkState(isWriteLockedByCurrentThread(), "Write Lock should be "
+ "held before reloadPartitions");
FsPermissionCache permissionCache = new FsPermissionCache();
Map<HdfsPartition.Builder, HdfsPartition> partBuilderToPartitions = new HashMap<>();
Set<HdfsPartition.Builder> partBuildersFileMetadataRefresh = new HashSet<>();
long latestEventId = MetastoreEventsProcessor.getCurrentEventIdNoThrow(client);
+ catalogTimeline.markEvent(FETCHED_LATEST_HMS_EVENT_ID + latestEventId);
for (Map.Entry<Partition, HdfsPartition> entry : hmsPartsToHdfsParts.entrySet()) {
Partition hmsPartition = entry.getKey();
HdfsPartition oldPartition = entry.getValue();
@@ -2991,7 +2995,7 @@ public class HdfsTable extends Table implements FeFsTable {
partBuilderToPartitions.size());
// load file metadata in parallel
loadFileMetadataForPartitions(client, partBuildersFileMetadataRefresh,
- /*isRefresh=*/true);
+ /*isRefresh=*/true, catalogTimeline);
}
for (Map.Entry<HdfsPartition.Builder, HdfsPartition> entry :
partBuilderToPartitions.entrySet()) {
diff --git a/fe/src/main/java/org/apache/impala/catalog/IcebergTable.java b/fe/src/main/java/org/apache/impala/catalog/IcebergTable.java
index 6aedc0bd1..37a75ee0c 100644
--- a/fe/src/main/java/org/apache/impala/catalog/IcebergTable.java
+++ b/fe/src/main/java/org/apache/impala/catalog/IcebergTable.java
@@ -52,6 +52,7 @@ import org.apache.impala.thrift.TPartialPartitionInfo;
import org.apache.impala.thrift.TTable;
import org.apache.impala.thrift.TTableDescriptor;
import org.apache.impala.thrift.TTableType;
+import org.apache.impala.util.EventSequence;
import org.apache.impala.util.IcebergSchemaConverter;
import org.apache.impala.util.IcebergUtil;
import org.apache.thrift.TException;
@@ -381,8 +382,8 @@ public class IcebergTable extends Table implements FeIcebergTable {
*/
@Override
public void load(boolean reuseMetadata, IMetaStoreClient msClient,
- org.apache.hadoop.hive.metastore.api.Table msTbl, String reason)
- throws TableLoadingException {
+ org.apache.hadoop.hive.metastore.api.Table msTbl, String reason,
+ EventSequence catalogTimeline) throws TableLoadingException {
final Timer.Context context =
getMetrics().getTimer(Table.LOAD_DURATION_METRIC).time();
verifyTable(msTbl);
@@ -399,8 +400,10 @@ public class IcebergTable extends Table implements FeIcebergTable {
getMetrics().getTimer(Table.LOAD_DURATION_STORAGE_METADATA).time();
try {
icebergApiTable_ = IcebergUtil.loadTable(this);
+ catalogTimeline.markEvent("Loaded Iceberg API table");
catalogSnapshotId_ = FeIcebergTable.super.snapshotId();
loadSchemaFromIceberg();
+ catalogTimeline.markEvent("Loaded schema from Iceberg");
// Loading hdfs table after loaded schema from Iceberg,
// in case we create external Iceberg table skipping column info in sql.
icebergFileFormat_ = IcebergUtil.getIcebergFileFormat(msTbl);
@@ -410,15 +413,16 @@ public class IcebergTable extends Table implements FeIcebergTable {
icebergParquetDictPageSize_ = Utils.getIcebergParquetDictPageSize(msTbl);
GroupedContentFiles icebergFiles = IcebergUtil.getIcebergFiles(this,
new ArrayList<>(), /*timeTravelSpec=*/null);
+ catalogTimeline.markEvent("Loaded Iceberg files");
hdfsTable_.setIcebergFiles(icebergFiles);
hdfsTable_.setCanDataBeOutsideOfTableLocation(
!Utils.requiresDataFilesInTableLocation(this));
- hdfsTable_.load(reuseMetadata, msClient, msTable_, reason);
+ hdfsTable_.load(reuseMetadata, msClient, msTable_, reason, catalogTimeline);
fileStore_ = Utils.loadAllPartition(this, icebergFiles);
partitionStats_ = Utils.loadPartitionStats(this, icebergFiles);
setIcebergTableStats();
- loadAllColumnStats(msClient);
- setAvroSchema(msClient, msTbl, fileStore_);
+ loadAllColumnStats(msClient, catalogTimeline);
+ setAvroSchema(msClient, msTbl, fileStore_, catalogTimeline);
} catch (Exception e) {
throw new IcebergTableLoadingException("Error loading metadata for Iceberg table "
+ icebergTableLocation_, e);
@@ -439,6 +443,7 @@ public class IcebergTable extends Table implements FeIcebergTable {
msTable_.putToParameters(StatsSetupConst.DO_NOT_UPDATE_STATS,
StatsSetupConst.TRUE);
msClient.alter_table(msTable_.getDbName(), msTable_.getTableName(), msTable_);
+ catalogTimeline.markEvent("Updated table schema in Metastore");
} catch (TException e) {
throw new TableLoadingException(e.getMessage());
}
@@ -504,9 +509,9 @@ public class IcebergTable extends Table implements FeIcebergTable {
*/
private void setAvroSchema(IMetaStoreClient msClient,
org.apache.hadoop.hive.metastore.api.Table msTbl,
- IcebergContentFileStore fileStore) throws Exception {
+ IcebergContentFileStore fileStore, EventSequence catalogTimeline) throws Exception {
if (fileStore.hasAvro()) {
- hdfsTable_.setAvroSchemaInternal(msClient, msTbl);
+ hdfsTable_.setAvroSchemaInternal(msClient, msTbl, catalogTimeline);
}
}
diff --git a/fe/src/main/java/org/apache/impala/catalog/IncompleteTable.java b/fe/src/main/java/org/apache/impala/catalog/IncompleteTable.java
index 04a962fc3..338cc7e67 100644
--- a/fe/src/main/java/org/apache/impala/catalog/IncompleteTable.java
+++ b/fe/src/main/java/org/apache/impala/catalog/IncompleteTable.java
@@ -37,6 +37,7 @@ import org.apache.impala.thrift.TTableType;
import com.google.common.base.Joiner;
import com.google.common.base.Throwables;
import com.google.common.collect.Lists;
+import org.apache.impala.util.EventSequence;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -103,8 +104,8 @@ public class IncompleteTable extends Table implements FeIncompleteTable {
@Override
public void load(boolean reuseMetadata, IMetaStoreClient client,
- org.apache.hadoop.hive.metastore.api.Table msTbl, String reason)
- throws TableLoadingException {
+ org.apache.hadoop.hive.metastore.api.Table msTbl, String reason,
+ EventSequence catalogTimeline) throws TableLoadingException {
if (cause_ instanceof TableLoadingException) {
throw (TableLoadingException) cause_;
} else {
diff --git a/fe/src/main/java/org/apache/impala/catalog/KuduTable.java b/fe/src/main/java/org/apache/impala/catalog/KuduTable.java
index 76fbb7e0f..e141daebc 100644
--- a/fe/src/main/java/org/apache/impala/catalog/KuduTable.java
+++ b/fe/src/main/java/org/apache/impala/catalog/KuduTable.java
@@ -42,6 +42,7 @@ import org.apache.impala.thrift.TKuduTable;
import org.apache.impala.thrift.TTable;
import org.apache.impala.thrift.TTableDescriptor;
import org.apache.impala.thrift.TTableType;
+import org.apache.impala.util.EventSequence;
import org.apache.impala.util.KuduUtil;
import org.apache.kudu.ColumnSchema;
import org.apache.kudu.Schema;
@@ -56,6 +57,8 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
+import static org.apache.impala.service.KuduCatalogOpExecutor.OPENED_KUDU_TABLE;
+
/**
* Representation of a Kudu table in the catalog cache.
*/
@@ -296,16 +299,18 @@ public class KuduTable extends Table implements FeKuduTable {
/**
* Load schema and partitioning schemes directly from Kudu.
*/
- public void loadSchemaFromKudu() throws ImpalaRuntimeException {
+ public void loadSchemaFromKudu(EventSequence catalogTimeline)
+ throws ImpalaRuntimeException {
// This is set to 0 for Kudu tables.
// TODO: Change this to reflect the number of pk columns and modify all the
// places (e.g. insert stmt) that currently make use of this parameter.
numClusteringCols_ = 0;
org.apache.kudu.client.KuduTable kuduTable = null;
// Connect to Kudu to retrieve table metadata
- KuduClient kuduClient = KuduUtil.getKuduClient(getKuduMasterHosts());
+ KuduClient kuduClient = KuduUtil.getKuduClient(getKuduMasterHosts(), catalogTimeline);
try {
kuduTable = kuduClient.openTable(kuduTableName_);
+ catalogTimeline.markEvent(OPENED_KUDU_TABLE);
} catch (KuduException e) {
throw new ImpalaRuntimeException(
String.format("Error opening Kudu table '%s', Kudu error: %s", kuduTableName_,
@@ -316,6 +321,7 @@ public class KuduTable extends Table implements FeKuduTable {
loadSchema(kuduTable);
Preconditions.checkState(!colsByPos_.isEmpty());
partitionBy_ = Utils.loadPartitionByParams(kuduTable);
+ catalogTimeline.markEvent("Loaded Kudu table schema");
}
/**
@@ -327,8 +333,8 @@ public class KuduTable extends Table implements FeKuduTable {
*/
@Override
public void load(boolean dummy /* not used */, IMetaStoreClient msClient,
- org.apache.hadoop.hive.metastore.api.Table msTbl, String reason)
- throws TableLoadingException {
+ org.apache.hadoop.hive.metastore.api.Table msTbl, String reason,
+ EventSequence catalogTimeline) throws TableLoadingException {
final Timer.Context context =
getMetrics().getTimer(Table.LOAD_DURATION_METRIC).time();
Table.LOADING_TABLES.incrementAndGet();
@@ -346,7 +352,7 @@ public class KuduTable extends Table implements FeKuduTable {
final Timer.Context ctxStorageLdTime =
getMetrics().getTimer(Table.LOAD_DURATION_STORAGE_METADATA).time();
try {
- loadSchemaFromKudu();
+ loadSchemaFromKudu(catalogTimeline);
} catch (ImpalaRuntimeException e) {
throw new TableLoadingException("Error loading metadata for Kudu table " +
kuduTableName_, e);
@@ -354,7 +360,7 @@ public class KuduTable extends Table implements FeKuduTable {
storageMetadataLoadTime_ = ctxStorageLdTime.stop();
}
// Load from HMS
- loadAllColumnStats(msClient);
+ loadAllColumnStats(msClient, catalogTimeline);
refreshLastUsedTime();
// Avoid updating HMS if the schema didn't change.
if (msTable_.equals(msTbl)) return;
@@ -368,6 +374,7 @@ public class KuduTable extends Table implements FeKuduTable {
msTable_.putToParameters(StatsSetupConst.DO_NOT_UPDATE_STATS,
StatsSetupConst.TRUE);
msClient.alter_table(msTable_.getDbName(), msTable_.getTableName(), msTable_);
+ catalogTimeline.markEvent("Updated table schema in Metastore");
} catch (TException e) {
throw new TableLoadingException(e.getMessage());
}
diff --git a/fe/src/main/java/org/apache/impala/catalog/MaterializedViewHdfsTable.java b/fe/src/main/java/org/apache/impala/catalog/MaterializedViewHdfsTable.java
index 07d7d4c34..f2d0a2038 100644
--- a/fe/src/main/java/org/apache/impala/catalog/MaterializedViewHdfsTable.java
+++ b/fe/src/main/java/org/apache/impala/catalog/MaterializedViewHdfsTable.java
@@ -26,6 +26,7 @@ import org.apache.impala.authorization.TableMask;
import org.apache.impala.authorization.User;
import org.apache.impala.common.InternalException;
import org.apache.impala.thrift.TTable;
+import org.apache.impala.util.EventSequence;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -87,9 +88,9 @@ public class MaterializedViewHdfsTable extends HdfsTable {
@Override
public void load(boolean reuseMetadata, IMetaStoreClient client,
- org.apache.hadoop.hive.metastore.api.Table msTbl, String reason)
- throws TableLoadingException {
- super.load(reuseMetadata, client, msTbl, reason);
+ org.apache.hadoop.hive.metastore.api.Table msTbl, String reason,
+ EventSequence catalogTimeline) throws TableLoadingException {
+ super.load(reuseMetadata, client, msTbl, reason, catalogTimeline);
initQueryStmt();
}
diff --git a/fe/src/main/java/org/apache/impala/catalog/Table.java b/fe/src/main/java/org/apache/impala/catalog/Table.java
index 6299dfc89..09c5086e0 100644
--- a/fe/src/main/java/org/apache/impala/catalog/Table.java
+++ b/fe/src/main/java/org/apache/impala/catalog/Table.java
@@ -60,6 +60,7 @@ import org.apache.impala.thrift.TTableInfoSelector;
import org.apache.impala.thrift.TTableStats;
import org.apache.impala.thrift.TTableType;
import org.apache.impala.util.AcidUtils;
+import org.apache.impala.util.EventSequence;
import org.apache.impala.util.HdfsCachingUtil;
import com.codahale.metrics.Gauge;
@@ -434,8 +435,8 @@ public abstract class Table extends CatalogObjectImpl implements FeTable {
* valid existing metadata.
*/
public abstract void load(boolean reuseMetadata, IMetaStoreClient client,
- org.apache.hadoop.hive.metastore.api.Table msTbl, String reason)
- throws TableLoadingException;
+ org.apache.hadoop.hive.metastore.api.Table msTbl, String reason,
+ EventSequence catalogTimeline) throws TableLoadingException;
/**
* Sets 'tableStats_' by extracting the table statistics from the given HMS table.
@@ -488,7 +489,8 @@ public abstract class Table extends CatalogObjectImpl implements FeTable {
* errors are logged and ignored, since the absence of column stats is not critical to
* the correctness of the system.
*/
- protected void loadAllColumnStats(IMetaStoreClient client) {
+ protected void loadAllColumnStats(IMetaStoreClient client,
+ EventSequence catalogTimeline) {
final Timer.Context columnStatsLdContext =
getMetrics().getTimer(LOAD_DURATION_ALL_COLUMN_STATS).time();
try {
@@ -509,6 +511,7 @@ public abstract class Table extends CatalogObjectImpl implements FeTable {
return;
}
FeCatalogUtils.injectColumnStats(colStats, this, testStats_);
+ catalogTimeline.markEvent("Loaded all column stats");
} finally {
columnStatsLdContext.stop();
}
diff --git a/fe/src/main/java/org/apache/impala/catalog/TableLoader.java b/fe/src/main/java/org/apache/impala/catalog/TableLoader.java
index 6ccae1fe1..79b388cb5 100644
--- a/fe/src/main/java/org/apache/impala/catalog/TableLoader.java
+++ b/fe/src/main/java/org/apache/impala/catalog/TableLoader.java
@@ -31,6 +31,7 @@ import org.apache.impala.catalog.events.MetastoreEventsProcessor;
import org.apache.impala.common.Metrics;
import org.apache.impala.compat.MetastoreShim;
import org.apache.impala.service.BackendConfig;
+import org.apache.impala.util.EventSequence;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.thrift.TException;
@@ -40,6 +41,9 @@ import com.google.common.base.Stopwatch;
import org.apache.impala.catalog.MetaStoreClientPool.MetaStoreClient;
import org.apache.impala.util.ThreadNameAnnotator;
+import static org.apache.impala.service.CatalogOpExecutor.FETCHED_HMS_EVENT_BATCH;
+import static org.apache.impala.service.CatalogOpExecutor.FETCHED_HMS_TABLE;
+
/**
* Class that implements the logic for how a table's metadata should be loaded from
* the Hive Metastore / HDFS / etc.
@@ -69,7 +73,8 @@ public class TableLoader {
* Returns new instance of Table, If there were any errors loading the table metadata
* an IncompleteTable will be returned that contains details on the error.
*/
- public Table load(Db db, String tblName, long eventId, String reason) {
+ public Table load(Db db, String tblName, long eventId, String reason,
+ EventSequence catalogTimeline) {
Stopwatch sw = Stopwatch.createStarted();
String fullTblName = db.getName() + "." + tblName;
String annotation = "Loading metadata for: " + fullTblName + " (" + reason + ")";
@@ -80,12 +85,13 @@ public class TableLoader {
// turn all exceptions into TableLoadingException
List<NotificationEvent> events = null;
try (ThreadNameAnnotator tna = new ThreadNameAnnotator(annotation);
- MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
org.apache.hadoop.hive.metastore.api.Table msTbl = null;
// All calls to getTable() need to be serialized due to HIVE-5457.
Stopwatch hmsLoadSW = Stopwatch.createStarted();
synchronized (metastoreAccessLock_) {
msTbl = msClient.getHiveClient().getTable(db.getName(), tblName);
+ catalogTimeline.markEvent(FETCHED_HMS_TABLE);
}
if (eventId != -1 && catalog_.isEventProcessingActive()) {
// If the eventId is not -1 it means this table was likely created by Impala.
@@ -100,6 +106,7 @@ public class TableLoader {
.equals(notificationEvent.getEventType())
&& notificationEvent.getDbName().equalsIgnoreCase(db.getName())
&& notificationEvent.getTableName().equalsIgnoreCase(tblName));
+ catalogTimeline.markEvent(FETCHED_HMS_EVENT_BATCH);
}
if (events != null && !events.isEmpty()) {
// if the table was recreated after the table was initially created in the
@@ -127,7 +134,7 @@ public class TableLoader {
if (syncToLatestEventId) {
// acquire write lock on table since MetastoreEventProcessor.syncToLatestEventId
// expects current thread to have write lock on the table
- if (!catalog_.tryWriteLock(table)) {
+ if (!catalog_.tryWriteLock(table, catalogTimeline)) {
throw new CatalogException("Couldn't acquire write lock on new table object"
+ " created when doing a full table reload of " + table.getFullName());
}
@@ -140,8 +147,7 @@ public class TableLoader {
+ "while loading table: " + table.getFullName(), e);
}
}
-
- table.load(false, msClient.getHiveClient(), msTbl, reason);
+ table.load(false, msClient.getHiveClient(), msTbl, reason, catalogTimeline);
table.validate();
if (syncToLatestEventId) {
LOG.debug("After full reload, table {} is synced atleast till event id {}. "
diff --git a/fe/src/main/java/org/apache/impala/catalog/TableLoadingMgr.java b/fe/src/main/java/org/apache/impala/catalog/TableLoadingMgr.java
index cb9ec2df5..08de02566 100644
--- a/fe/src/main/java/org/apache/impala/catalog/TableLoadingMgr.java
+++ b/fe/src/main/java/org/apache/impala/catalog/TableLoadingMgr.java
@@ -32,7 +32,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.impala.common.Pair;
import org.apache.impala.thrift.TTableName;
+import org.apache.impala.util.EventSequence;
import org.apache.impala.util.HdfsCachingUtil;
+import org.apache.impala.util.NoOpEventSequence;
import org.apache.log4j.Logger;
import com.google.common.base.Preconditions;
@@ -234,7 +236,7 @@ public class TableLoadingMgr {
* loads of the same table.
*/
public LoadRequest loadAsync(final TTableName tblName, final long createdEventId,
- final String reason)
+ final String reason, final EventSequence catalogTimeline)
throws DatabaseNotFoundException {
final Db parentDb = catalog_.getDb(tblName.getDb_name());
if (parentDb == null) {
@@ -245,7 +247,9 @@ public class TableLoadingMgr {
FutureTask<Table> tableLoadTask = new FutureTask<Table>(new Callable<Table>() {
@Override
public Table call() throws Exception {
- return tblLoader_.load(parentDb, tblName.table_name, createdEventId, reason);
+ catalogTimeline.markEvent("Start loading table");
+ return tblLoader_.load(parentDb, tblName.table_name, createdEventId, reason,
+ catalogTimeline);
}});
FutureTask<Table> existingValue = loadingTables_.putIfAbsent(tblName, tableLoadTask);
@@ -331,7 +335,7 @@ public class TableLoadingMgr {
try {
Table tbl = catalog_.getTable(tblName.getDb_name(), tblName.getTable_name());
if (tbl == null || tbl instanceof IncompleteTable || !tbl.isLoaded()) return;
- catalog_.reloadTable(tbl, reason);
+ catalog_.reloadTable(tbl, reason, NoOpEventSequence.INSTANCE);
} catch (CatalogException e) {
LOG.error("Error reloading cached table: ", e);
}
diff --git a/fe/src/main/java/org/apache/impala/catalog/View.java b/fe/src/main/java/org/apache/impala/catalog/View.java
index c12f34c63..abab84738 100644
--- a/fe/src/main/java/org/apache/impala/catalog/View.java
+++ b/fe/src/main/java/org/apache/impala/catalog/View.java
@@ -32,6 +32,7 @@ import org.apache.impala.thrift.TTable;
import org.apache.impala.thrift.TTableDescriptor;
import org.apache.impala.thrift.TTableStats;
import org.apache.impala.thrift.TTableType;
+import org.apache.impala.util.EventSequence;
import com.google.common.collect.Lists;
@@ -83,8 +84,8 @@ public class View extends Table implements FeView {
@Override
public void load(boolean reuseMetadata, IMetaStoreClient client,
- org.apache.hadoop.hive.metastore.api.Table msTbl, String reason)
- throws TableLoadingException {
+ org.apache.hadoop.hive.metastore.api.Table msTbl, String reason,
+ EventSequence catalogTimeline) throws TableLoadingException {
try {
Table.LOADING_TABLES.incrementAndGet();
clearColumns();
diff --git a/fe/src/main/java/org/apache/impala/catalog/events/MetastoreEvents.java b/fe/src/main/java/org/apache/impala/catalog/events/MetastoreEvents.java
index 1aa8b682a..d5324004b 100644
--- a/fe/src/main/java/org/apache/impala/catalog/events/MetastoreEvents.java
+++ b/fe/src/main/java/org/apache/impala/catalog/events/MetastoreEvents.java
@@ -82,7 +82,9 @@ import org.apache.impala.thrift.TPartitionKeyValue;
import org.apache.impala.thrift.TTableName;
import org.apache.impala.util.AcidUtils;
import org.apache.impala.util.DebugUtils;
+import org.apache.impala.util.EventSequence;
import org.apache.impala.util.MetaStoreUtil;
+import org.apache.impala.util.NoOpEventSequence;
import org.slf4j.LoggerFactory;
import org.slf4j.Logger;
@@ -1847,7 +1849,7 @@ public class MetastoreEvents {
// No-Op
} else if (getEventId() > tbl.getCreateEventId()) {
catalog_.invalidateTable(tbl.getTableName().toThrift(),
- new Reference<>(), new Reference<>());
+ new Reference<>(), new Reference<>(), NoOpEventSequence.INSTANCE);
LOG.info("Table " + tbl.getFullName() + " is invalidated from catalog cache" +
" since eventSync is turned on for this table.");
} else {
@@ -3086,7 +3088,7 @@ public class MetastoreEvents {
return ;
}
catalog_.invalidateTable(tbl.getTableName().toThrift(),
- tblWasRemoved, dbWasAdded);
+ tblWasRemoved, dbWasAdded, NoOpEventSequence.INSTANCE);
LOG.info("Table " + tbl.getFullName() + " is invalidated from catalog cache");
}
}
diff --git a/fe/src/main/java/org/apache/impala/catalog/events/MetastoreEventsProcessor.java b/fe/src/main/java/org/apache/impala/catalog/events/MetastoreEventsProcessor.java
index 4a2a4b38f..09b931326 100644
--- a/fe/src/main/java/org/apache/impala/catalog/events/MetastoreEventsProcessor.java
+++ b/fe/src/main/java/org/apache/impala/catalog/events/MetastoreEventsProcessor.java
@@ -64,6 +64,7 @@ import org.apache.impala.service.CatalogOpExecutor;
import org.apache.impala.thrift.TEventProcessorMetrics;
import org.apache.impala.thrift.TEventProcessorMetricsSummaryResponse;
import org.apache.impala.util.MetaStoreUtil;
+import org.apache.impala.util.NoOpEventSequence;
import org.apache.impala.util.ThreadNameAnnotator;
import org.apache.thrift.TException;
import org.slf4j.Logger;
@@ -1009,7 +1010,7 @@ public class MetastoreEventsProcessor implements ExternalEventsProcessor {
|| (currentStatus == EventProcessorStatus.NEEDS_INVALIDATE))) {
try {
LOG.error("Triggering auto global invalidation");
- catalog_.reset();
+ catalog_.reset(NoOpEventSequence.INSTANCE);
eventProcessorErrorMsg_ = null;
} catch (Exception e) {
// Catching generic exception so that scheduler thread does not die silently
diff --git a/fe/src/main/java/org/apache/impala/catalog/metastore/CatalogMetastoreServiceHandler.java b/fe/src/main/java/org/apache/impala/catalog/metastore/CatalogMetastoreServiceHandler.java
index 57a212671..a5b2114c7 100644
--- a/fe/src/main/java/org/apache/impala/catalog/metastore/CatalogMetastoreServiceHandler.java
+++ b/fe/src/main/java/org/apache/impala/catalog/metastore/CatalogMetastoreServiceHandler.java
@@ -72,6 +72,8 @@ import org.apache.impala.service.CatalogOpExecutor;
import org.apache.impala.service.MetadataOp;
import org.apache.impala.thrift.TImpalaTableType;
import org.apache.impala.thrift.TTableName;
+import org.apache.impala.util.EventSequence;
+import org.apache.impala.util.NoOpEventSequence;
import org.apache.thrift.TException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -873,8 +875,11 @@ public class CatalogMetastoreServiceHandler extends MetastoreServiceHandler {
try {
String sourceDb = MetaStoreUtils.parseDbName(sourceDbWithCatalog, serverConf_)[1];
String destDb = MetaStoreUtils.parseDbName(destDbWithCatalog, serverConf_)[1];
- srcTbl = catalogOpExecutor_.getExistingTable(sourceDb, sourceTbl, apiName);
- destinationTbl = catalogOpExecutor_.getExistingTable(destDb, destTbl, apiName);
+ EventSequence catalogTimeline = NoOpEventSequence.INSTANCE;
+ srcTbl = catalogOpExecutor_.getExistingTable(sourceDb, sourceTbl, apiName,
+ catalogTimeline);
+ destinationTbl = catalogOpExecutor_.getExistingTable(destDb, destTbl, apiName,
+ catalogTimeline);
if (!catalog_.tryWriteLock(
new org.apache.impala.catalog.Table[] {srcTbl, destinationTbl})) {
@@ -917,8 +922,11 @@ public class CatalogMetastoreServiceHandler extends MetastoreServiceHandler {
try {
String sourceDb = MetaStoreUtils.parseDbName(sourceDbWithCatalog, serverConf_)[1];
String destDb = MetaStoreUtils.parseDbName(destDbWithCatalog, serverConf_)[1];
- srcTbl = catalogOpExecutor_.getExistingTable(sourceDb, sourceTbl, apiName);
- destinationTbl = catalogOpExecutor_.getExistingTable(destDb, destTbl, apiName);
+ EventSequence catalogTimeline = NoOpEventSequence.INSTANCE;
+ srcTbl = catalogOpExecutor_.getExistingTable(sourceDb, sourceTbl, apiName,
+ catalogTimeline);
+ destinationTbl = catalogOpExecutor_.getExistingTable(destDb, destTbl, apiName,
+ catalogTimeline);
if (!catalog_.tryWriteLock(
new org.apache.impala.catalog.Table[] {srcTbl, destinationTbl})) {
@@ -1212,7 +1220,8 @@ public class CatalogMetastoreServiceHandler extends MetastoreServiceHandler {
org.apache.impala.catalog.Table tbl = null;
try {
String dbName = MetaStoreUtils.parseDbName(dbNameWithCatalog, serverConf_)[1];
- tbl = catalogOpExecutor_.getExistingTable(dbName, tblName, apiName);
+ tbl = catalogOpExecutor_.getExistingTable(dbName, tblName, apiName,
+ NoOpEventSequence.INSTANCE);
} catch (Exception e) {
rethrowException(e, apiName);
}
diff --git a/fe/src/main/java/org/apache/impala/service/CatalogOpExecutor.java b/fe/src/main/java/org/apache/impala/service/CatalogOpExecutor.java
index 1e5aa1802..e8be33988 100644
--- a/fe/src/main/java/org/apache/impala/service/CatalogOpExecutor.java
+++ b/fe/src/main/java/org/apache/impala/service/CatalogOpExecutor.java
@@ -18,6 +18,7 @@
package org.apache.impala.service;
import static org.apache.impala.analysis.Analyzer.ACCESSTYPE_READWRITE;
+import static org.apache.impala.catalog.CatalogServiceCatalog.TABLE_ID_UNAVAILABLE;
import com.codahale.metrics.Timer;
import com.google.common.annotations.VisibleForTesting;
@@ -255,6 +256,7 @@ import org.apache.impala.util.IcebergUtil;
import org.apache.impala.util.KuduUtil;
import org.apache.impala.util.MetaStoreUtil;
import org.apache.impala.util.MetaStoreUtil.TableInsertEventInfo;
+import org.apache.impala.util.NoOpEventSequence;
import org.apache.impala.util.ThreadNameAnnotator;
import org.apache.thrift.TException;
import org.slf4j.Logger;
@@ -372,6 +374,7 @@ public class CatalogOpExecutor {
public static final String CAPABILITIES_KEY = "OBJCAPABILITIES";
// Labels used in catalog timelines
+ private static final String CATALOG_TIMELINE_NAME = "Catalog Server Operation";
private static final String CHECKED_HMS_TABLE_EXISTENCE =
"Checked table existence in Metastore";
private static final String CREATED_HMS_TABLE = "Created table in Metastore";
@@ -379,13 +382,17 @@ public class CatalogOpExecutor {
private static final String CREATED_ICEBERG_TABLE =
"Created table using Iceberg Catalog ";
private static final String DDL_FINISHED = "DDL finished";
- private static final String FETCHED_LATEST_HMS_EVENT_ID =
+ public static final String FETCHED_LATEST_HMS_EVENT_ID =
"Got current Metastore event id ";
- private static final String FETCHED_HMS_EVENT_BATCH =
+ public static final String FETCHED_HMS_EVENT_BATCH =
"Fetched event batch from Metastore";
- private static final String FETCHED_HMS_TABLE = "Fetched table from Metastore";
+ public static final String FETCHED_HMS_TABLE = "Fetched table from Metastore";
+ public static final String FETCHED_HMS_DB = "Fetched database from Metastore";
+ public static final String FETCHED_HMS_PARTITION = "Fetched partition from Metastore";
private static final String GOT_METASTORE_DDL_LOCK = "Got metastoreDdlLock";
- private static final String GOT_TABLE_WRITE_LOCK = "Got table write lock";
+ public static final String GOT_TABLE_WRITE_LOCK =
+ "Got catalog version write lock and table write lock";
+ public static final String GOT_TABLE_READ_LOCK = "Got table read lock";
private static final String LOADED_ICEBERG_TABLE = "Loaded iceberg table";
private static final String SENT_CATALOG_FOR_SYNC_DDL =
"Sent catalog update for sync_ddl";
@@ -419,7 +426,7 @@ public class CatalogOpExecutor {
public TDdlExecResponse execDdlRequest(TDdlExecRequest ddlRequest)
throws ImpalaException {
- EventSequence catalogTimeline = new EventSequence("Catalog Server Operation");
+ EventSequence catalogTimeline = new EventSequence(CATALOG_TIMELINE_NAME);
TDdlExecResponse response = new TDdlExecResponse();
response.setResult(new TCatalogUpdateResult());
response.getResult().setCatalog_service_id(JniCatalog.getServiceId());
@@ -443,26 +450,27 @@ public class CatalogOpExecutor {
TAlterDbParams alter_db_params = ddlRequest.getAlter_db_params();
tTableName = Optional.of(new TTableName(alter_db_params.db, ""));
catalogOpTracker_.increment(ddlRequest, tTableName);
- alterDatabase(alter_db_params, wantMinimalResult, response);
+ alterDatabase(alter_db_params, wantMinimalResult, response, catalogTimeline);
break;
case ALTER_TABLE:
TAlterTableParams alter_table_params = ddlRequest.getAlter_table_params();
tTableName = Optional.of(alter_table_params.getTable_name());
catalogOpTracker_.increment(ddlRequest, tTableName);
alterTable(alter_table_params, ddlRequest.getQuery_options().getDebug_action(),
- wantMinimalResult, response);
+ wantMinimalResult, response, catalogTimeline);
break;
case ALTER_VIEW:
TCreateOrAlterViewParams alter_view_params = ddlRequest.getAlter_view_params();
tTableName = Optional.of(alter_view_params.getView_name());
catalogOpTracker_.increment(ddlRequest, tTableName);
- alterView(alter_view_params, wantMinimalResult, response);
+ alterView(alter_view_params, wantMinimalResult, response, catalogTimeline);
break;
case CREATE_DATABASE:
TCreateDbParams create_db_params = ddlRequest.getCreate_db_params();
tTableName = Optional.of(new TTableName(create_db_params.db, ""));
catalogOpTracker_.increment(ddlRequest, tTableName);
- createDatabase(create_db_params, response, syncDdl, wantMinimalResult);
+ createDatabase(create_db_params, response, catalogTimeline, syncDdl,
+ wantMinimalResult);
break;
case CREATE_TABLE_AS_SELECT:
TCreateTableParams create_table_as_select_params =
@@ -499,7 +507,7 @@ public class CatalogOpExecutor {
TFunctionName fnName = create_func_params.getFn().getName();
tTableName = Optional.of(new TTableName(fnName.db_name, fnName.function_name));
catalogOpTracker_.increment(ddlRequest, tTableName);
- createFunction(create_func_params, response);
+ createFunction(ddlRequest.getCreate_fn_params(), response, catalogTimeline);
break;
case CREATE_DATA_SOURCE:
TCreateDataSourceParams create_ds_params =
@@ -516,14 +524,15 @@ public class CatalogOpExecutor {
TDropStatsParams drop_stats_params = ddlRequest.getDrop_stats_params();
tTableName = Optional.of(drop_stats_params.getTable_name());
catalogOpTracker_.increment(ddlRequest, tTableName);
- dropStats(drop_stats_params, wantMinimalResult, response);
+ dropStats(drop_stats_params, wantMinimalResult, response, catalogTimeline);
break;
case DROP_DATABASE:
TDropDbParams drop_db_params = ddlRequest.getDrop_db_params();
tTableName = Optional.of(new TTableName(drop_db_params.getDb(), ""));
catalogOpTracker_.increment(ddlRequest, tTableName);
dropDatabase(drop_db_params, response,
- ddlRequest.getQuery_options().getKudu_table_reserve_seconds());
+ ddlRequest.getQuery_options().getKudu_table_reserve_seconds(),
+ catalogTimeline);
break;
case DROP_TABLE:
case DROP_VIEW:
@@ -535,14 +544,15 @@ public class CatalogOpExecutor {
// need to pass down wantMinimalResult here.
dropTableOrView(drop_table_or_view_params, response,
ddlRequest.getQuery_options().getLock_max_wait_time_s(),
- ddlRequest.getQuery_options().getKudu_table_reserve_seconds());
+ ddlRequest.getQuery_options().getKudu_table_reserve_seconds(),
+ catalogTimeline);
break;
case TRUNCATE_TABLE:
TTruncateParams truncate_params = ddlRequest.getTruncate_params();
tTableName = Optional.of(truncate_params.getTable_name());
catalogOpTracker_.increment(ddlRequest, tTableName);
truncateTable(truncate_params, wantMinimalResult, response,
- ddlRequest.getQuery_options().getLock_max_wait_time_s());
+ ddlRequest.getQuery_options().getLock_max_wait_time_s(), catalogTimeline);
break;
case DROP_FUNCTION:
TDropFunctionParams drop_func_params = ddlRequest.getDrop_fn_params();
@@ -550,7 +560,7 @@ public class CatalogOpExecutor {
tTableName = Optional.of(
new TTableName(dropFnName.db_name, dropFnName.function_name));
catalogOpTracker_.increment(ddlRequest, tTableName);
- dropFunction(drop_func_params, response);
+ dropFunction(ddlRequest.getDrop_fn_params(), response, catalogTimeline);
break;
case DROP_DATA_SOURCE:
TDropDataSourceParams drop_ds_params = ddlRequest.getDrop_data_source_params();
@@ -605,7 +615,8 @@ public class CatalogOpExecutor {
break;
case COMMENT_ON:
tTableName = Optional.of(new TTableName("", ""));
- alterCommentOn(ddlRequest, response, tTableName, wantMinimalResult);
+ alterCommentOn(ddlRequest, response, tTableName, wantMinimalResult,
+ catalogTimeline);
break;
case COPY_TESTCASE:
catalogOpTracker_.increment(ddlRequest, Optional.empty());
@@ -903,7 +914,8 @@ public class CatalogOpExecutor {
if (tblBefore != null) {
// if the before table exists, then we must take a lock on it so that
// we block any other concurrent operations on it.
- tryWriteLock(tblBefore, "ALTER_TABLE RENAME EVENT");
+ tryWriteLock(tblBefore, "ALTER_TABLE RENAME EVENT",
+ NoOpEventSequence.INSTANCE);
beforeTblLocked = true;
catalog_.getLock().writeLock().unlock();
}
@@ -1014,7 +1026,8 @@ public class CatalogOpExecutor {
BackendConfig.INSTANCE.enableSyncToLatestEventOnDdls();
boolean dbLocked = false;
try {
- tryLock(dbToAlter, String.format("alter db from event id: %s", eventId));
+ tryLock(dbToAlter, String.format("alter db from event id: %s", eventId),
+ NoOpEventSequence.INSTANCE);
catalog_.getLock().writeLock().unlock();
dbLocked = true;
if (syncToLatestEventId && dbToAlter.getLastSyncedEventId() >= eventId) {
@@ -1044,7 +1057,7 @@ public class CatalogOpExecutor {
* thread-safe, i.e. concurrent operations on the same table are serialized.
*/
private void alterTable(TAlterTableParams params, @Nullable String debugAction,
- boolean wantMinimalResult, TDdlExecResponse response)
+ boolean wantMinimalResult, TDdlExecResponse response, EventSequence catalogTimeline)
throws ImpalaException {
// When true, loads the file/block metadata.
boolean reloadFileMetadata = false;
@@ -1055,7 +1068,7 @@ public class CatalogOpExecutor {
TableName tableName = TableName.fromThrift(params.getTable_name());
Table tbl = getExistingTable(tableName.getDb(), tableName.getTbl(),
- "Load for ALTER TABLE");
+ "Load for ALTER TABLE", catalogTimeline);
if (params.getAlter_type() == TAlterTableType.RENAME_VIEW
|| params.getAlter_type() == TAlterTableType.RENAME_TABLE) {
TableName newTableName = TableName.fromThrift(
@@ -1064,7 +1077,7 @@ public class CatalogOpExecutor {
String.format("Can't rename to blacklisted table name: %s. %s", newTableName,
BLACKLISTED_DBS_INCONSISTENT_ERR_STR));
}
- tryWriteLock(tbl);
+ tryWriteLock(tbl, catalogTimeline);
// get table's catalogVersion before altering it
long oldCatalogVersion = tbl.getCatalogVersion();
// Get a new catalog version to assign to the table being altered.
@@ -1080,7 +1093,7 @@ public class CatalogOpExecutor {
try {
alterTableOrViewRename(tbl,
TableName.fromThrift(params.getRename_params().getNew_table_name()),
- newCatalogVersion, wantMinimalResult, response);
+ newCatalogVersion, wantMinimalResult, response, catalogTimeline);
return;
} finally {
// release the version taken in the tryLock call above
@@ -1095,12 +1108,12 @@ public class CatalogOpExecutor {
if (tbl instanceof KuduTable && altersKuduTable(params.getAlter_type())) {
alterKuduTable(params, response, (KuduTable) tbl, newCatalogVersion,
- wantMinimalResult);
+ wantMinimalResult, catalogTimeline);
return;
} else if (tbl instanceof IcebergTable &&
altersIcebergTable(params.getAlter_type())) {
boolean needToUpdateHms = alterIcebergTable(params, response, (IcebergTable)tbl,
- newCatalogVersion, wantMinimalResult, debugAction);
+ newCatalogVersion, wantMinimalResult, debugAction, catalogTimeline);
if (!needToUpdateHms) return;
}
switch (params.getAlter_type()) {
@@ -1112,7 +1125,7 @@ public class CatalogOpExecutor {
&& params.getAdd_cols_params().getColumnsSize() != 0) {
TAlterTableAddColsParams addColParams = params.getAdd_cols_params();
added = alterTableAddCols(tbl, addColParams.getColumns(),
- addColParams.isIf_not_exists());
+ addColParams.isIf_not_exists(), catalogTimeline);
reloadTableSchema = true;
}
if (added) {
@@ -1123,7 +1136,7 @@ public class CatalogOpExecutor {
break;
case REPLACE_COLUMNS:
TAlterTableReplaceColsParams replaceColParams = params.getReplace_cols_params();
- alterTableReplaceCols(tbl, replaceColParams.getColumns());
+ alterTableReplaceCols(tbl, replaceColParams.getColumns(), catalogTimeline);
reloadTableSchema = true;
responseSummaryMsg = "Table columns have been replaced.";
break;
@@ -1136,7 +1149,7 @@ public class CatalogOpExecutor {
format = params.getSet_file_format_params().file_format;
}
refreshedTable = alterTableAddPartitions(tbl, params.getAdd_partition_params(),
- format);
+ format, catalogTimeline);
if (refreshedTable != null) {
refreshedTable.setCatalogVersion(newCatalogVersion);
// the alter table event is only generated when we add the partition. For
@@ -1151,14 +1164,14 @@ public class CatalogOpExecutor {
break;
case DROP_COLUMN:
TAlterTableDropColParams dropColParams = params.getDrop_col_params();
- alterTableDropCol(tbl, dropColParams.getCol_name());
+ alterTableDropCol(tbl, dropColParams.getCol_name(), catalogTimeline);
reloadTableSchema = true;
responseSummaryMsg = "Column has been dropped.";
break;
case ALTER_COLUMN:
TAlterTableAlterColParams alterColParams = params.getAlter_col_params();
alterTableAlterCol(tbl, alterColParams.getCol_name(),
- alterColParams.getNew_col_def());
+ alterColParams.getNew_col_def(), catalogTimeline);
reloadTableSchema = true;
responseSummaryMsg = "Column has been altered.";
break;
@@ -1172,7 +1185,7 @@ public class CatalogOpExecutor {
refreshedTable = alterTableDropPartition(
tbl, dropPartParams.getPartition_set(),
dropPartParams.isIf_exists(),
- dropPartParams.isPurge(), numUpdatedPartitions);
+ dropPartParams.isPurge(), numUpdatedPartitions, catalogTimeline);
if (refreshedTable != null) {
refreshedTable.setCatalogVersion(newCatalogVersion);
// we don't need to add catalog versions in partition's InflightEvents here
@@ -1194,7 +1207,7 @@ public class CatalogOpExecutor {
params.getSet_file_format_params();
reloadFileMetadata = alterTableSetFileFormat(
tbl, fileFormatParams.getPartition_set(),
- fileFormatParams.getFile_format(), numUpdatedPartitions);
+ fileFormatParams.getFile_format(), numUpdatedPartitions, catalogTimeline);
if (fileFormatParams.isSetPartition_set()) {
responseSummaryMsg =
@@ -1208,7 +1221,7 @@ public class CatalogOpExecutor {
params.getSet_row_format_params();
reloadFileMetadata = alterTableSetRowFormat(tbl,
rowFormatParams.getPartition_set(), rowFormatParams.getRow_format(),
- numUpdatedPartitions);
+ numUpdatedPartitions, catalogTimeline);
if (rowFormatParams.isSetPartition_set()) {
responseSummaryMsg =
"Updated " + numUpdatedPartitions.getRef() + " partition(s).";
@@ -1221,7 +1234,7 @@ public class CatalogOpExecutor {
params.getSet_location_params();
List<TPartitionKeyValue> partitionSpec = setLocationParams.getPartition_spec();
reloadFileMetadata = alterTableSetLocation(tbl, partitionSpec,
- setLocationParams.getLocation());
+ setLocationParams.getLocation(), catalogTimeline);
if (partitionSpec == null) {
responseSummaryMsg = "New location has been set.";
} else {
@@ -1230,7 +1243,7 @@ public class CatalogOpExecutor {
break;
case SET_TBL_PROPERTIES:
alterTableSetTblProperties(tbl, params.getSet_tbl_properties_params(),
- numUpdatedPartitions);
+ numUpdatedPartitions, catalogTimeline);
reloadTableSchema = true;
if (params.getSet_tbl_properties_params().isSetPartition_set()) {
responseSummaryMsg =
@@ -1241,7 +1254,7 @@ public class CatalogOpExecutor {
break;
case UNSET_TBL_PROPERTIES:
alterTableUnSetTblProperties(tbl, params.getUnset_tbl_properties_params(),
- numUpdatedPartitions);
+ numUpdatedPartitions, catalogTimeline);
reloadTableSchema = true;
if (params.getUnset_tbl_properties_params().isSetPartition_set()) {
responseSummaryMsg =
@@ -1251,12 +1264,14 @@ public class CatalogOpExecutor {
}
break;
case SET_VIEW_PROPERTIES:
- alterViewSetTblProperties(tbl, params.getSet_tbl_properties_params());
+ alterViewSetTblProperties(tbl, params.getSet_tbl_properties_params(),
+ catalogTimeline);
reloadTableSchema = true;
responseSummaryMsg = "Updated view.";
break;
case UNSET_VIEW_PROPERTIES:
- alterViewUnSetTblProperties(tbl, params.getUnset_tbl_properties_params());
+ alterViewUnSetTblProperties(tbl, params.getUnset_tbl_properties_params(),
+ catalogTimeline);
reloadTableSchema = true;
responseSummaryMsg = "Updated view.";
break;
@@ -1264,7 +1279,7 @@ public class CatalogOpExecutor {
Preconditions.checkState(params.isSetUpdate_stats_params());
Reference<Long> numUpdatedColumns = new Reference<>(0L);
alterTableUpdateStats(tbl, params.getUpdate_stats_params(),
- numUpdatedPartitions, numUpdatedColumns, debugAction);
+ numUpdatedPartitions, numUpdatedColumns, debugAction, catalogTimeline);
reloadTableSchema = true;
responseSummaryMsg = "Updated " + numUpdatedPartitions.getRef() +
" partition(s) and " + numUpdatedColumns.getRef() + " column(s).";
@@ -1275,21 +1290,22 @@ public class CatalogOpExecutor {
"Cached " : "Uncached ";
if (params.getSet_cached_params().getPartition_set() == null) {
reloadFileMetadata =
- alterTableSetCached(tbl, params.getSet_cached_params());
+ alterTableSetCached(tbl, params.getSet_cached_params(), catalogTimeline);
responseSummaryMsg = op + "table.";
} else {
alterPartitionSetCached(tbl, params.getSet_cached_params(),
- numUpdatedPartitions);
+ numUpdatedPartitions, catalogTimeline);
responseSummaryMsg = op + numUpdatedPartitions.getRef() + " partition(s).";
}
break;
case RECOVER_PARTITIONS:
- alterTableRecoverPartitions(tbl, debugAction);
+ alterTableRecoverPartitions(tbl, debugAction, catalogTimeline);
responseSummaryMsg = "Partitions have been recovered.";
break;
case SET_OWNER:
Preconditions.checkState(params.isSetSet_owner_params());
- alterTableOrViewSetOwner(tbl, params.getSet_owner_params(), response);
+ alterTableOrViewSetOwner(tbl, params.getSet_owner_params(), response,
+ catalogTimeline);
responseSummaryMsg = "Updated table/view.";
break;
default:
@@ -1301,7 +1317,8 @@ public class CatalogOpExecutor {
if (tbl.hasInProgressModification()) Preconditions.checkState(reloadMetadata);
if (reloadMetadata) {
loadTableMetadata(tbl, newCatalogVersion, reloadFileMetadata,
- reloadTableSchema, null, "ALTER TABLE " + params.getAlter_type().name());
+ reloadTableSchema, null, "ALTER TABLE " + params.getAlter_type().name(),
+ catalogTimeline);
// now that HMS alter operation has succeeded, add this version to list of
// inflight events in catalog table if event processing is enabled
catalog_.addVersionsForInflightEvents(false, tbl, newCatalogVersion);
@@ -1338,15 +1355,16 @@ public class CatalogOpExecutor {
* Executes the ALTER TABLE command for a Kudu table and reloads its metadata.
*/
private void alterKuduTable(TAlterTableParams params, TDdlExecResponse response,
- KuduTable tbl, long newCatalogVersion, boolean wantMinimalResult)
- throws ImpalaException {
+ KuduTable tbl, long newCatalogVersion, boolean wantMinimalResult,
+ EventSequence catalogTimeline) throws ImpalaException {
Preconditions.checkState(tbl.isWriteLockedByCurrentThread());
switch (params.getAlter_type()) {
case ADD_COLUMNS:
if (params.getAdd_cols_params() != null
&& params.getAdd_cols_params().getColumnsSize() != 0) {
TAlterTableAddColsParams addColParams = params.getAdd_cols_params();
- KuduCatalogOpExecutor.addColumn(tbl, addColParams.getColumns());
+ KuduCatalogOpExecutor.addColumn(tbl, addColParams.getColumns(),
+ catalogTimeline);
addSummary(response, "Column(s) have been added.");
} else {
addSummary(response, "No new column(s) have been added to the table.");
@@ -1354,24 +1372,26 @@ public class CatalogOpExecutor {
break;
case REPLACE_COLUMNS:
TAlterTableReplaceColsParams replaceColParams = params.getReplace_cols_params();
- KuduCatalogOpExecutor.addColumn(tbl, replaceColParams.getColumns());
+ KuduCatalogOpExecutor.addColumn(tbl, replaceColParams.getColumns(),
+ catalogTimeline);
addSummary(response, "Column(s) have been replaced.");
break;
case DROP_COLUMN:
TAlterTableDropColParams dropColParams = params.getDrop_col_params();
- KuduCatalogOpExecutor.dropColumn(tbl, dropColParams.getCol_name());
+ KuduCatalogOpExecutor.dropColumn(tbl, dropColParams.getCol_name(),
+ catalogTimeline);
addSummary(response, "Column has been dropped.");
break;
case ALTER_COLUMN:
TAlterTableAlterColParams alterColParams = params.getAlter_col_params();
KuduCatalogOpExecutor.alterColumn(tbl, alterColParams.getCol_name(),
- alterColParams.getNew_col_def());
+ alterColParams.getNew_col_def(), catalogTimeline);
addSummary(response, "Column has been altered.");
break;
case ADD_DROP_RANGE_PARTITION:
TAlterTableAddDropRangePartitionParams partParams =
params.getAdd_drop_range_partition_params();
- KuduCatalogOpExecutor.addDropRangePartition(tbl, partParams);
+ KuduCatalogOpExecutor.addDropRangePartition(tbl, partParams, catalogTimeline);
addSummary(response, "Range partition has been " +
(partParams.type == TRangePartitionOperationType.ADD ?
"added." : "dropped."));
@@ -1383,7 +1403,7 @@ public class CatalogOpExecutor {
}
loadTableMetadata(tbl, newCatalogVersion, true, true, null, "ALTER KUDU TABLE " +
- params.getAlter_type().name());
+ params.getAlter_type().name(), catalogTimeline);
addTableToCatalogUpdate(tbl, wantMinimalResult, response.result);
}
@@ -1411,12 +1431,13 @@ public class CatalogOpExecutor {
*/
private boolean alterIcebergTable(TAlterTableParams params, TDdlExecResponse response,
IcebergTable tbl, long newCatalogVersion, boolean wantMinimalResult,
- String debugAction)
+ String debugAction, EventSequence catalogTimeline)
throws ImpalaException {
Preconditions.checkState(tbl.isWriteLockedByCurrentThread());
boolean needsToUpdateHms = !IcebergUtil.isHiveCatalog(tbl.getMetaStoreTable());
try {
org.apache.iceberg.Transaction iceTxn = IcebergUtil.getIcebergTransaction(tbl);
+ catalogTimeline.markEvent("Got Iceberg transaction");
switch (params.getAlter_type()) {
case ADD_COLUMNS:
if (params.getAdd_cols_params() != null
@@ -1492,6 +1513,7 @@ public class CatalogOpExecutor {
"Unsupported ALTER TABLE operation for Iceberg tables: " +
params.getAlter_type());
}
+ catalogTimeline.markEvent("Iceberg operations are prepared for commit");
if (!needsToUpdateHms) {
IcebergCatalogOpExecutor.addCatalogVersionToTxn(iceTxn,
catalog_.getCatalogServiceId(), newCatalogVersion);
@@ -1500,6 +1522,7 @@ public class CatalogOpExecutor {
DebugUtils.executeDebugAction(debugAction, DebugUtils.ICEBERG_COMMIT);
}
iceTxn.commitTransaction();
+ catalogTimeline.markEvent("Committed Iceberg transaction");
} catch (IllegalArgumentException | ValidationException ex) {
throw new ImpalaRuntimeException(String.format(
"Failed to ALTER table '%s': %s", params.getTable_name().table_name,
@@ -1510,7 +1533,7 @@ public class CatalogOpExecutor {
// We don't need to update HMS because either it is already done by Iceberg's
// HiveCatalog, or we modified the Iceberg data which is not stored in HMS.
loadTableMetadata(tbl, newCatalogVersion, true, true, null, "ALTER Iceberg TABLE " +
- params.getAlter_type().name());
+ params.getAlter_type().name(), catalogTimeline);
catalog_.addVersionsForInflightEvents(false, tbl, newCatalogVersion);
addTableToCatalogUpdate(tbl, wantMinimalResult, response.result);
return false;
@@ -1577,36 +1600,38 @@ public class CatalogOpExecutor {
*/
private void loadTableMetadata(Table tbl, long newCatalogVersion,
boolean reloadFileMetadata, boolean reloadTableSchema,
- Set<String> partitionsToUpdate, String reason) throws CatalogException {
+ Set<String> partitionsToUpdate, String reason, EventSequence catalogTimeline)
+ throws CatalogException {
loadTableMetadata(tbl, newCatalogVersion, reloadFileMetadata, reloadTableSchema,
- partitionsToUpdate, null, reason, null);
+ partitionsToUpdate, null, reason, null, catalogTimeline);
}
/**
- * Same as {@link #loadTableMetadata(Table, long, boolean, boolean, Set, String)} but
- * takes in a Map of partition name to event id which is passed down to the table load
- * method.
+ * Same as the above method but takes in a Map of partition name to event id which is
+ * passed down to the table load method.
*/
private void loadTableMetadata(Table tbl, long newCatalogVersion,
boolean reloadFileMetadata, boolean reloadTableSchema,
Set<String> partitionsToUpdate, @Nullable Map<String, Long> partitionToEventId,
- String reason, @Nullable String debugAction)
+ String reason, @Nullable String debugAction, EventSequence catalogTimeline)
throws CatalogException {
Preconditions.checkState(tbl.isWriteLockedByCurrentThread());
long eventId = -1L;
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
org.apache.hadoop.hive.metastore.api.Table msTbl =
getMetaStoreTable(msClient, tbl);
+ catalogTimeline.markEvent(FETCHED_HMS_TABLE);
if (msTbl.getPartitionKeysSize() == 0) {
eventId = MetastoreEventsProcessor.getCurrentEventIdNoThrow(
msClient.getHiveClient());
+ catalogTimeline.markEvent(FETCHED_LATEST_HMS_EVENT_ID + eventId);
}
if (tbl instanceof HdfsTable) {
((HdfsTable) tbl).load(true, msClient.getHiveClient(), msTbl,
reloadFileMetadata, reloadTableSchema, false, partitionsToUpdate,
- debugAction, partitionToEventId, reason);
+ debugAction, partitionToEventId, reason, catalogTimeline);
} else {
- tbl.load(true, msClient.getHiveClient(), msTbl, reason);
+ tbl.load(true, msClient.getHiveClient(), msTbl, reason, catalogTimeline);
}
// Update the lastRefreshEventId at the table level if it is unpartitioned table
// if it is partitioned table, partitions are updated in HdfsTable#load() method
@@ -1614,6 +1639,7 @@ public class CatalogOpExecutor {
&& reloadFileMetadata && reloadTableSchema) {
tbl.setLastRefreshEventId(eventId);
}
+ catalogTimeline.markEvent("Reloaded table metadata");
}
tbl.setCatalogVersion(newCatalogVersion);
}
@@ -1633,8 +1659,8 @@ public class CatalogOpExecutor {
}
private Table addHdfsPartitions(MetaStoreClient msClient, Table tbl,
- List<Partition> addedPartitions, Map<String, Long> partitionToEventId)
- throws CatalogException {
+ List<Partition> addedPartitions, Map<String, Long> partitionToEventId,
+ EventSequence catalogTimeline) throws CatalogException {
Preconditions.checkNotNull(tbl);
Preconditions.checkNotNull(addedPartitions);
if (!(tbl instanceof HdfsTable)) {
@@ -1642,7 +1668,7 @@ public class CatalogOpExecutor {
}
HdfsTable hdfsTable = (HdfsTable) tbl;
List<HdfsPartition> hdfsPartitions = hdfsTable.createAndLoadPartitions(
- msClient.getHiveClient(), addedPartitions, partitionToEventId);
+ msClient.getHiveClient(), addedPartitions, partitionToEventId, catalogTimeline);
for (HdfsPartition hdfsPartition : hdfsPartitions) {
catalog_.addPartition(hdfsPartition);
}
@@ -1655,17 +1681,17 @@ public class CatalogOpExecutor {
* a table instead of a a view.
*/
private void alterView(TCreateOrAlterViewParams params, boolean wantMinimalResult,
- TDdlExecResponse resp) throws ImpalaException {
+ TDdlExecResponse resp, EventSequence catalogTimeline) throws ImpalaException {
TableName tableName = TableName.fromThrift(params.getView_name());
Preconditions.checkState(tableName != null && tableName.isFullyQualified());
Preconditions.checkState(params.getColumns() != null &&
params.getColumns().size() > 0,
"Null or empty column list given as argument to DdlExecutor.alterView");
Table tbl = getExistingTable(tableName.getDb(), tableName.getTbl(),
- "Load for ALTER VIEW");
+ "Load for ALTER VIEW", catalogTimeline);
Preconditions.checkState(tbl instanceof View, "Expected view: %s",
tableName);
- tryWriteLock(tbl);
+ tryWriteLock(tbl, catalogTimeline);
try {
long newCatalogVersion = catalog_.incrementAndGetCatalogVersion();
catalog_.getLock().writeLock().unlock();
@@ -1687,12 +1713,12 @@ public class CatalogOpExecutor {
if (LOG.isTraceEnabled()) {
LOG.trace(String.format("Altering view %s", tableName));
}
- applyAlterTable(msTbl);
+ applyAlterTable(msTbl, catalogTimeline);
long eventId = -1L;
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
eventId = MetastoreEventsProcessor.getCurrentEventIdNoThrow(
msClient.getHiveClient());
- tbl.load(true, msClient.getHiveClient(), msTbl, "ALTER VIEW");
+ tbl.load(true, msClient.getHiveClient(), msTbl, "ALTER VIEW", catalogTimeline);
}
addSummary(resp, "View has been altered.");
tbl.setCatalogVersion(newCatalogVersion);
@@ -1747,7 +1773,7 @@ public class CatalogOpExecutor {
*/
private void alterTableUpdateStats(Table table, TAlterTableUpdateStatsParams params,
Reference<Long> numUpdatedPartitions, Reference<Long> numUpdatedColumns,
- @Nullable String debugAction)
+ @Nullable String debugAction, EventSequence catalogTimeline)
throws ImpalaException {
Preconditions.checkState(table.isWriteLockedByCurrentThread());
Preconditions.checkState(params.isSetTable_stats() || params.isSetColumn_stats());
@@ -1774,20 +1800,23 @@ public class CatalogOpExecutor {
// transactional tables). Hive seems to use internal API for this.
// See IMPALA-8865 about plans to improve this.
TblTransaction tblTxn = null;
- try(MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
try {
if (AcidUtils.isTransactionalTable(msTbl.getParameters())) {
tblTxn = MetastoreShim.createTblTransaction(
msClient.getHiveClient(), msTbl, -1 /* opens new transaction */);
+ catalogTimeline.markEvent("Opened new transaction");
}
alterTableUpdateStatsInner(table, msTbl, params,
- numUpdatedPartitions, numUpdatedColumns, msClient, tblTxn);
+ numUpdatedPartitions, numUpdatedColumns, msClient, tblTxn, catalogTimeline);
if (tblTxn != null) {
MetastoreShim.commitTblTransactionIfNeeded(msClient.getHiveClient(), tblTxn);
+ catalogTimeline.markEvent("Committed transaction");
}
} catch (Exception ex) {
if (tblTxn != null) {
MetastoreShim.abortTblTransactionIfNeeded(msClient.getHiveClient(), tblTxn);
+ catalogTimeline.markEvent("Aborted transaction");
}
throw ex;
}
@@ -1799,7 +1828,7 @@ public class CatalogOpExecutor {
org.apache.hadoop.hive.metastore.api.Table msTbl,
TAlterTableUpdateStatsParams params,
Reference<Long> numUpdatedPartitions, Reference<Long> numUpdatedColumns,
- MetaStoreClient msClient, TblTransaction tblTxn)
+ MetaStoreClient msClient, TblTransaction tblTxn, EventSequence catalogTimeline)
throws ImpalaException {
// Update column stats.
numUpdatedColumns.setRef(0L);
@@ -1817,6 +1846,7 @@ public class CatalogOpExecutor {
"updateTableColumnStatistics"), e);
}
}
+ catalogTimeline.markEvent("Updated column stats");
}
numUpdatedColumns.setRef((long) colStats.getStatsObjSize());
}
@@ -1828,7 +1858,8 @@ public class CatalogOpExecutor {
Preconditions.checkState(table instanceof HdfsTable);
modifiedParts = updatePartitionStats(params, (HdfsTable) table);
// TODO: IMPALA-10203: avoid reloading modified partitions when updating stats.
- bulkAlterPartitions(table, modifiedParts, tblTxn, UpdatePartitionMethod.MARK_DIRTY);
+ bulkAlterPartitions(table, modifiedParts, tblTxn, UpdatePartitionMethod.MARK_DIRTY,
+ catalogTimeline);
}
if (params.isSetTable_stats()) {
@@ -1841,10 +1872,11 @@ public class CatalogOpExecutor {
if (IcebergTable.isIcebergTable(msTbl) && isIcebergHmsIntegrationEnabled(msTbl)) {
updateTableStatsViaIceberg((IcebergTable)table, msTbl);
+ catalogTimeline.markEvent("Updated table stats via Iceberg");
} else {
// Apply property changes like numRows.
msTbl.getParameters().remove(StatsSetupConst.COLUMN_STATS_ACCURATE);
- applyAlterTable(msTbl, false, tblTxn);
+ applyAlterTable(msTbl, false, tblTxn, catalogTimeline);
}
numUpdatedPartitions.setRef(0L);
if (modifiedParts != null) {
@@ -2029,7 +2061,8 @@ public class CatalogOpExecutor {
* @param syncDdl tells if SYNC_DDL option is enabled on this DDL request.
*/
private void createDatabase(TCreateDbParams params, TDdlExecResponse resp,
- boolean syncDdl, boolean wantMinimalResult) throws ImpalaException {
+ EventSequence catalogTimeline, boolean syncDdl, boolean wantMinimalResult)
+ throws ImpalaException {
Preconditions.checkNotNull(params);
String dbName = params.getDb();
Preconditions.checkState(dbName != null && !dbName.isEmpty(),
@@ -2045,7 +2078,7 @@ public class CatalogOpExecutor {
}
Preconditions.checkNotNull(existingDb);
if (syncDdl) {
- tryLock(existingDb, "create database");
+ tryLock(existingDb, "create database", catalogTimeline);
try {
// When SYNC_DDL is enabled and the database already exists, we force a version
// bump on it so that it is added to the next statestore update. Without this
@@ -2087,13 +2120,15 @@ public class CatalogOpExecutor {
db.setOwnerType(PrincipalType.USER);
if (LOG.isTraceEnabled()) LOG.trace("Creating database " + dbName);
Db newDb = null;
- getMetastoreDdlLock().lock();
+ acquireMetastoreDdlLock(catalogTimeline);
try {
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
try {
- long eventId = getCurrentEventId(msClient);
+ long eventId = getCurrentEventId(msClient, catalogTimeline);
msClient.getHiveClient().createDatabase(db);
- List<NotificationEvent> events = getNextMetastoreEventsIfEnabled(eventId,
+ catalogTimeline.markEvent("Created database in Metastore");
+ List<NotificationEvent> events = getNextMetastoreEventsIfEnabled(
+ catalogTimeline, eventId,
notificationEvent ->
CreateDatabaseEvent.CREATE_DATABASE_EVENT_TYPE
.equals(notificationEvent.getEventType())
@@ -2115,6 +2150,7 @@ public class CatalogOpExecutor {
eventDbPair.second = msClient.getHiveClient().getDatabase(dbName);
}
newDb = catalog_.addDb(dbName, eventDbPair.second, eventDbPair.first);
+ catalogTimeline.markEvent("Created database in catalog cache");
addSummary(resp, "Database has been created.");
} catch (AlreadyExistsException e) {
if (!params.if_not_exists) {
@@ -2131,7 +2167,9 @@ public class CatalogOpExecutor {
try {
org.apache.hadoop.hive.metastore.api.Database msDb =
msClient.getHiveClient().getDatabase(dbName);
+ catalogTimeline.markEvent("Fetched database from Metastore");
newDb = catalog_.addDb(dbName, msDb);
+ catalogTimeline.markEvent("Created database in catalog cache");
} catch (TException e1) {
throw new ImpalaRuntimeException(
String.format(HMS_RPC_ERROR_FORMAT_STR, "createDatabase"), e1);
@@ -2159,15 +2197,7 @@ public class CatalogOpExecutor {
* Wrapper around
* {@code MetastoreEventsProcessor#getNextMetastoreEventsInBatches} with the
* addition that it checks if events processing is active or not. If not active,
- * returns an empty list.
- */
- private List<NotificationEvent> getNextMetastoreEventsIfEnabled(long eventId,
- NotificationFilter eventsFilter) throws MetastoreNotificationException {
- return getNextMetastoreEventsIfEnabled(null, eventId, eventsFilter);
- }
-
- /**
- * Same as the above but also update the given 'catalogTimeline'.
+ * returns an empty list. Also updates the given 'catalogTimeline'
*/
private List<NotificationEvent> getNextMetastoreEventsIfEnabled(
EventSequence catalogTimeline, long eventId, NotificationFilter eventsFilter)
@@ -2175,9 +2205,7 @@ public class CatalogOpExecutor {
if (!catalog_.isEventProcessingActive()) return Collections.emptyList();
List<NotificationEvent> events = MetastoreEventsProcessor
.getNextMetastoreEventsInBatches(catalog_, eventId, eventsFilter);
- if (catalogTimeline != null) {
- catalogTimeline.markEvent(FETCHED_HMS_EVENT_BATCH);
- }
+ catalogTimeline.markEvent(FETCHED_HMS_EVENT_BATCH);
return events;
}
@@ -2373,8 +2401,8 @@ public class CatalogOpExecutor {
}
}
- private void createFunction(TCreateFunctionParams params, TDdlExecResponse resp)
- throws ImpalaException {
+ private void createFunction(TCreateFunctionParams params, TDdlExecResponse resp,
+ EventSequence catalogTimeline) throws ImpalaException {
Function fn = Function.fromThrift(params.getFn());
if (LOG.isTraceEnabled()) {
LOG.trace(String.format("Adding %s: %s",
@@ -2390,7 +2418,7 @@ public class CatalogOpExecutor {
throw new CatalogException("Database: " + fn.dbName() + " does not exist.");
}
- tryLock(db, "creating function " + fn.getClass().getSimpleName());
+ tryLock(db, "creating function " + fn.getClass().getSimpleName(), catalogTimeline);
// Get a new catalog version to assign to the database being altered. This is
// needed for events processor as this method creates alter database events.
long newCatalogVersion = catalog_.incrementAndGetCatalogVersion();
@@ -2417,8 +2445,8 @@ public class CatalogOpExecutor {
// the corresponding Jar and add each signature to the catalog.
Preconditions.checkState(fn instanceof ScalarFunction);
List<ScalarFunction> funcs = hiveJavaFunction.extract();
- if (addJavaFunctionToHms(fn.dbName(), hiveJavaFunction.getHiveFunction(),
- params.if_not_exists)) {
+ if (addJavaFunctionToHms(hiveJavaFunction.getHiveFunction(),
+ params.if_not_exists, catalogTimeline)) {
for (Function addedFn : funcs) {
if (LOG.isTraceEnabled()) {
LOG.trace(String.format("Adding function: %s.%s", addedFn.dbName(),
@@ -2438,7 +2466,7 @@ public class CatalogOpExecutor {
addCatalogServiceIdentifiers(db.getMetaStoreDb(),
catalog_.getCatalogServiceId(), newCatalogVersion);
// Flush DB changes to metastore
- applyAlterDatabase(db.getMetaStoreDb());
+ applyAlterDatabase(db.getMetaStoreDb(), catalogTimeline);
addedFunctions.add(fn.toTCatalogObject());
// now that HMS alter database has succeeded, add this version to list of
// inflight events in catalog database if event processing is enabled.
@@ -2522,15 +2550,15 @@ public class CatalogOpExecutor {
* to protect against concurrent modifications.
*/
private void dropStats(TDropStatsParams params, boolean wantMinimalResult,
- TDdlExecResponse resp) throws ImpalaException {
+ TDdlExecResponse resp, EventSequence catalogTimeline) throws ImpalaException {
Table table = getExistingTable(params.getTable_name().getDb_name(),
- params.getTable_name().getTable_name(), "Load for DROP STATS");
+ params.getTable_name().getTable_name(), "Load for DROP STATS", catalogTimeline);
Preconditions.checkNotNull(table);
// There is no transactional HMS API to drop stats at the moment (HIVE-22104).
Preconditions.checkState(!AcidUtils.isTransactionalTable(
table.getMetaStoreTable().getParameters()));
- tryWriteLock(table, "dropping stats");
+ tryWriteLock(table, "dropping stats", catalogTimeline);
try {
long newCatalogVersion = catalog_.incrementAndGetCatalogVersion();
catalog_.getLock().writeLock().unlock();
@@ -2539,8 +2567,8 @@ public class CatalogOpExecutor {
if (params.getPartition_set() == null) {
// TODO: Report the number of updated partitions/columns to the user?
// TODO: bulk alter the partitions.
- dropColumnStats(table);
- dropTableStats(table);
+ dropColumnStats(table, catalogTimeline);
+ dropTableStats(table, catalogTimeline);
} else {
HdfsTable hdfsTbl = (HdfsTable) table;
List<HdfsPartition> partitions =
@@ -2554,13 +2582,14 @@ public class CatalogOpExecutor {
if (partition.getPartitionStatsCompressed() != null) {
HdfsPartition.Builder partBuilder = new HdfsPartition.Builder(partition);
partBuilder.dropPartitionStats();
- applyAlterPartition(table, partBuilder);
+ applyAlterPartition(table, partBuilder, catalogTimeline);
hdfsTbl.updatePartition(partBuilder);
}
}
}
loadTableMetadata(table, newCatalogVersion, /*reloadFileMetadata=*/false,
- /*reloadTableSchema=*/true, /*partitionsToUpdate=*/null, "DROP STATS");
+ /*reloadTableSchema=*/true, /*partitionsToUpdate=*/null, "DROP STATS",
+ catalogTimeline);
catalog_.addVersionsForInflightEvents(false, table, newCatalogVersion);
addTableToCatalogUpdate(table, wantMinimalResult, resp.result);
addSummary(resp, "Stats have been dropped.");
@@ -2574,10 +2603,11 @@ public class CatalogOpExecutor {
* Drops all column stats from the table in the HMS. Returns the number of columns
* that were updated as part of this operation.
*/
- private int dropColumnStats(Table table) throws ImpalaRuntimeException {
+ private int dropColumnStats(Table table, EventSequence catalogTimeline)
+ throws ImpalaRuntimeException {
Preconditions.checkState(table.isWriteLockedByCurrentThread());
int numColsUpdated = 0;
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
for (Column col: table.getColumns()) {
// Skip columns that don't have stats.
if (!col.getStats().hasStats()) continue;
@@ -2585,6 +2615,7 @@ public class CatalogOpExecutor {
try {
MetastoreShim.deleteTableColumnStatistics(msClient.getHiveClient(),
table.getDb().getName(), table.getName(), col.getName());
+ catalogTimeline.markEvent("Deleted column statistics in Metastore");
++numColsUpdated;
} catch (NoSuchObjectException e) {
// We don't care if the column stats do not exist, just ignore the exception.
@@ -2606,7 +2637,8 @@ public class CatalogOpExecutor {
* the number of partitions updated as part of this operation, or 1 if the table
* is unpartitioned.
*/
- private int dropTableStats(Table table) throws ImpalaException {
+ private int dropTableStats(Table table, EventSequence catalogTimeline)
+ throws ImpalaException {
Preconditions.checkState(table.isWriteLockedByCurrentThread());
// Delete the ROW_COUNT from the table (if it was set).
org.apache.hadoop.hive.metastore.api.Table msTbl = table.getMetaStoreTable();
@@ -2624,7 +2656,7 @@ public class CatalogOpExecutor {
msTbl.getParameters().remove(StatsSetupConst.TOTAL_SIZE) != null;
if (droppedRowCount || droppedTotalSize) {
- applyAlterTable(msTbl, false, null);
+ applyAlterTable(msTbl, false, null, catalogTimeline);
++numTargetedPartitions;
}
@@ -2661,7 +2693,8 @@ public class CatalogOpExecutor {
if (partBuilder != null) modifiedParts.add(partBuilder);
}
- bulkAlterPartitions(table, modifiedParts, null, UpdatePartitionMethod.IN_PLACE);
+ bulkAlterPartitions(table, modifiedParts, null, UpdatePartitionMethod.IN_PLACE,
+ catalogTimeline);
return modifiedParts.size();
}
@@ -2671,7 +2704,8 @@ public class CatalogOpExecutor {
* tables. Re-throws any HMS exceptions encountered during the drop.
*/
private void dropDatabase(TDropDbParams params, TDdlExecResponse resp,
- int kudu_table_reserve_seconds) throws ImpalaException {
+ int kudu_table_reserve_seconds, EventSequence catalogTimeline)
+ throws ImpalaException {
Preconditions.checkNotNull(params);
String dbName = params.getDb();
Preconditions.checkState(dbName != null && !dbName.isEmpty(),
@@ -2692,17 +2726,17 @@ public class CatalogOpExecutor {
}
TCatalogObject removedObject = null;
- getMetastoreDdlLock().lock();
+ acquireMetastoreDdlLock(catalogTimeline);
try {
// Remove all the Kudu tables of 'db' from the Kudu storage engine.
if (db != null && params.cascade) {
- dropTablesFromKudu(db, kudu_table_reserve_seconds);
+ dropTablesFromKudu(db, kudu_table_reserve_seconds, catalogTimeline);
}
// The Kudu tables in the HMS should have been dropped at this point
// with the Hive Metastore integration enabled.
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
- long eventId = getCurrentEventId(msClient);
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
+ long eventId = getCurrentEventId(msClient, catalogTimeline);
// HMS client does not have a way to identify if the database was dropped or
// not if the ignoreIfUnknown flag is true. Hence we always pass the
// ignoreIfUnknown as false and catch the NoSuchObjectFoundException and
@@ -2710,7 +2744,9 @@ public class CatalogOpExecutor {
msClient.getHiveClient().dropDatabase(
dbName, /* deleteData */true, /* ignoreIfUnknown */false,
params.cascade);
- List<NotificationEvent> events = getNextMetastoreEventsIfEnabled(eventId,
+ catalogTimeline.markEvent("Dropped database in Metastore");
+ List<NotificationEvent> events = getNextMetastoreEventsIfEnabled(
+ catalogTimeline, eventId,
event -> dbName.equalsIgnoreCase(event.getDbName()) && (
DropDatabaseEvent.DROP_DATABASE_EVENT_TYPE.equals(event.getEventType()) ||
DropTableEvent.DROP_TABLE_EVENT_TYPE.equals(event.getEventType())));
@@ -2726,6 +2762,7 @@ public class CatalogOpExecutor {
}
}
Db removedDb = catalog_.removeDb(dbName);
+ catalogTimeline.markEvent("Deleted database in catalog cache");
if (removedDb == null) {
// Nothing was removed from the catalogd's cache.
@@ -2734,7 +2771,7 @@ public class CatalogOpExecutor {
}
// Make sure the cache directives, if any, of the underlying tables are removed
for (String tableName: removedDb.getAllTableNames()) {
- uncacheTable(removedDb.getTable(tableName));
+ uncacheTable(removedDb.getTable(tableName), catalogTimeline);
}
removedObject = removedDb.toTCatalogObject();
if (authzConfig_.isEnabled()) {
@@ -2784,8 +2821,8 @@ public class CatalogOpExecutor {
* metadata for Kudu tables cannot be loaded from HMS or if an error occurs while
* trying to drop a table from Kudu.
*/
- private void dropTablesFromKudu(Db db, int kudu_table_reserve_seconds)
- throws ImpalaException {
+ private void dropTablesFromKudu(Db db, int kudu_table_reserve_seconds,
+ EventSequence catalogTimeline) throws ImpalaException {
// If the table format isn't available, because the table hasn't been loaded yet,
// the metadata must be fetched from the Hive Metastore.
List<String> incompleteTableNames = Lists.newArrayList();
@@ -2799,9 +2836,10 @@ public class CatalogOpExecutor {
}
}
if (!incompleteTableNames.isEmpty()) {
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
msTables.addAll(msClient.getHiveClient().getTableObjectsByName(
db.getName(), incompleteTableNames));
+ catalogTimeline.markEvent("Fetched unloaded tables from Metastore");
} catch (TException e) {
LOG.error(String.format(HMS_RPC_ERROR_FORMAT_STR, "getTableObjectsByName") +
e.getMessage());
@@ -2815,7 +2853,7 @@ public class CatalogOpExecutor {
// expected to ALTER TABLE to either set the table to UNMANAGED or set the format
// to something else.
KuduCatalogOpExecutor.dropTable(
- msTable, /*if exists*/ true, kudu_table_reserve_seconds);
+ msTable, /*if exists*/ true, kudu_table_reserve_seconds, catalogTimeline);
}
}
@@ -2859,7 +2897,8 @@ public class CatalogOpExecutor {
* executing the drop operation.
*/
private void dropTableOrView(TDropTableOrViewParams params, TDdlExecResponse resp,
- int lockMaxWaitTime, int kudu_table_reserve_seconds) throws ImpalaException {
+ int lockMaxWaitTime, int kudu_table_reserve_seconds, EventSequence catalogTimeline)
+ throws ImpalaException {
TableName tableName = TableName.fromThrift(params.getTable_name());
Preconditions.checkState(tableName != null && tableName.isFullyQualified());
Preconditions.checkState(!catalog_.isBlacklistedTable(tableName) || params.if_exists,
@@ -2885,8 +2924,9 @@ public class CatalogOpExecutor {
// we pass null validWriteIdList here since we don't really care what version of
// table is loaded, eventually its going to be dropped below.
catalog_.getOrLoadTable(params.getTable_name().db_name,
- params.getTable_name().table_name, "Load for DROP TABLE/VIEW", null);
-
+ params.getTable_name().table_name, "Load for DROP TABLE/VIEW", null,
+ TABLE_ID_UNAVAILABLE, catalogTimeline);
+ catalogTimeline.markEvent("Loaded catalog table");
} catch (CatalogException e) {
// Ignore exceptions -- the above was just to trigger loading. Failure to load
// or non-existence of the database will be handled down below.
@@ -2901,10 +2941,12 @@ public class CatalogOpExecutor {
System.nanoTime());
lockId = catalog_.lockTableStandalone(tableName.getDb(), tableName.getTbl(), ctx,
lockMaxWaitTime);
+ catalogTimeline.markEvent("Acquired Metastore lock on the table");
}
try {
- dropTableOrViewInternal(params, tableName, resp, kudu_table_reserve_seconds);
+ dropTableOrViewInternal(params, tableName, resp, kudu_table_reserve_seconds,
+ catalogTimeline);
} finally {
if (lockId > 0) catalog_.releaseTableLock(lockId);
}
@@ -2914,10 +2956,10 @@ public class CatalogOpExecutor {
* Helper function for dropTableOrView().
*/
private void dropTableOrViewInternal(TDropTableOrViewParams params,
- TableName tableName, TDdlExecResponse resp, int kudu_table_reserve_seconds)
- throws ImpalaException {
+ TableName tableName, TDdlExecResponse resp, int kudu_table_reserve_seconds,
+ EventSequence catalogTimeline) throws ImpalaException {
TCatalogObject removedObject = new TCatalogObject();
- getMetastoreDdlLock().lock();
+ acquireMetastoreDdlLock(catalogTimeline);
try {
Db db = catalog_.getDb(params.getTable_name().db_name);
if (db == null) {
@@ -2960,9 +3002,10 @@ public class CatalogOpExecutor {
Preconditions.checkState(existingTbl instanceof IncompleteTable);
Stopwatch hmsLoadSW = Stopwatch.createStarted();
long hmsLoadTime;
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
msTbl = msClient.getHiveClient().getTable(tableName.getDb(),
tableName.getTbl());
+ catalogTimeline.markEvent(FETCHED_HMS_TABLE);
} catch (TException e) {
LOG.error(String.format(HMS_RPC_ERROR_FORMAT_STR, "getTable") + e.getMessage());
} finally {
@@ -2974,12 +3017,12 @@ public class CatalogOpExecutor {
KuduTable.isKuduTable(msTbl) && KuduTable.isSynchronizedTable(msTbl);
if (isSynchronizedKuduTable) {
KuduCatalogOpExecutor.dropTable(
- msTbl, /* if exists */ true, kudu_table_reserve_seconds);
+ msTbl, /* if exists */ true, kudu_table_reserve_seconds, catalogTimeline);
}
long eventId;
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
- eventId = getCurrentEventId(msClient);
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
+ eventId = getCurrentEventId(msClient, catalogTimeline);
}
boolean isSynchronizedIcebergTable = msTbl != null &&
IcebergTable.isIcebergTable(msTbl) &&
@@ -2996,6 +3039,7 @@ public class CatalogOpExecutor {
Preconditions.checkState(existingTbl instanceof IcebergTable);
try {
IcebergCatalogOpExecutor.dropTable((IcebergTable)existingTbl, params.if_exists);
+ catalogTimeline.markEvent("Dropped table using Iceberg");
} catch (TableNotFoundException e) {
// This is unusual as normally this would have already shown up as
// (existingTbl instanceof IncompleteTable), but this can happen if
@@ -3014,10 +3058,11 @@ public class CatalogOpExecutor {
if (needsHmsDropTable) {
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
msClient.getHiveClient().dropTable(
tableName.getDb(), tableName.getTbl(), true,
params.if_exists, params.purge);
+ catalogTimeline.markEvent("Dropped table in Metastore");
} catch (NoSuchObjectException e) {
throw new ImpalaRuntimeException(String.format("Table %s no longer exists " +
"in the Hive MetaStore. Run 'invalidate metadata %s' to update the " +
@@ -3027,9 +3072,9 @@ public class CatalogOpExecutor {
String.format(HMS_RPC_ERROR_FORMAT_STR, "dropTable"), e);
}
}
- List<NotificationEvent> events = Collections.EMPTY_LIST;
+ List<NotificationEvent> events;
final org.apache.hadoop.hive.metastore.api.Table finalMsTbl = msTbl;
- events = getNextMetastoreEventsIfEnabled(eventId,
+ events = getNextMetastoreEventsIfEnabled(catalogTimeline, eventId,
event -> DropTableEvent.DROP_TABLE_EVENT_TYPE.equals(event.getEventType())
&& finalMsTbl.getDbName().equalsIgnoreCase(event.getDbName())
&& finalMsTbl.getTableName().equalsIgnoreCase(event.getTableName()));
@@ -3037,13 +3082,14 @@ public class CatalogOpExecutor {
addToDeleteEventLog(events);
Table table = catalog_.removeTable(params.getTable_name().db_name,
params.getTable_name().table_name);
+ catalogTimeline.markEvent("Deleted table in catalog cache");
if (table == null) {
// Nothing was removed from the catalogd's cache.
resp.result.setVersion(catalog_.getCatalogVersion());
return;
}
resp.result.setVersion(table.getCatalogVersion());
- uncacheTable(table);
+ uncacheTable(table, catalogTimeline);
if (table.getMetaStoreTable() != null) {
if (authzConfig_.isEnabled()) {
authzManager_.updateTableOwnerPrivilege(params.server_name,
@@ -3070,12 +3116,15 @@ public class CatalogOpExecutor {
* uncaching all table data, if applicable. Throws no exceptions, only logs errors.
* Does not update the HMS.
*/
- private static void uncacheTable(FeTable table) {
+ private static void uncacheTable(FeTable table, EventSequence catalogTimeline) {
if (!(table instanceof FeFsTable)) return;
FeFsTable hdfsTable = (FeFsTable) table;
if (hdfsTable.isMarkedCached()) {
try {
HdfsCachingUtil.removeTblCacheDirective(table.getMetaStoreTable());
+ // This is also used in dropDatabase() so add the table name.
+ catalogTimeline.markEvent("Removed table cache directive of " +
+ table.getFullName());
} catch (Exception e) {
LOG.error("Unable to uncache table: " + table.getFullName(), e);
}
@@ -3083,8 +3132,10 @@ public class CatalogOpExecutor {
if (table.getNumClusteringCols() > 0) {
Collection<? extends FeFsPartition> parts =
FeCatalogUtils.loadAllPartitions(hdfsTable);
+ boolean hasTasks = false;
for (FeFsPartition part: parts) {
if (part.isMarkedCached()) {
+ hasTasks = true;
HdfsPartition.Builder partBuilder = new HdfsPartition.Builder(
(HdfsPartition) part);
try {
@@ -3096,6 +3147,11 @@ public class CatalogOpExecutor {
}
}
}
+ if (hasTasks) {
+ // This is also used in dropDatabase() so add the table name.
+ catalogTimeline.markEvent("Removed partition cache directives of " +
+ table.getFullName());
+ }
}
}
@@ -3106,13 +3162,13 @@ public class CatalogOpExecutor {
* TODO truncate specified partitions.
*/
private void truncateTable(TTruncateParams params, boolean wantMinimalResult,
- TDdlExecResponse resp, int lockMaxWaitTime)
+ TDdlExecResponse resp, int lockMaxWaitTime, EventSequence catalogTimeline)
throws ImpalaException {
TTableName tblName = params.getTable_name();
Table table = null;
try {
table = getExistingTable(tblName.getDb_name(), tblName.getTable_name(),
- "Load for TRUNCATE TABLE");
+ "Load for TRUNCATE TABLE", catalogTimeline);
} catch (TableNotFoundException e) {
if (params.if_exists) {
addSummary(resp, "Table does not exist.");
@@ -3131,17 +3187,20 @@ public class CatalogOpExecutor {
// If transactional, the lock will be released for some time to acquire the HMS Acid
// lock. It's safe because transactional -> non-transactional conversion is not
// allowed.
- tryWriteLock(table, "truncating");
+ tryWriteLock(table, "truncating", catalogTimeline);
try {
long newCatalogVersion = 0;
try {
if (AcidUtils.isTransactionalTable(table.getMetaStoreTable().getParameters())) {
- newCatalogVersion = truncateTransactionalTable(params, table, lockMaxWaitTime);
+ newCatalogVersion = truncateTransactionalTable(params, table, lockMaxWaitTime,
+ catalogTimeline);
} else if (table instanceof FeIcebergTable) {
- newCatalogVersion = truncateIcebergTable(params, table);
+ newCatalogVersion = truncateIcebergTable(params, table, catalogTimeline);
} else {
- newCatalogVersion = truncateNonTransactionalTable(params, table);
+ newCatalogVersion = truncateNonTransactionalTable(params, table,
+ catalogTimeline);
}
+ catalogTimeline.markEvent("Truncated table");
} catch (Exception e) {
String fqName = tblName.db_name + "." + tblName.table_name;
throw new CatalogException(String.format("Failed to truncate table: %s.\n" +
@@ -3149,7 +3208,8 @@ public class CatalogOpExecutor {
}
Preconditions.checkState(newCatalogVersion > 0);
addSummary(resp, "Table has been truncated.");
- loadTableMetadata(table, newCatalogVersion, true, true, null, "TRUNCATE");
+ loadTableMetadata(table, newCatalogVersion, true, true, null, "TRUNCATE",
+ catalogTimeline);
catalog_.addVersionsForInflightEvents(false, table, newCatalogVersion);
addTableToCatalogUpdate(table, wantMinimalResult, resp.result);
} finally {
@@ -3169,19 +3229,20 @@ public class CatalogOpExecutor {
* the table and its partitions.
*/
private long truncateTransactionalTable(TTruncateParams params, Table table,
- int lockMaxWaitTime) throws ImpalaException {
+ int lockMaxWaitTime, EventSequence catalogTimeline) throws ImpalaException {
Preconditions.checkState(table.isWriteLockedByCurrentThread());
Preconditions.checkState(catalog_.getLock().isWriteLockedByCurrentThread());
catalog_.getLock().writeLock().unlock();
TableName tblName = TableName.fromThrift(params.getTable_name());
Stopwatch sw = Stopwatch.createStarted();
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
long newCatalogVersion = 0;
IMetaStoreClient hmsClient = msClient.getHiveClient();
HeartbeatContext ctx = new HeartbeatContext(
String.format("Truncate table %s.%s", tblName.getDb(), tblName.getTbl()),
System.nanoTime());
try (Transaction txn = catalog_.openTransaction(hmsClient, ctx)) {
+ catalogTimeline.markEvent("Opened transaction in Metastore");
Preconditions.checkState(txn.getId() > 0);
// We need to release catalog table lock here, because HMS Acid table lock
// must be locked in advance to avoid dead lock.
@@ -3189,7 +3250,7 @@ public class CatalogOpExecutor {
//TODO: if possible, set DataOperationType to something better than NO_TXN.
catalog_.lockTableInTransaction(tblName.getDb(), tblName.getTbl(), txn,
DataOperationType.NO_TXN, ctx, lockMaxWaitTime);
- tryWriteLock(table, "truncating");
+ tryWriteLock(table, "truncating", catalogTimeline);
LOG.trace("Time elapsed after taking write lock on table {}: {} msec",
table.getFullName(), sw.elapsed(TimeUnit.MILLISECONDS));
newCatalogVersion = catalog_.incrementAndGetCatalogVersion();
@@ -3233,10 +3294,11 @@ public class CatalogOpExecutor {
}
// For partitioned tables we need to alter all the partitions in HMS.
if (!hmsPartitions.isEmpty()) {
- unsetPartitionsColStats(table.getMetaStoreTable(), hmsPartitions, tblTxn);
+ unsetPartitionsColStats(table.getMetaStoreTable(), hmsPartitions, tblTxn,
+ catalogTimeline);
}
// Remove COLUMN_STATS_ACCURATE property from the table.
- unsetTableColStats(table.getMetaStoreTable(), tblTxn);
+ unsetTableColStats(table.getMetaStoreTable(), tblTxn, catalogTimeline);
LOG.trace("Time elapsed after unset partition and column statistics for table "
+ "{}: {} msec", table.getFullName(), sw.elapsed(TimeUnit.MILLISECONDS));
}
@@ -3274,8 +3336,8 @@ public class CatalogOpExecutor {
}
}
- private long truncateIcebergTable(TTruncateParams params, Table table)
- throws Exception {
+ private long truncateIcebergTable(TTruncateParams params, Table table,
+ EventSequence catalogTimeline) throws ImpalaException {
Preconditions.checkState(table.isWriteLockedByCurrentThread());
Preconditions.checkState(catalog_.getLock().isWriteLockedByCurrentThread());
Preconditions.checkState(table instanceof FeIcebergTable);
@@ -3285,8 +3347,8 @@ public class CatalogOpExecutor {
newCatalogVersion);
FeIcebergTable iceTbl = (FeIcebergTable)table;
if (params.isDelete_stats()) {
- dropColumnStats(table);
- dropTableStats(table);
+ dropColumnStats(table, catalogTimeline);
+ dropTableStats(table, catalogTimeline);
}
org.apache.iceberg.Transaction iceTxn = IcebergUtil.getIcebergTransaction(iceTbl);
IcebergCatalogOpExecutor.truncateTable(iceTxn);
@@ -3299,8 +3361,8 @@ public class CatalogOpExecutor {
return newCatalogVersion;
}
- private long truncateNonTransactionalTable(TTruncateParams params, Table table)
- throws Exception {
+ private long truncateNonTransactionalTable(TTruncateParams params, Table table,
+ EventSequence catalogTimeline) throws Exception {
Preconditions.checkState(table.isWriteLockedByCurrentThread());
Preconditions.checkState(catalog_.getLock().isWriteLockedByCurrentThread());
long newCatalogVersion = catalog_.incrementAndGetCatalogVersion();
@@ -3313,12 +3375,13 @@ public class CatalogOpExecutor {
try {
// if the table is being replicated we issue the HMS API to truncate the table
// since it generates additional events which are used by Hive Replication.
- try (MetaStoreClient metaStoreClient = catalog_.getMetaStoreClient()) {
- if (isTableBeingReplicated(metaStoreClient.getHiveClient(), hdfsTable)) {
+ try (MetaStoreClient client = catalog_.getMetaStoreClient(catalogTimeline)) {
+ if (isTableBeingReplicated(client.getHiveClient(), hdfsTable)) {
isTableBeingReplicated = true;
String dbName = Preconditions.checkNotNull(hdfsTable.getDb()).getName();
- metaStoreClient.getHiveClient()
+ client.getHiveClient()
.truncateTable(dbName, hdfsTable.getName(), null);
+ catalogTimeline.markEvent("Truncated table in Metastore");
LOG.trace("Time elapsed after truncating table {} using HMS API: {} msec",
hdfsTable.getFullName(), sw.elapsed(TimeUnit.MILLISECONDS));
}
@@ -3331,12 +3394,13 @@ public class CatalogOpExecutor {
for (FeFsPartition part : parts) {
FileSystemUtil.deleteAllVisibleFiles(new Path(part.getLocation()));
}
+ catalogTimeline.markEvent("Deleted all visible files");
LOG.trace("Time elapsed after deleting files for table {}: {} msec",
table.getFullName(), sw.elapsed(TimeUnit.MILLISECONDS));
}
if (params.isDelete_stats()) {
- dropColumnStats(table);
- dropTableStats(table);
+ dropColumnStats(table, catalogTimeline);
+ dropTableStats(table, catalogTimeline);
LOG.trace("Time elapsed after deleting statistics for table {}: {} msec ",
table.getFullName(), sw.elapsed(TimeUnit.MILLISECONDS));
}
@@ -3369,8 +3433,8 @@ public class CatalogOpExecutor {
}
}
- private void dropFunction(TDropFunctionParams params, TDdlExecResponse resp)
- throws ImpalaException {
+ private void dropFunction(TDropFunctionParams params, TDdlExecResponse resp,
+ EventSequence catalogTimeline) throws ImpalaException {
FunctionName fName = FunctionName.fromThrift(params.fn_name);
Db db = catalog_.getDb(fName.getDb());
if (db == null) {
@@ -3382,7 +3446,7 @@ public class CatalogOpExecutor {
return;
}
- tryLock(db, "dropping function " + fName);
+ tryLock(db, "dropping function " + fName, catalogTimeline);
// Get a new catalog version to assign to the database being altered. This is
// needed for events processor as this method creates alter database events.
long newCatalogVersion = catalog_.incrementAndGetCatalogVersion();
@@ -3390,7 +3454,8 @@ public class CatalogOpExecutor {
try {
List<TCatalogObject> removedFunctions = Lists.newArrayList();
if (!params.isSetSignature()) {
- dropJavaFunctionFromHms(fName.getDb(), fName.getFunction(), params.if_exists);
+ dropJavaFunctionFromHms(fName.getDb(), fName.getFunction(), params.if_exists,
+ catalogTimeline);
for (Function fn : db.getFunctions(fName.getFunction())) {
if (fn.getBinaryType() != TFunctionBinaryType.JAVA
|| !fn.isPersistent()) {
@@ -3406,6 +3471,7 @@ public class CatalogOpExecutor {
}
Function desc = new Function(fName, argTypes, Type.INVALID, false);
Function fn = catalog_.removeFunction(desc);
+ catalogTimeline.markEvent("Removed function in catalog cache");
if (fn == null) {
if (!params.if_exists) {
throw new CatalogException(
@@ -3415,7 +3481,7 @@ public class CatalogOpExecutor {
addCatalogServiceIdentifiers(db.getMetaStoreDb(),
catalog_.getCatalogServiceId(), newCatalogVersion);
// Flush DB changes to metastore
- applyAlterDatabase(db.getMetaStoreDb());
+ applyAlterDatabase(db.getMetaStoreDb(), catalogTimeline);
removedFunctions.add(fn.toTCatalogObject());
// now that HMS alter operation has succeeded, add this version to list of
// inflight events in catalog database if event processing is enabled.
@@ -3461,8 +3527,7 @@ public class CatalogOpExecutor {
addSummary(response, "Table already exists.");
LOG.trace("Skipping table creation because {} already exists and " +
"IF NOT EXISTS was specified.", tableName);
- tryWriteLock(existingTbl);
- catalogTimeline.markEvent(GOT_TABLE_WRITE_LOCK);
+ tryWriteLock(existingTbl, catalogTimeline);
try {
if (syncDdl) {
// When SYNC_DDL is enabled and the table already exists, we force a version
@@ -3678,8 +3743,8 @@ public class CatalogOpExecutor {
try {
// Error creating the table in HMS, drop the synchronized table from Kudu.
if (!KuduTable.isSynchronizedTable(newTable)) {
- KuduCatalogOpExecutor.dropTable(
- newTable, /* if exists */ false, /* kudu_table_reserve_seconds */ 0);
+ KuduCatalogOpExecutor.dropTable(newTable, /* if exists */ false,
+ /* kudu_table_reserve_seconds */ 0, catalogTimeline);
}
} catch (Exception logged) {
String kuduTableName = newTable.getParameters().get(KuduTable.KEY_TABLE_NAME);
@@ -3793,7 +3858,7 @@ public class CatalogOpExecutor {
// reloading the table when the alter_table event is received later.
addCatalogServiceIdentifiers(msTable, catalog_.getCatalogServiceId(),
newTbl.getCatalogVersion());
- applyAlterTable(msTable);
+ applyAlterTable(msTable, catalogTimeline);
newTbl.addToVersionsForInflightEvents(false, newTbl.getCatalogVersion());
}
addTableToCatalogUpdate(newTbl, wantMinimalResult, response.result);
@@ -3872,7 +3937,7 @@ public class CatalogOpExecutor {
Map<String, String> tableProperties, String tblComment) throws ImpalaException {
Preconditions.checkState(IcebergTable.isIcebergTable(newTable));
- getMetastoreDdlLock().lock();
+ acquireMetastoreDdlLock(catalogTimeline);
try {
// Add the table to the HMS and the catalog cache. Acquire metastoreDdlLock_ to
// ensure the atomicity of these operations.
@@ -4015,7 +4080,7 @@ public class CatalogOpExecutor {
addSummary(response, "Table already exists.");
LOG.trace(String.format("Skipping table creation because %s already exists and " +
"IF NOT EXISTS was specified.", tblName));
- tryWriteLock(existingTbl);
+ tryWriteLock(existingTbl, catalogTimeline);
try {
if (syncDdl) {
// When SYNC_DDL is enabled and the table already exists, we force a version
@@ -4042,7 +4107,7 @@ public class CatalogOpExecutor {
return;
}
Table srcTable = getExistingTable(srcTblName.getDb(), srcTblName.getTbl(),
- "Load source for CREATE TABLE LIKE");
+ "Load source for CREATE TABLE LIKE", catalogTimeline);
org.apache.hadoop.hive.metastore.api.Table tbl =
srcTable.getMetaStoreTable().deepCopy();
tbl.setDbName(tblName.getDb());
@@ -4264,8 +4329,8 @@ public class CatalogOpExecutor {
* Appends one or more columns to the given table. Returns true if there a column was
* added; false otherwise.
*/
- private boolean alterTableAddCols(Table tbl, List<TColumn> columns, boolean ifNotExists)
- throws ImpalaException {
+ private boolean alterTableAddCols(Table tbl, List<TColumn> columns, boolean ifNotExists,
+ EventSequence catalogTimeline) throws ImpalaException {
Preconditions.checkState(tbl.isWriteLockedByCurrentThread());
org.apache.hadoop.hive.metastore.api.Table msTbl = tbl.getMetaStoreTable().deepCopy();
List<TColumn> colsToAdd = new ArrayList<>();
@@ -4283,7 +4348,7 @@ public class CatalogOpExecutor {
if (!colsToAdd.isEmpty()) {
// Append the new column to the existing list of columns.
msTbl.getSd().getCols().addAll(buildFieldSchemaList(colsToAdd));
- applyAlterTable(msTbl);
+ applyAlterTable(msTbl, catalogTimeline);
return true;
}
return false;
@@ -4292,8 +4357,8 @@ public class CatalogOpExecutor {
/**
* Replaces all existing columns to the given table.
*/
- private void alterTableReplaceCols(Table tbl, List<TColumn> columns)
- throws ImpalaException {
+ private void alterTableReplaceCols(Table tbl, List<TColumn> columns,
+ EventSequence catalogTimeline) throws ImpalaException {
Preconditions.checkState(tbl.isWriteLockedByCurrentThread());
org.apache.hadoop.hive.metastore.api.Table msTbl = tbl.getMetaStoreTable().deepCopy();
List<FieldSchema> newColumns = buildFieldSchemaList(columns);
@@ -4305,7 +4370,7 @@ public class CatalogOpExecutor {
columns);
msTbl.getParameters().put(sortByKey, alteredColumns);
}
- applyAlterTable(msTbl);
+ applyAlterTable(msTbl, catalogTimeline);
}
/**
@@ -4313,7 +4378,7 @@ public class CatalogOpExecutor {
* column, add a comment to a column, or change the datatype of a column.
*/
private void alterTableAlterCol(Table tbl, String colName,
- TColumn newCol) throws ImpalaException {
+ TColumn newCol, EventSequence catalogTimeline) throws ImpalaException {
Preconditions.checkState(tbl.isWriteLockedByCurrentThread());
org.apache.hadoop.hive.metastore.api.Table msTbl = tbl.getMetaStoreTable().deepCopy();
// Find the matching column name and change it.
@@ -4342,7 +4407,7 @@ public class CatalogOpExecutor {
"Column name %s not found in table %s.", colName, tbl.getFullName()));
}
}
- applyAlterTable(msTbl);
+ applyAlterTable(msTbl, catalogTimeline);
}
/**
@@ -4361,8 +4426,8 @@ public class CatalogOpExecutor {
* catalog cache and the HMS.
*/
private Table alterTableAddPartitions(Table tbl,
- TAlterTableAddPartitionParams addPartParams, THdfsFileFormat fileFormat)
- throws ImpalaException {
+ TAlterTableAddPartitionParams addPartParams, THdfsFileFormat fileFormat,
+ EventSequence catalogTimeline) throws ImpalaException {
Preconditions.checkState(tbl.isWriteLockedByCurrentThread());
TableName tableName = tbl.getTableName();
@@ -4398,15 +4463,15 @@ public class CatalogOpExecutor {
if (allHmsPartitionsToAdd.isEmpty()) return null;
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
Map<String, Long> partitionToEventId = catalog_.isEventProcessingActive() ?
Maps.newHashMap() : null;
List<Partition> addedHmsPartitions = addHmsPartitionsInTransaction(msClient,
- tbl, allHmsPartitionsToAdd, partitionToEventId, ifNotExists);
+ tbl, allHmsPartitionsToAdd, partitionToEventId, ifNotExists, catalogTimeline);
// Handle HDFS cache. This is done in a separate round bacause we have to apply
// caching only to newly added partitions.
alterTableCachePartitions(msTbl, msClient, tableName, addedHmsPartitions,
- partitionCachingOpMap);
+ partitionCachingOpMap, catalogTimeline);
// If 'ifNotExists' is true, add_partitions() may fail to add all the partitions to
// HMS because some of them may already exist there. In that case, we load in the
@@ -4417,7 +4482,8 @@ public class CatalogOpExecutor {
addedHmsPartitions.addAll(
getPartitionsFromHms(msTbl, msClient, difference));
}
- addHdfsPartitions(msClient, tbl, addedHmsPartitions, partitionToEventId);
+ addHdfsPartitions(msClient, tbl, addedHmsPartitions, partitionToEventId,
+ catalogTimeline);
}
return tbl;
}
@@ -4470,7 +4536,7 @@ public class CatalogOpExecutor {
boolean syncToLatestEventId =
BackendConfig.INSTANCE.enableSyncToLatestEventOnDdls();
try {
- tryWriteLock(table, reason);
+ tryWriteLock(table, reason, NoOpEventSequence.INSTANCE);
if (syncToLatestEventId && table.getLastSyncedEventId() >= eventId) {
LOG.info("Not adding partitions from event id: {} since table {} is already "
+ "synced till event id {}", eventId, table.getFullName(),
@@ -4492,7 +4558,8 @@ public class CatalogOpExecutor {
.put(FeCatalogUtils.getPartitionName(hdfsTable, part.getValues()), eventId);
}
try (MetaStoreClient metaStoreClient = catalog_.getMetaStoreClient()) {
- addHdfsPartitions(metaStoreClient, table, partitionsToAdd, partToEventId);
+ addHdfsPartitions(metaStoreClient, table, partitionsToAdd, partToEventId,
+ NoOpEventSequence.INSTANCE);
}
table.setCatalogVersion(newCatalogVersion);
partitionsAdded = partitionsToAdd.size();
@@ -4612,7 +4679,7 @@ public class CatalogOpExecutor {
boolean errorOccured = false;
try {
- tryWriteLock(table, reason);
+ tryWriteLock(table, reason, NoOpEventSequence.INSTANCE);
if (syncToLatestEventId && table.getLastSyncedEventId() >= eventId) {
LOG.info("Not dropping partitions from event id: {} since table {} is already "
+ "synced till event id {}", eventId, table.getFullName(),
@@ -4787,7 +4854,7 @@ public class CatalogOpExecutor {
boolean errorOccured = false;
try {
- tryWriteLock(table, reason);
+ tryWriteLock(table, reason, NoOpEventSequence.INSTANCE);
long newCatalogVersion = catalog_.incrementAndGetCatalogVersion();
catalog_.getLock().writeLock().unlock();
if (syncToLatestEventId && table.getLastSyncedEventId() >= eventId) {
@@ -4873,7 +4940,7 @@ public class CatalogOpExecutor {
return 0;
}
try {
- tryWriteLock(table, reason);
+ tryWriteLock(table, reason, NoOpEventSequence.INSTANCE);
long newCatalogVersion = catalog_.incrementAndGetCatalogVersion();
catalog_.getLock().writeLock().unlock();
HdfsTable hdfsTable = (HdfsTable) table;
@@ -4936,7 +5003,7 @@ public class CatalogOpExecutor {
HdfsTable hdfsTable = (HdfsTable) table;
ValidWriteIdList previousWriteIdList = hdfsTable.getValidWriteIds();
try {
- tryWriteLock(table, reason);
+ tryWriteLock(table, reason, NoOpEventSequence.INSTANCE);
long newCatalogVersion = catalog_.incrementAndGetCatalogVersion();
catalog_.getLock().writeLock().unlock();
boolean syncToLatestEvent =
@@ -5032,9 +5099,9 @@ public class CatalogOpExecutor {
*/
private List<Partition> addHmsPartitions(MetaStoreClient msClient,
Table tbl, List<Partition> allHmsPartitionsToAdd,
- @Nullable Map<String, Long> partitionToEventId, boolean ifNotExists)
- throws ImpalaRuntimeException, CatalogException {
- long eventId = getCurrentEventId(msClient);
+ @Nullable Map<String, Long> partitionToEventId, boolean ifNotExists,
+ EventSequence catalogTimeline) throws ImpalaRuntimeException, CatalogException {
+ long eventId = getCurrentEventId(msClient, catalogTimeline);
List<Partition> addedHmsPartitions = Lists
.newArrayListWithCapacity(allHmsPartitionsToAdd.size());
long numDone = 0;
@@ -5045,14 +5112,17 @@ public class CatalogOpExecutor {
msClient.getHiveClient(), tbl.getMetaStoreTable(),
hmsSublist, ifNotExists, true);
numDone += hmsSublist.size();
+ catalogTimeline.markEvent(String.format(
+ "Added %d partitions in Metastore", numDone));
LOG.info("Added {}/{} partitions in HMS for table {}", numDone,
allHmsPartitionsToAdd.size(), tbl.getFullName());
org.apache.hadoop.hive.metastore.api.Table msTbl = tbl.getMetaStoreTable();
- List<NotificationEvent> events = getNextMetastoreEventsIfEnabled(eventId,
- event -> AddPartitionEvent.ADD_PARTITION_EVENT_TYPE
- .equals(event.getEventType())
- && msTbl.getDbName().equalsIgnoreCase(event.getDbName())
- && msTbl.getTableName().equalsIgnoreCase(event.getTableName()));
+ List<NotificationEvent> events = getNextMetastoreEventsIfEnabled(
+ catalogTimeline, eventId,
+ event -> AddPartitionEvent.ADD_PARTITION_EVENT_TYPE
+ .equals(event.getEventType())
+ && msTbl.getDbName().equalsIgnoreCase(event.getDbName())
+ && msTbl.getTableName().equalsIgnoreCase(event.getTableName()));
Map<Partition, Long> partitionToEventSubMap = Maps.newHashMap();
getPartitionsFromEvent(events, partitionToEventSubMap);
// set the eventId to last one which we received so the we fetch the next
@@ -5094,10 +5164,10 @@ public class CatalogOpExecutor {
*/
private List<Partition> addHmsPartitionsInTransaction(MetaStoreClient msClient,
Table tbl, List<Partition> partitions, Map<String, Long> partitionToEventId,
- boolean ifNotExists) throws ImpalaException {
+ boolean ifNotExists, EventSequence catalogTimeline) throws ImpalaException {
if (!AcidUtils.isTransactionalTable(tbl.getMetaStoreTable().getParameters())) {
return addHmsPartitions(msClient, tbl, partitions, partitionToEventId,
- ifNotExists);
+ ifNotExists, catalogTimeline);
}
try (Transaction txn = new Transaction(
msClient.getHiveClient(),
@@ -5106,7 +5176,7 @@ public class CatalogOpExecutor {
MetastoreShim.allocateTableWriteId(msClient.getHiveClient(), txn.getId(),
tbl.getDb().getName(), tbl.getName());
List<Partition> ret = addHmsPartitions(msClient, tbl, partitions,
- partitionToEventId, ifNotExists);
+ partitionToEventId, ifNotExists, catalogTimeline);
txn.commit();
return ret;
}
@@ -5160,8 +5230,8 @@ public class CatalogOpExecutor {
*/
private void alterTableCachePartitions(org.apache.hadoop.hive.metastore.api.Table msTbl,
MetaStoreClient msClient, TableName tableName, List<Partition> hmsPartitions,
- Map<List<String>, THdfsCachingOp> partitionCachingOpMap)
- throws ImpalaException {
+ Map<List<String>, THdfsCachingOp> partitionCachingOpMap,
+ EventSequence catalogTimeline) throws ImpalaException {
// Handle HDFS cache
List<Long> cacheIds = Lists.newArrayList();
List<Partition> hmsPartitionsToCache = Lists.newArrayList();
@@ -5205,7 +5275,7 @@ public class CatalogOpExecutor {
for (Partition part : hmsPartitionsToCache) {
addCatalogServiceIdentifiers(msTbl, part);
}
- applyAlterHmsPartitions(msTbl, msClient, tableName, hmsPartitionsToCache);
+ applyAlterHmsPartitions(msClient, tableName, hmsPartitionsToCache, catalogTimeline);
catalog_.watchCacheDirs(cacheIds, tableName.toThrift(),
"ALTER TABLE CACHE PARTITIONS");
}
@@ -5222,8 +5292,8 @@ public class CatalogOpExecutor {
*/
private Table alterTableDropPartition(Table tbl,
List<List<TPartitionKeyValue>> partitionSet,
- boolean ifExists, boolean purge, Reference<Long> numUpdatedPartitions)
- throws ImpalaException {
+ boolean ifExists, boolean purge, Reference<Long> numUpdatedPartitions,
+ EventSequence catalogTimeline) throws ImpalaException {
Preconditions.checkState(tbl.isWriteLockedByCurrentThread());
Preconditions.checkNotNull(partitionSet);
@@ -5253,8 +5323,8 @@ public class CatalogOpExecutor {
// droppedPartitionsFromEvent maps the eventId to the list of partition values
// for all the partitions which are received in that event.
Map<Long, List<List<String>>> droppedPartsFromEvent = Maps.newHashMap();
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
- long currentEventId = getCurrentEventId(msClient);
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
+ long currentEventId = getCurrentEventId(msClient, catalogTimeline);
//TODO batch drop the partitions instead of one-by-one.
for (HdfsPartition part : parts) {
try {
@@ -5270,10 +5340,12 @@ public class CatalogOpExecutor {
String.format("Ignoring '%s' when dropping partitions from %s because" +
" ifExists is true.", e, tableName));
}
+ catalogTimeline.markEvent("Dropped partitions in Metastore");
}
- List<NotificationEvent> events = getNextMetastoreEventsIfEnabled(currentEventId,
- notificationEvent ->
- tableName.getDb().equalsIgnoreCase(notificationEvent.getDbName())
+ List<NotificationEvent> events = getNextMetastoreEventsIfEnabled(
+ catalogTimeline, currentEventId,
+ notificationEvent ->
+ tableName.getDb().equalsIgnoreCase(notificationEvent.getDbName())
&& tableName.getTbl().equalsIgnoreCase(notificationEvent.getTableName())
&& DropPartitionEvent.EVENT_TYPE
.equals(notificationEvent.getEventType()));
@@ -5301,7 +5373,8 @@ public class CatalogOpExecutor {
/**
* Removes a column from the given table.
*/
- private void alterTableDropCol(Table tbl, String colName) throws ImpalaException {
+ private void alterTableDropCol(Table tbl, String colName,
+ EventSequence catalogTimeline) throws ImpalaException {
Preconditions.checkState(tbl.isWriteLockedByCurrentThread());
org.apache.hadoop.hive.metastore.api.Table msTbl = tbl.getMetaStoreTable().deepCopy();
// Find the matching column name and remove it.
@@ -5323,7 +5396,7 @@ public class CatalogOpExecutor {
String alteredColumns = MetaStoreUtil.removeValueFromCsvList(oldColumns, colName);
msTbl.getParameters().put(sortByKey, alteredColumns);
}
- applyAlterTable(msTbl);
+ applyAlterTable(msTbl, catalogTimeline);
}
/**
@@ -5332,8 +5405,8 @@ public class CatalogOpExecutor {
* reloaded on the next access.
*/
private void alterTableOrViewRename(Table oldTbl, TableName newTableName,
- long newCatalogVersion, boolean wantMinimalResult, TDdlExecResponse response)
- throws ImpalaException {
+ long newCatalogVersion, boolean wantMinimalResult, TDdlExecResponse response,
+ EventSequence catalogTimeline) throws ImpalaException {
Preconditions.checkState(oldTbl.isWriteLockedByCurrentThread()
&& catalog_.getLock().isWriteLockedByCurrentThread());
TableName tableName = oldTbl.getTableName();
@@ -5342,8 +5415,9 @@ public class CatalogOpExecutor {
msTbl.setDbName(newTableName.getDb());
msTbl.setTableName(newTableName.getTbl());
long eventId = -1;
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
eventId = getCurrentEventId(msClient);
+ catalogTimeline.markEvent(FETCHED_LATEST_HMS_EVENT_ID + eventId);
}
// If oldTbl is a synchronized Kudu table, rename the underlying Kudu table.
boolean isSynchronizedKuduTable = (oldTbl instanceof KuduTable) &&
@@ -5351,7 +5425,8 @@ public class CatalogOpExecutor {
boolean integratedHmsTable = isHmsIntegrationAutomatic(msTbl);
if (isSynchronizedKuduTable) {
Preconditions.checkState(KuduTable.isKuduTable(msTbl));
- renameManagedKuduTable((KuduTable) oldTbl, msTbl, newTableName, integratedHmsTable);
+ renameManagedKuduTable((KuduTable) oldTbl, msTbl, newTableName, integratedHmsTable,
+ catalogTimeline);
}
// If oldTbl is a synchronized Iceberg table, rename the underlying Iceberg table.
@@ -5359,6 +5434,7 @@ public class CatalogOpExecutor {
IcebergTable.isSynchronizedTable(msTbl);
if (isSynchronizedIcebergTable) {
renameManagedIcebergTable((IcebergTable) oldTbl, msTbl, newTableName);
+ catalogTimeline.markEvent("Renamed table in Iceberg");
}
boolean isSynchronizedTable = isSynchronizedKuduTable || isSynchronizedIcebergTable;
@@ -5366,17 +5442,18 @@ public class CatalogOpExecutor {
// is automatic.
boolean needsHmsAlterTable = !isSynchronizedTable || !integratedHmsTable;
if (needsHmsAlterTable) {
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
Table.updateTimestampProperty(msTbl, Table.TBL_PROP_LAST_DDL_TIME);
msClient.getHiveClient().alter_table(
tableName.getDb(), tableName.getTbl(), msTbl);
+ catalogTimeline.markEvent("Renamed table in Metastore");
} catch (TException e) {
throw new ImpalaRuntimeException(
String.format(HMS_RPC_ERROR_FORMAT_STR, "alter_table"), e);
}
}
List<NotificationEvent> events = null;
- events = getNextMetastoreEventsIfEnabled(eventId,
+ events = getNextMetastoreEventsIfEnabled(catalogTimeline, eventId,
event -> "ALTER_TABLE".equals(event.getEventType())
// the alter table event is generated on the renamed table
&& msTbl.getDbName().equalsIgnoreCase(event.getDbName())
@@ -5441,8 +5518,8 @@ public class CatalogOpExecutor {
*/
private void renameManagedKuduTable(KuduTable oldTbl,
org.apache.hadoop.hive.metastore.api.Table oldMsTbl,
- TableName newTableName, boolean isHMSIntegrationEanbled)
- throws ImpalaRuntimeException {
+ TableName newTableName, boolean isHMSIntegrationEanbled,
+ EventSequence catalogTimeline) throws ImpalaRuntimeException {
String newKuduTableName = KuduUtil.getDefaultKuduTableName(
newTableName.getDb(), newTableName.getTbl(),
isHMSIntegrationEanbled);
@@ -5450,7 +5527,7 @@ public class CatalogOpExecutor {
// If the name of the Kudu table has not changed, do nothing
if (oldTbl.getKuduTableName().equals(newKuduTableName)) return;
- KuduCatalogOpExecutor.renameTable(oldTbl, newKuduTableName);
+ KuduCatalogOpExecutor.renameTable(oldTbl, newKuduTableName, catalogTimeline);
// Add the name of the new Kudu table to the HMS table parameters
oldMsTbl.getParameters().put(KuduTable.KEY_TABLE_NAME, newKuduTableName);
@@ -5481,7 +5558,7 @@ public class CatalogOpExecutor {
*/
private boolean alterTableSetFileFormat(Table tbl,
List<List<TPartitionKeyValue>> partitionSet, THdfsFileFormat fileFormat,
- Reference<Long> numUpdatedPartitions)
+ Reference<Long> numUpdatedPartitions, EventSequence catalogTimeline)
throws ImpalaException {
Preconditions.checkState(tbl.isWriteLockedByCurrentThread());
boolean reloadFileMetadata = false;
@@ -5492,7 +5569,7 @@ public class CatalogOpExecutor {
// The prototype partition must be updated if the file format is changed so that new
// partitions are created with the new file format.
if (tbl instanceof HdfsTable) ((HdfsTable) tbl).setPrototypePartition(msTbl.getSd());
- applyAlterTable(msTbl);
+ applyAlterTable(msTbl, catalogTimeline);
reloadFileMetadata = true;
} else {
Preconditions.checkArgument(tbl instanceof HdfsTable);
@@ -5503,7 +5580,8 @@ public class CatalogOpExecutor {
modifiedParts.add(new HdfsPartition.Builder(partition).setFileFormat(
HdfsFileFormat.fromThrift(fileFormat)));
}
- bulkAlterPartitions(tbl, modifiedParts, null, UpdatePartitionMethod.MARK_DIRTY);
+ bulkAlterPartitions(tbl, modifiedParts, null, UpdatePartitionMethod.MARK_DIRTY,
+ catalogTimeline);
numUpdatedPartitions.setRef((long) modifiedParts.size());
}
return reloadFileMetadata;
@@ -5516,7 +5594,7 @@ public class CatalogOpExecutor {
*/
private boolean alterTableSetRowFormat(Table tbl,
List<List<TPartitionKeyValue>> partitionSet, TTableRowFormat tRowFormat,
- Reference<Long> numUpdatedPartitions)
+ Reference<Long> numUpdatedPartitions, EventSequence catalogTimeline)
throws ImpalaException {
Preconditions.checkState(tbl.isWriteLockedByCurrentThread());
Preconditions.checkArgument(tbl instanceof HdfsTable);
@@ -5530,7 +5608,7 @@ public class CatalogOpExecutor {
// The prototype partition must be updated if the row format is changed so that new
// partitions are created with the new file format.
((HdfsTable) tbl).setPrototypePartition(msTbl.getSd());
- applyAlterTable(msTbl);
+ applyAlterTable(msTbl, catalogTimeline);
reloadFileMetadata = true;
} else {
List<HdfsPartition> partitions =
@@ -5541,7 +5619,8 @@ public class CatalogOpExecutor {
HiveStorageDescriptorFactory.setSerdeInfo(rowFormat, partBuilder.getSerdeInfo());
modifiedParts.add(partBuilder);
}
- bulkAlterPartitions(tbl, modifiedParts, null, UpdatePartitionMethod.MARK_DIRTY);
+ bulkAlterPartitions(tbl, modifiedParts, null, UpdatePartitionMethod.MARK_DIRTY,
+ catalogTimeline);
numUpdatedPartitions.setRef((long) modifiedParts.size());
}
return reloadFileMetadata;
@@ -5564,7 +5643,8 @@ public class CatalogOpExecutor {
* operation, existing table data will not be as part of changing the location.
*/
private boolean alterTableSetLocation(Table tbl,
- List<TPartitionKeyValue> partitionSpec, String location) throws ImpalaException {
+ List<TPartitionKeyValue> partitionSpec, String location,
+ EventSequence catalogTimeline) throws ImpalaException {
Preconditions.checkState(tbl.isWriteLockedByCurrentThread());
boolean reloadFileMetadata = false;
if (partitionSpec == null) {
@@ -5572,7 +5652,7 @@ public class CatalogOpExecutor {
tbl.getMetaStoreTable().deepCopy();
if (msTbl.getPartitionKeysSize() == 0) reloadFileMetadata = true;
msTbl.getSd().setLocation(location);
- applyAlterTable(msTbl);
+ applyAlterTable(msTbl, catalogTimeline);
} else {
TableName tableName = tbl.getTableName();
HdfsPartition partition = catalog_.getHdfsPartition(
@@ -5580,7 +5660,7 @@ public class CatalogOpExecutor {
HdfsPartition.Builder partBuilder = new HdfsPartition.Builder(partition);
partBuilder.setLocation(location);
try {
- applyAlterPartition(tbl, partBuilder);
+ applyAlterPartition(tbl, partBuilder, catalogTimeline);
} finally {
((HdfsTable) tbl).markDirtyPartition(partBuilder);
}
@@ -5593,8 +5673,8 @@ public class CatalogOpExecutor {
* the values of any keys that already exist.
*/
private void alterTableSetTblProperties(Table tbl,
- TAlterTableSetTblPropertiesParams params, Reference<Long> numUpdatedPartitions)
- throws ImpalaException {
+ TAlterTableSetTblPropertiesParams params, Reference<Long> numUpdatedPartitions,
+ EventSequence catalogTimeline) throws ImpalaException {
Preconditions.checkState(tbl.isWriteLockedByCurrentThread());
Map<String, String> properties = params.getProperties();
Preconditions.checkNotNull(properties);
@@ -5621,7 +5701,8 @@ public class CatalogOpExecutor {
}
try {
// Do not mark the partitions dirty here since it's done in finally clause.
- bulkAlterPartitions(tbl, modifiedParts, null, UpdatePartitionMethod.NONE);
+ bulkAlterPartitions(tbl, modifiedParts, null, UpdatePartitionMethod.NONE,
+ catalogTimeline);
} finally {
((HdfsTable) tbl).markDirtyPartitions(modifiedParts);
}
@@ -5641,7 +5722,7 @@ public class CatalogOpExecutor {
msTbl.getParameters().get(KuduTable.KEY_TABLE_NAME))
&& KuduTable.isSynchronizedTable(msTbl)) {
KuduCatalogOpExecutor.renameTable((KuduTable) tbl,
- properties.get(KuduTable.KEY_TABLE_NAME));
+ properties.get(KuduTable.KEY_TABLE_NAME), catalogTimeline);
}
msTbl.getParameters().putAll(properties);
// Validate that the new table properties are valid and that
@@ -5658,13 +5739,13 @@ public class CatalogOpExecutor {
throw new UnsupportedOperationException(
"Unknown target TTablePropertyType: " + params.getTarget());
}
- applyAlterTable(msTbl);
+ applyAlterTable(msTbl, catalogTimeline);
}
}
private void alterTableUnSetTblProperties(Table tbl,
- TAlterTableUnSetTblPropertiesParams params, Reference<Long> numUpdatedPartitions)
- throws ImpalaException {
+ TAlterTableUnSetTblPropertiesParams params, Reference<Long> numUpdatedPartitions,
+ EventSequence catalogTimeline) throws ImpalaException {
Preconditions.checkState(tbl.isWriteLockedByCurrentThread());
List<String> removeProperties = params.getProperty_keys();
boolean ifExists = params.isIf_exists();
@@ -5697,7 +5778,8 @@ public class CatalogOpExecutor {
}
try {
// Do not mark the partitions dirty here since it's done in finally clause.
- bulkAlterPartitions(tbl, modifiedParts, null, UpdatePartitionMethod.NONE);
+ bulkAlterPartitions(tbl, modifiedParts, null, UpdatePartitionMethod.NONE,
+ catalogTimeline);
} finally {
((HdfsTable) tbl).markDirtyPartitions(modifiedParts);
}
@@ -5725,7 +5807,7 @@ public class CatalogOpExecutor {
if (KuduTable.isKuduTable(msTbl)) {
KuduCatalogOpExecutor.validateKuduTblExists(msTbl);
}
- applyAlterTable(msTbl);
+ applyAlterTable(msTbl, catalogTimeline);
}
}
@@ -5734,7 +5816,8 @@ public class CatalogOpExecutor {
* the values of any keys that already exist.
*/
private void alterViewSetTblProperties(Table tbl,
- TAlterTableSetTblPropertiesParams params) throws ImpalaException {
+ TAlterTableSetTblPropertiesParams params, EventSequence catalogTimeline)
+ throws ImpalaException {
Preconditions.checkState(tbl.isWriteLockedByCurrentThread());
Map<String, String> properties = params.getProperties();
Preconditions.checkNotNull(properties);
@@ -5743,11 +5826,12 @@ public class CatalogOpExecutor {
org.apache.hadoop.hive.metastore.api.Table msTbl =
tbl.getMetaStoreTable().deepCopy();
msTbl.getParameters().putAll(properties);
- applyAlterTable(msTbl);
+ applyAlterTable(msTbl, catalogTimeline);
}
private void alterViewUnSetTblProperties(Table tbl,
- TAlterTableUnSetTblPropertiesParams params) throws ImpalaException {
+ TAlterTableUnSetTblPropertiesParams params, EventSequence catalogTimeline)
+ throws ImpalaException {
Preconditions.checkState(tbl.isWriteLockedByCurrentThread());
List<String> removeProperties = params.getProperty_keys();
boolean ifExists = params.isIf_exists();
@@ -5758,7 +5842,7 @@ public class CatalogOpExecutor {
Set<String> keys = msTbl.getParameters().keySet();
removeKeys(removeProperties, ifExists, keys,
"view " + tbl.getFullName(), ALTER_VIEW_UNSET_NON_EXIST_PROPERTY);
- applyAlterTable(msTbl);
+ applyAlterTable(msTbl, catalogTimeline);
}
private void removeKeys(List<String> removeProperties, boolean ifExists,
@@ -5786,8 +5870,8 @@ public class CatalogOpExecutor {
* marks the partitions that are affected as 'dirty'. For unpartitioned tables, it
* returns true to indicate that the file metadata of the table must be reloaded.
*/
- private boolean alterTableSetCached(Table tbl, TAlterTableSetCachedParams params)
- throws ImpalaException {
+ private boolean alterTableSetCached(Table tbl, TAlterTableSetCachedParams params,
+ EventSequence catalogTimeline) throws ImpalaException {
Preconditions.checkArgument(tbl.isWriteLockedByCurrentThread());
THdfsCachingOp cacheOp = params.getCache_op();
Preconditions.checkNotNull(cacheOp);
@@ -5859,7 +5943,7 @@ public class CatalogOpExecutor {
// Update the partition metadata.
try {
- applyAlterPartition(tbl, partBuilder);
+ applyAlterPartition(tbl, partBuilder, catalogTimeline);
} finally {
((HdfsTable) tbl).markDirtyPartition(partBuilder);
}
@@ -5890,7 +5974,7 @@ public class CatalogOpExecutor {
HdfsPartition.Builder partBuilder = new HdfsPartition.Builder(partition);
HdfsCachingUtil.removePartitionCacheDirective(partBuilder);
try {
- applyAlterPartition(tbl, partBuilder);
+ applyAlterPartition(tbl, partBuilder, catalogTimeline);
} finally {
((HdfsTable) tbl).markDirtyPartition(partBuilder);
}
@@ -5902,7 +5986,7 @@ public class CatalogOpExecutor {
}
// Update the table metadata.
- applyAlterTable(msTbl);
+ applyAlterTable(msTbl, catalogTimeline);
return loadFileMetadata;
}
@@ -5914,8 +5998,8 @@ public class CatalogOpExecutor {
* directive ID property key will be cleared.
*/
private void alterPartitionSetCached(Table tbl,
- TAlterTableSetCachedParams params, Reference<Long> numUpdatedPartitions)
- throws ImpalaException {
+ TAlterTableSetCachedParams params, Reference<Long> numUpdatedPartitions,
+ EventSequence catalogTimeline) throws ImpalaException {
Preconditions.checkArgument(tbl.isWriteLockedByCurrentThread());
THdfsCachingOp cacheOp = params.getCache_op();
Preconditions.checkNotNull(cacheOp);
@@ -5965,7 +6049,8 @@ public class CatalogOpExecutor {
}
try {
// Do not mark the partitions dirty here since it's done in finally clause.
- bulkAlterPartitions(tbl, modifiedParts, null, UpdatePartitionMethod.NONE);
+ bulkAlterPartitions(tbl, modifiedParts, null, UpdatePartitionMethod.NONE,
+ catalogTimeline);
} finally {
((HdfsTable) tbl).markDirtyPartitions(modifiedParts);
}
@@ -5976,8 +6061,8 @@ public class CatalogOpExecutor {
* Recover partitions of specified table.
* Add partitions to metastore which exist in HDFS but not in metastore.
*/
- private void alterTableRecoverPartitions(Table tbl, @Nullable String debugAction)
- throws ImpalaException {
+ private void alterTableRecoverPartitions(Table tbl, @Nullable String debugAction,
+ EventSequence catalogTimeline) throws ImpalaException {
Preconditions.checkArgument(tbl.isWriteLockedByCurrentThread());
if (!(tbl instanceof HdfsTable)) {
throw new CatalogException("Table " + tbl.getFullName() + " is not an HDFS table");
@@ -6015,10 +6100,11 @@ public class CatalogOpExecutor {
String annotation = String.format("Recovering %d partitions for %s",
hmsPartitions.size(), tbl.getFullName());
try (ThreadNameAnnotator tna = new ThreadNameAnnotator(annotation);
- MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
List<Partition> addedPartitions = addHmsPartitions(msClient, tbl, hmsPartitions,
- partitionToEventId, true);
- addHdfsPartitions(msClient, tbl, addedPartitions, partitionToEventId);
+ partitionToEventId, true, catalogTimeline);
+ addHdfsPartitions(msClient, tbl, addedPartitions, partitionToEventId,
+ catalogTimeline);
// Handle HDFS cache.
if (cachePoolName != null) {
int numDone = 0;
@@ -6048,7 +6134,7 @@ public class CatalogOpExecutor {
}
private void alterTableOrViewSetOwner(Table tbl, TAlterTableOrViewSetOwnerParams params,
- TDdlExecResponse response) throws ImpalaException {
+ TDdlExecResponse response, EventSequence catalogTimeline) throws ImpalaException {
org.apache.hadoop.hive.metastore.api.Table msTbl = tbl.getMetaStoreTable().deepCopy();
String oldOwner = msTbl.getOwner();
PrincipalType oldOwnerType = msTbl.getOwnerType();
@@ -6064,10 +6150,11 @@ public class CatalogOpExecutor {
boolean isKuduHmsIntegrationEnabled = isKuduHmsIntegrationEnabled(msTbl);
// We need to update HMS when the integration between Kudu and HMS is not enabled.
altersHMSTable = !isKuduHmsIntegrationEnabled;
- KuduCatalogOpExecutor.alterSetOwner((KuduTable) tbl, params.owner_name);
+ KuduCatalogOpExecutor.alterSetOwner((KuduTable) tbl, params.owner_name,
+ catalogTimeline);
}
- if (altersHMSTable) applyAlterTable(msTbl);
+ if (altersHMSTable) applyAlterTable(msTbl, catalogTimeline);
if (authzConfig_.isEnabled()) {
authzManager_.updateTableOwnerPrivilege(params.server_name, msTbl.getDbName(),
@@ -6171,11 +6258,12 @@ public class CatalogOpExecutor {
* Creates a new function in the Hive metastore. Returns true if successful
* and false if the call fails and ifNotExists is true.
*/
- public boolean addJavaFunctionToHms(String db,
- org.apache.hadoop.hive.metastore.api.Function fn, boolean ifNotExists)
- throws ImpalaRuntimeException{
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ public boolean addJavaFunctionToHms(
+ org.apache.hadoop.hive.metastore.api.Function fn, boolean ifNotExists,
+ EventSequence catalogTimeline) throws ImpalaRuntimeException{
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
msClient.getHiveClient().createFunction(fn);
+ catalogTimeline.markEvent("Created function in Metastore");
} catch(AlreadyExistsException e) {
if (!ifNotExists) {
throw new ImpalaRuntimeException(
@@ -6195,10 +6283,11 @@ public class CatalogOpExecutor {
* Drops the given function from Hive metastore. Returns true if successful
* and false if the function does not exist and ifExists is true.
*/
- public boolean dropJavaFunctionFromHms(String db, String fn, boolean ifExists)
- throws ImpalaRuntimeException {
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ public boolean dropJavaFunctionFromHms(String db, String fn, boolean ifExists,
+ EventSequence catalogTimeline) throws ImpalaRuntimeException {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
msClient.getHiveClient().dropFunction(db, fn);
+ catalogTimeline.markEvent("Dropped function in Metastore");
} catch (NoSuchObjectException e) {
if (!ifExists) {
throw new ImpalaRuntimeException(
@@ -6275,10 +6364,11 @@ public class CatalogOpExecutor {
/**
* Updates the database object in the metastore.
*/
- private void applyAlterDatabase(Database msDb)
+ private void applyAlterDatabase(Database msDb, EventSequence catalogTimeline)
throws ImpalaRuntimeException {
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
msClient.getHiveClient().alterDatabase(msDb.getName(), msDb);
+ catalogTimeline.markEvent("Altered database in Metastore");
} catch (TException e) {
throw new ImpalaRuntimeException(
String.format(HMS_RPC_ERROR_FORMAT_STR, "alterDatabase"), e);
@@ -6286,11 +6376,11 @@ public class CatalogOpExecutor {
}
/**
- * Conveniance function to call applyAlterTable(3) with default arguments.
+ * Conveniance function to call applyAlterTable(4) with default arguments.
*/
- private void applyAlterTable(org.apache.hadoop.hive.metastore.api.Table msTbl)
- throws ImpalaRuntimeException {
- applyAlterTable(msTbl, true, null);
+ private void applyAlterTable(org.apache.hadoop.hive.metastore.api.Table msTbl,
+ EventSequence catalogTimeline) throws ImpalaRuntimeException {
+ applyAlterTable(msTbl, true, null, catalogTimeline);
}
/**
@@ -6306,9 +6396,9 @@ public class CatalogOpExecutor {
* call.
*/
private void applyAlterTable(org.apache.hadoop.hive.metastore.api.Table msTbl,
- boolean overwriteLastDdlTime, TblTransaction tblTxn)
+ boolean overwriteLastDdlTime, TblTransaction tblTxn, EventSequence catalogTimeline)
throws ImpalaRuntimeException {
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
if (overwriteLastDdlTime) {
// It would be enough to remove this table property, as HMS would fill it, but
// this would make it necessary to reload the table after alter_table in order to
@@ -6334,26 +6424,29 @@ public class CatalogOpExecutor {
String.format(HMS_RPC_ERROR_FORMAT_STR, "alter_table"), e);
}
}
+ catalogTimeline.markEvent("Altered table in Metastore");
}
}
- private void applyAlterPartition(Table tbl, HdfsPartition.Builder partBuilder)
- throws ImpalaException {
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ private void applyAlterPartition(Table tbl, HdfsPartition.Builder partBuilder,
+ EventSequence catalogTimeline) throws ImpalaException {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
Partition hmsPartition = partBuilder.toHmsPartition();
addCatalogServiceIdentifiers(tbl.getMetaStoreTable(), hmsPartition);
- applyAlterHmsPartitions(tbl.getMetaStoreTable().deepCopy(), msClient,
- tbl.getTableName(), Arrays.asList(hmsPartition));
+ applyAlterHmsPartitions(msClient, tbl.getTableName(),
+ Arrays.asList(hmsPartition), catalogTimeline);
addToInflightVersionsOfPartition(hmsPartition.getParameters(), partBuilder);
}
}
- private void applyAlterHmsPartitions(org.apache.hadoop.hive.metastore.api.Table msTbl,
- MetaStoreClient msClient, TableName tableName, List<Partition> hmsPartitions)
- throws ImpalaException {
+ private void applyAlterHmsPartitions(
+ MetaStoreClient msClient, TableName tableName, List<Partition> hmsPartitions,
+ EventSequence catalogTimeline) throws ImpalaException {
try {
MetastoreShim.alterPartitions(
msClient.getHiveClient(), tableName.getDb(), tableName.getTbl(), hmsPartitions);
+ catalogTimeline.markEvent(String.format("Altered %d partitions in Metastore",
+ hmsPartitions.size()));
} catch (TException e) {
throw new ImpalaRuntimeException(
String.format(HMS_RPC_ERROR_FORMAT_STR, "alter_partitions"), e);
@@ -6496,7 +6589,8 @@ public class CatalogOpExecutor {
* the changes written to the HMS.
*/
private void bulkAlterPartitions(Table tbl, List<HdfsPartition.Builder> modifiedParts,
- TblTransaction tblTxn, UpdatePartitionMethod updateMethod) throws ImpalaException {
+ TblTransaction tblTxn, UpdatePartitionMethod updateMethod,
+ EventSequence catalogTimeline) throws ImpalaException {
// Map from msPartitions to the partition builders. Use IdentityHashMap since
// modifications will change hash codes of msPartitions.
Map<Partition, HdfsPartition.Builder> msPartitionToBuilders =
@@ -6513,7 +6607,7 @@ public class CatalogOpExecutor {
String dbName = tbl.getDb().getName();
String tableName = tbl.getName();
int numDone = 0;
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
// Apply the updates in batches of 'MAX_PARTITION_UPDATES_PER_RPC'.
for (List<Partition> msPartitionsSubList : Iterables.partition(
msPartitionToBuilders.keySet(), MAX_PARTITION_UPDATES_PER_RPC)) {
@@ -6527,6 +6621,8 @@ public class CatalogOpExecutor {
msPartitionsSubList);
}
numDone += msPartitionsSubList.size();
+ catalogTimeline.markEvent(
+ String.format("Altered %d partitions in Metastore", numDone));
LOG.info("HMS alterPartitions done on {}/{} partitions of table {}", numDone,
msPartitionToBuilders.size(), tbl.getFullName());
// Mark the corresponding HdfsPartition objects as dirty
@@ -6576,22 +6672,6 @@ public class CatalogOpExecutor {
return msTbl;
}
- /**
- * Returns the metastore.api.Table object from the Hive Metastore for an existing
- * fully loaded table. Gets the MetaStore object from 'catalog_'.
- */
- private org.apache.hadoop.hive.metastore.api.Table getTableFromMetaStore(
- TableName tblName) throws CatalogException {
- Preconditions.checkNotNull(tblName);
- org.apache.hadoop.hive.metastore.api.Table msTbl = null;
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
- msTbl = msClient.getHiveClient().getTable(tblName.getDb(),tblName.getTbl());
- } catch (TException e) {
- LOG.error(String.format(HMS_RPC_ERROR_FORMAT_STR, "getTable") + e.getMessage());
- }
- return msTbl;
- }
-
private static List<FieldSchema> buildFieldSchemaList(List<TColumn> columns) {
List<FieldSchema> fsList = Lists.newArrayList();
// Add in all the columns
@@ -6634,6 +6714,7 @@ public class CatalogOpExecutor {
*/
public TResetMetadataResponse execResetMetadataImpl(TResetMetadataRequest req)
throws CatalogException {
+ EventSequence catalogTimeline = new EventSequence(CATALOG_TIMELINE_NAME);
String cmdString = CatalogOpUtil.getShortDescForReset(req);
TResetMetadataResponse resp = new TResetMetadataResponse();
resp.setResult(new TCatalogUpdateResult());
@@ -6644,11 +6725,11 @@ public class CatalogOpExecutor {
String.format("Can't refresh functions in blacklisted database: %s. %s",
req.getDb_name(), BLACKLISTED_DBS_INCONSISTENT_ERR_STR));
// This is a "refresh functions" operation.
- getMetastoreDdlLock().lock();
+ acquireMetastoreDdlLock(catalogTimeline);
try {
List<TCatalogObject> addedFuncs = Lists.newArrayList();
List<TCatalogObject> removedFuncs = Lists.newArrayList();
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
catalog_.refreshFunctions(msClient, req.getDb_name(), addedFuncs, removedFuncs);
}
resp.result.setUpdated_catalog_objects(addedFuncs);
@@ -6675,7 +6756,8 @@ public class CatalogOpExecutor {
// For INVALIDATE METADATA <db>.<table>, the db might be unloaded.
// So we can't update 'tbl' here.
updatedThriftTable = catalog_.invalidateTable(
- req.getTable_name(), tblWasRemoved, dbWasAdded);
+ req.getTable_name(), tblWasRemoved, dbWasAdded, catalogTimeline);
+ catalogTimeline.markEvent("Invalidated table in catalog cache");
} else {
// Quick check to see if the table exists in the catalog without triggering
// a table load.
@@ -6685,7 +6767,7 @@ public class CatalogOpExecutor {
// metadata load.
boolean isTableLoadedInCatalog = tbl.isLoaded();
tbl = getExistingTable(tblName.getDb(), tblName.getTbl(),
- "Load triggered by " + cmdString);
+ "Load triggered by " + cmdString, catalogTimeline);
CatalogObject.ThriftObjectType resultType =
req.header.want_minimal_response ?
CatalogObject.ThriftObjectType.INVALIDATION :
@@ -6698,8 +6780,8 @@ public class CatalogOpExecutor {
Reference<Boolean> wasPartitionRefreshed = new Reference<>(false);
// TODO if the partition was not really refreshed because the partSpec
// was wrong, do we still need to send back the table?
- updatedThriftTable = catalog_.reloadPartition(tbl,
- req.getPartition_spec(), wasPartitionRefreshed, resultType, cmdString);
+ updatedThriftTable = catalog_.reloadPartition(tbl, req.getPartition_spec(),
+ wasPartitionRefreshed, resultType, cmdString, catalogTimeline);
} else {
// TODO IMPALA-8809: Optimisation for partitioned tables:
// 1: Reload the whole table if schema change happened. Identify
@@ -6710,15 +6792,17 @@ public class CatalogOpExecutor {
// writeIds and reload only the ones that changed.
try {
updatedThriftTable = catalog_.reloadTable(tbl, req, resultType, cmdString,
- -1);
+ /*eventId*/ -1, catalogTimeline);
} catch (IcebergTableLoadingException e) {
updatedThriftTable = catalog_.invalidateTable(
- req.getTable_name(), tblWasRemoved, dbWasAdded);
+ req.getTable_name(), tblWasRemoved, dbWasAdded, catalogTimeline);
}
}
} else {
+ catalogTimeline.markEvent("Loaded table from scratch");
// Table was loaded from scratch, so it's already "refreshed".
tbl.takeReadLock();
+ catalogTimeline.markEvent("Got table read lock");
try {
updatedThriftTable = tbl.toTCatalogObject(resultType);
} finally {
@@ -6743,6 +6827,7 @@ public class CatalogOpExecutor {
Preconditions.checkNotNull(tbl, "tbl is null in " + cmdString);
// fire event for refresh event and update the last refresh event id
fireReloadEventAndUpdateRefreshEventId(req, tblName, tbl);
+ catalogTimeline.markEvent("Fired reload events in Metastore");
}
// Return the TCatalogObject in the result to indicate this request can be
@@ -6773,13 +6858,19 @@ public class CatalogOpExecutor {
} else {
// Invalidate the entire catalog if no table name is provided.
Preconditions.checkArgument(!req.isIs_refresh());
- resp.getResult().setVersion(catalog_.reset());
+ resp.getResult().setVersion(catalog_.reset(catalogTimeline));
resp.getResult().setIs_invalidate(true);
}
+ catalogTimeline.markEvent("Finished resetMetadata request");
if (req.isSync_ddl()) {
resp.getResult().setVersion(catalog_.waitForSyncDdlVersion(resp.getResult()));
+ catalogTimeline.markEvent(SENT_CATALOG_FOR_SYNC_DDL);
}
resp.getResult().setStatus(new TStatus(TErrorCode.OK, new ArrayList<String>()));
+
+ TRuntimeProfileNode profile = Frontend.createTRuntimeProfileNode("CatalogOp");
+ profile.addToEvent_sequences(catalogTimeline.toThrift());
+ resp.setProfile(profile);
return resp;
}
@@ -6862,16 +6953,17 @@ public class CatalogOpExecutor {
*/
public TUpdateCatalogResponse updateCatalogImpl(TUpdateCatalogRequest update)
throws ImpalaException {
+ EventSequence catalogTimeline = new EventSequence(CATALOG_TIMELINE_NAME);
TUpdateCatalogResponse response = new TUpdateCatalogResponse();
// Only update metastore for Hdfs tables.
Table table = getExistingTable(update.getDb_name(), update.getTarget_table(),
- "Load for INSERT");
+ "Load for INSERT", catalogTimeline);
if (!(table instanceof FeFsTable)) {
throw new InternalException("Unexpected table type: " +
update.getTarget_table());
}
- tryWriteLock(table, "updating the catalog");
+ tryWriteLock(table, "updating the catalog", catalogTimeline);
final Timer.Context context
= table.getMetrics().getTimer(HdfsTable.CATALOG_UPDATE_DURATION_METRIC).time();
@@ -6884,7 +6976,7 @@ public class CatalogOpExecutor {
if (update.isSetTransaction_id()) {
long transactionId = update.getTransaction_id();
Preconditions.checkState(transactionId > 0);
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
if (DebugUtils.hasDebugAction(update.getDebug_action(),
DebugUtils.UPDATE_CATALOG_ABORT_INSERT_TXN)) {
MetastoreShim.abortTransaction(msClient.getHiveClient(), transactionId);
@@ -6895,6 +6987,7 @@ public class CatalogOpExecutor {
// not always needed + the writeId of the INSERT could be probably reused.
tblTxn = MetastoreShim.createTblTransaction(
msClient.getHiveClient(), table.getMetaStoreTable(), transactionId);
+ catalogTimeline.markEvent("Created Metastore transaction");
}
}
@@ -6966,7 +7059,7 @@ public class CatalogOpExecutor {
}
if (!partsToCreate.isEmpty()) {
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
org.apache.hadoop.hive.metastore.api.Table msTbl =
table.getMetaStoreTable().deepCopy();
List<org.apache.hadoop.hive.metastore.api.Partition> hmsParts =
@@ -6997,7 +7090,7 @@ public class CatalogOpExecutor {
// added concurrently, and we want to avoid caching a partition twice and
// leaking a caching directive.
List<Partition> addedHmsParts = addHmsPartitions(
- msClient, table, hmsParts, partitionToEventId, true);
+ msClient, table, hmsParts, partitionToEventId, true, catalogTimeline);
for (Partition part: addedHmsParts) {
String part_name =
FeCatalogUtils.getPartitionName((FeFsTable)table, part.getValues());
@@ -7055,14 +7148,14 @@ public class CatalogOpExecutor {
// Unset COLUMN_STATS_ACCURATE by calling alter partition to hms.
if (!hmsPartitionsStatsUnset.isEmpty()) {
unsetPartitionsColStats(table.getMetaStoreTable(), hmsPartitionsStatsUnset,
- tblTxn);
+ tblTxn, catalogTimeline);
}
} else {
// For non-partitioned table, only single part exists
FeFsPartition singlePart = Iterables.getOnlyElement((List<FeFsPartition>) parts);
affectedExistingPartitions.add(singlePart);
}
- unsetTableColStats(table.getMetaStoreTable(), tblTxn);
+ unsetTableColStats(table.getMetaStoreTable(), tblTxn, catalogTimeline);
// Submit the watch request for the given cache directives.
if (!cacheDirIds.isEmpty()) {
catalog_.watchCacheDirs(cacheDirIds, tblName.toThrift(),
@@ -7085,7 +7178,7 @@ public class CatalogOpExecutor {
// enabled. This is best-effort. Any errors in it should not fail the INSERT.
try {
createInsertEvents((FeFsTable) table, update.getUpdated_partitions(),
- addedPartitionNames, update.is_overwrite, tblTxn);
+ addedPartitionNames, update.is_overwrite, tblTxn, catalogTimeline);
} catch (Exception e) {
LOG.error("Failed to fire insert events for table {}", table.getFullName(), e);
}
@@ -7095,7 +7188,7 @@ public class CatalogOpExecutor {
// always responsible for aborting transactions when queries hit errors.
if (update.isSetTransaction_id()) {
if (response.getResult().getStatus().getStatus_code() == TErrorCode.OK) {
- commitTransaction(update.getTransaction_id());
+ commitTransaction(update.getTransaction_id(), catalogTimeline);
}
}
@@ -7104,12 +7197,15 @@ public class CatalogOpExecutor {
org.apache.iceberg.Transaction iceTxn = IcebergUtil.getIcebergTransaction(iceTbl);
IcebergCatalogOpExecutor.execute(iceTbl, iceTxn,
update.getIceberg_operation());
+ catalogTimeline.markEvent("Executed Iceberg operation " +
+ update.getIceberg_operation().getOperation());
if (isIcebergHmsIntegrationEnabled(iceTbl.getMetaStoreTable())) {
// Add catalog service id and the 'newCatalogVersion' to the table parameters.
// This way we can avoid reloading the table on self-events (Iceberg generates
// an ALTER TABLE statement to set the new metadata_location).
IcebergCatalogOpExecutor.addCatalogVersionToTxn(iceTxn,
catalog_.getCatalogServiceId(), newCatalogVersion);
+ catalogTimeline.markEvent("Updated table properties");
catalog_.addVersionsForInflightEvents(false, table, newCatalogVersion);
}
@@ -7121,7 +7217,7 @@ public class CatalogOpExecutor {
}
loadTableMetadata(table, newCatalogVersion, true, false, partsToLoadMetadata,
- partitionToEventId, "INSERT", update.getDebug_action());
+ partitionToEventId, "INSERT", update.getDebug_action(), catalogTimeline);
addTableToCatalogUpdate(table, update.header.want_minimal_response,
response.result);
} finally {
@@ -7129,16 +7225,21 @@ public class CatalogOpExecutor {
UnlockWriteLockIfErronouslyLocked();
table.releaseWriteLock();
}
+ catalogTimeline.markEvent("Finished updateCatalog request");
if (update.isSync_ddl()) {
response.getResult().setVersion(
catalog_.waitForSyncDdlVersion(response.getResult()));
+ catalogTimeline.markEvent(SENT_CATALOG_FOR_SYNC_DDL);
}
if (update.isSetDebug_action()) {
DebugUtils.executeDebugAction(update.getDebug_action(),
DebugUtils.INSERT_FINISH_DELAY);
}
+ TRuntimeProfileNode profile = Frontend.createTRuntimeProfileNode("CatalogOp");
+ profile.addToEvent_sequences(catalogTimeline.toThrift());
+ response.setProfile(profile);
return response;
}
@@ -7166,7 +7267,7 @@ public class CatalogOpExecutor {
private void createInsertEvents(FeFsTable table,
Map<String, TUpdatedPartition> updatedPartitions,
Map<String, List<String>> addedPartitionNames,
- boolean isInsertOverwrite, TblTransaction tblTxn)
+ boolean isInsertOverwrite, TblTransaction tblTxn, EventSequence catalogTimeline)
throws CatalogException, MetaException {
if (!shouldGenerateInsertEvents(table)) return;
long txnId = tblTxn == null ? -1 : tblTxn.txnId;
@@ -7218,11 +7319,12 @@ public class CatalogOpExecutor {
if (insertEventReqDatas.isEmpty()) return;
- MetaStoreClient metaStoreClient = catalog_.getMetaStoreClient();
+ MetaStoreClient metaStoreClient = catalog_.getMetaStoreClient(catalogTimeline);
TableInsertEventInfo insertEventInfo = new TableInsertEventInfo(
insertEventReqDatas, insertEventPartVals, isTransactional, txnId, writeId);
List<Long> eventIds = MetastoreShim.fireInsertEvents(metaStoreClient,
insertEventInfo, table.getDb().getName(), table.getName());
+ catalogTimeline.markEvent("Fired Metastore events");
if (isTransactional) {
// ACID inserts do not generate INSERT events so there is nothing we need to track
// here for self-event detection. Note that It is enough to listen to the commit
@@ -7356,11 +7458,12 @@ public class CatalogOpExecutor {
* TODO: Track object IDs to
* know when a table has been dropped and re-created with the same name.
*/
- public Table getExistingTable(String dbName, String tblName, String reason)
- throws CatalogException {
+ public Table getExistingTable(String dbName, String tblName, String reason,
+ EventSequence catalogTimeline) throws CatalogException {
// passing null validWriteIdList makes sure that we return the table if it is
// already loaded.
- Table tbl = catalog_.getOrLoadTable(dbName, tblName, reason, null);
+ Table tbl = catalog_.getOrLoadTable(dbName, tblName, reason, null,
+ TABLE_ID_UNAVAILABLE, catalogTimeline);
if (tbl == null) {
throw new TableNotFoundException("Table not found: " + dbName + "." + tblName);
}
@@ -7385,7 +7488,8 @@ public class CatalogOpExecutor {
}
private void alterCommentOn(TDdlExecRequest ddlRequest, TDdlExecResponse response,
- Optional<TTableName> tTableName, boolean wantMinimalResult)
+ Optional<TTableName> tTableName, boolean wantMinimalResult,
+ EventSequence catalogTimeline)
throws ImpalaRuntimeException, CatalogException, InternalException {
Preconditions.checkState(tTableName.isPresent());
TCommentOnParams params = ddlRequest.getComment_on_params();
@@ -7394,14 +7498,15 @@ public class CatalogOpExecutor {
!params.isSetColumn_name());
tTableName.get().setDb_name(params.db);
catalogOpTracker_.increment(ddlRequest, tTableName);
- alterCommentOnDb(params.getDb(), params.getComment(), wantMinimalResult, response);
+ alterCommentOnDb(params.getDb(), params.getComment(), wantMinimalResult, response,
+ catalogTimeline);
} else if (params.getTable_name() != null) {
Preconditions.checkArgument(!params.isSetDb() && !params.isSetColumn_name());
tTableName.get().setDb_name(params.table_name.db_name);
tTableName.get().setTable_name(params.table_name.table_name);
catalogOpTracker_.increment(ddlRequest, tTableName);
alterCommentOnTableOrView(TableName.fromThrift(params.getTable_name()),
- params.getComment(), wantMinimalResult, response);
+ params.getComment(), wantMinimalResult, response, catalogTimeline);
} else if (params.getColumn_name() != null) {
Preconditions.checkArgument(!params.isSetDb() && !params.isSetTable_name());
TColumnName columnName = params.getColumn_name();
@@ -7409,20 +7514,21 @@ public class CatalogOpExecutor {
tTableName.get().setTable_name(columnName.table_name.table_name);
catalogOpTracker_.increment(ddlRequest, tTableName);
alterCommentOnColumn(TableName.fromThrift(columnName.getTable_name()),
- columnName.getColumn_name(), params.getComment(), wantMinimalResult, response);
+ columnName.getColumn_name(), params.getComment(), wantMinimalResult, response,
+ catalogTimeline);
} else {
throw new UnsupportedOperationException("Unsupported COMMENT ON operation");
}
}
private void alterCommentOnDb(String dbName, String comment, boolean wantMinimalResult,
- TDdlExecResponse response)
+ TDdlExecResponse response, EventSequence catalogTimeline)
throws ImpalaRuntimeException, CatalogException, InternalException {
Db db = catalog_.getDb(dbName);
if (db == null) {
throw new CatalogException("Database: " + dbName + " does not exist.");
}
- tryLock(db, "altering the comment");
+ tryLock(db, "altering the comment", catalogTimeline);
// Get a new catalog version to assign to the database being altered.
long newCatalogVersion = catalog_.incrementAndGetCatalogVersion();
catalog_.getLock().writeLock().unlock();
@@ -7432,11 +7538,12 @@ public class CatalogOpExecutor {
newCatalogVersion);
msDb.setDescription(comment);
try {
- applyAlterDatabase(msDb);
+ applyAlterDatabase(msDb, catalogTimeline);
} catch (ImpalaRuntimeException e) {
throw e;
}
Db updatedDb = catalog_.updateDb(msDb);
+ catalogTimeline.markEvent("Updated database in catalog cache");
addDbToCatalogUpdate(updatedDb, wantMinimalResult, response.result);
// now that HMS alter operation has succeeded, add this version to list of inflight
// events in catalog database if event processing is enabled
@@ -7448,7 +7555,7 @@ public class CatalogOpExecutor {
}
private void alterDatabase(TAlterDbParams params, boolean wantMinimalResult,
- TDdlExecResponse response) throws ImpalaException {
+ TDdlExecResponse response, EventSequence catalogTimeline) throws ImpalaException {
Preconditions.checkNotNull(params);
String dbName = params.getDb();
Db db = catalog_.getDb(dbName);
@@ -7458,7 +7565,7 @@ public class CatalogOpExecutor {
switch (params.getAlter_type()) {
case SET_OWNER:
alterDatabaseSetOwner(db, params.getSet_owner_params(), wantMinimalResult,
- response);
+ response, catalogTimeline);
break;
default:
throw new UnsupportedOperationException(
@@ -7467,10 +7574,11 @@ public class CatalogOpExecutor {
}
private void alterDatabaseSetOwner(Db db, TAlterDbSetOwnerParams params,
- boolean wantMinimalResult, TDdlExecResponse response) throws ImpalaException {
+ boolean wantMinimalResult, TDdlExecResponse response,
+ EventSequence catalogTimeline) throws ImpalaException {
Preconditions.checkNotNull(params.owner_name);
Preconditions.checkNotNull(params.owner_type);
- tryLock(db, "altering the owner");
+ tryLock(db, "altering the owner", catalogTimeline);
// Get a new catalog version to assign to the database being altered.
long newCatalogVersion = catalog_.incrementAndGetCatalogVersion();
catalog_.getLock().writeLock().unlock();
@@ -7483,7 +7591,7 @@ public class CatalogOpExecutor {
msDb.setOwnerName(params.owner_name);
msDb.setOwnerType(PrincipalType.valueOf(params.owner_type.name()));
try {
- applyAlterDatabase(msDb);
+ applyAlterDatabase(msDb, catalogTimeline);
} catch (ImpalaRuntimeException e) {
throw e;
}
@@ -7493,6 +7601,7 @@ public class CatalogOpExecutor {
msDb.getOwnerType(), response);
}
Db updatedDb = catalog_.updateDb(msDb);
+ catalogTimeline.markEvent("Updated database in catalog cache");
addDbToCatalogUpdate(updatedDb, wantMinimalResult, response.result);
// now that HMS alter operation has succeeded, add this version to list of inflight
// events in catalog database if event processing is enabled
@@ -7527,11 +7636,11 @@ public class CatalogOpExecutor {
}
private void alterCommentOnTableOrView(TableName tableName, String comment,
- boolean wantMinimalResult, TDdlExecResponse response)
+ boolean wantMinimalResult, TDdlExecResponse response, EventSequence catalogTimeline)
throws CatalogException, InternalException, ImpalaRuntimeException {
Table tbl = getExistingTable(tableName.getDb(), tableName.getTbl(),
- "Load for ALTER COMMENT");
- tryWriteLock(tbl);
+ "Load for ALTER COMMENT", catalogTimeline);
+ tryWriteLock(tbl, catalogTimeline);
try {
long newCatalogVersion = catalog_.incrementAndGetCatalogVersion();
catalog_.getLock().writeLock().unlock();
@@ -7546,8 +7655,9 @@ public class CatalogOpExecutor {
} else {
msTbl.getParameters().put("comment", comment);
}
- applyAlterTable(msTbl);
- loadTableMetadata(tbl, newCatalogVersion, false, false, null, "ALTER COMMENT");
+ applyAlterTable(msTbl, catalogTimeline);
+ loadTableMetadata(tbl, newCatalogVersion, false, false, null, "ALTER COMMENT",
+ catalogTimeline);
catalog_.addVersionsForInflightEvents(false, tbl, newCatalogVersion);
addTableToCatalogUpdate(tbl, wantMinimalResult, response.result);
addSummary(response, String.format("Updated %s.", (isView) ? "view" : "table"));
@@ -7557,11 +7667,12 @@ public class CatalogOpExecutor {
}
private void alterCommentOnColumn(TableName tableName, String columnName,
- String comment, boolean wantMinimalResult, TDdlExecResponse response)
+ String comment, boolean wantMinimalResult, TDdlExecResponse response,
+ EventSequence catalogTimeline)
throws CatalogException, InternalException, ImpalaRuntimeException {
Table tbl = getExistingTable(tableName.getDb(), tableName.getTbl(),
- "Load for ALTER COLUMN COMMENT");
- tryWriteLock(tbl);
+ "Load for ALTER COLUMN COMMENT", catalogTimeline);
+ tryWriteLock(tbl, catalogTimeline);
try {
long newCatalogVersion = catalog_.incrementAndGetCatalogVersion();
catalog_.getLock().writeLock().unlock();
@@ -7571,7 +7682,8 @@ public class CatalogOpExecutor {
TColumn new_col = new TColumn(columnName,
tbl.getColumn(columnName).getType().toThrift());
new_col.setComment(comment != null ? comment : "");
- KuduCatalogOpExecutor.alterColumn((KuduTable) tbl, columnName, new_col);
+ KuduCatalogOpExecutor.alterColumn((KuduTable) tbl, columnName, new_col,
+ catalogTimeline);
} else {
org.apache.hadoop.hive.metastore.api.Table msTbl =
tbl.getMetaStoreTable().deepCopy();
@@ -7582,10 +7694,10 @@ public class CatalogOpExecutor {
"Column name %s not found in table %s.", columnName, tbl.getFullName()));
}
}
- applyAlterTable(msTbl);
+ applyAlterTable(msTbl, catalogTimeline);
}
loadTableMetadata(tbl, newCatalogVersion, false, true, null,
- "ALTER COLUMN COMMENT");
+ "ALTER COLUMN COMMENT", catalogTimeline);
catalog_.addVersionsForInflightEvents(false, tbl, newCatalogVersion);
addTableToCatalogUpdate(tbl, wantMinimalResult, response.result);
addSummary(response, "Column has been altered.");
@@ -7614,17 +7726,19 @@ public class CatalogOpExecutor {
* Tries to take the write lock of the table in the catalog. Throws an InternalException
* if the catalog is unable to lock the given table.
*/
- private void tryWriteLock(Table tbl) throws InternalException {
- tryWriteLock(tbl, "altering");
+ private void tryWriteLock(Table tbl, EventSequence catalogTimeline)
+ throws InternalException {
+ tryWriteLock(tbl, "altering", catalogTimeline);
}
/**
* Try to lock a table in the catalog for a given operation. Throw an InternalException
* if the catalog is unable to lock the given table.
*/
- private void tryWriteLock(Table tbl, String operation) throws InternalException {
+ private void tryWriteLock(Table tbl, String operation, EventSequence catalogTimeline)
+ throws InternalException {
String type = tbl instanceof View ? "view" : "table";
- if (!catalog_.tryWriteLock(tbl)) {
+ if (!catalog_.tryWriteLock(tbl, catalogTimeline)) {
throw new InternalException(String.format("Error %s (for) %s %s due to " +
"lock contention.", operation, type, tbl.getFullName()));
}
@@ -7634,11 +7748,13 @@ public class CatalogOpExecutor {
* Try to lock the given Db in the catalog for the given operation. Throws
* InternalException if catalog is unable to lock the database.
*/
- private void tryLock(Db db, String operation) throws InternalException {
+ private void tryLock(Db db, String operation, EventSequence catalogTimeline)
+ throws InternalException {
if (!catalog_.tryLockDb(db)) {
throw new InternalException(String.format("Error %s of database %s due to lock "
+ "contention.", operation, db.getName()));
}
+ catalogTimeline.markEvent("Got database lock");
}
/**
@@ -7646,10 +7762,12 @@ public class CatalogOpExecutor {
* @param transactionId is the id of the transaction.
* @throws TransactionException
*/
- private void commitTransaction(long transactionId) throws TransactionException {
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ private void commitTransaction(long transactionId, EventSequence catalogTimeline)
+ throws TransactionException {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
MetastoreShim.commitTransaction(msClient.getHiveClient(), transactionId);
- LOG.info("Committed transaction: " + Long.toString(transactionId));
+ catalogTimeline.markEvent("Committed Metastore transaction " + transactionId);
+ LOG.info("Committed transaction: " + transactionId);
}
}
@@ -7657,11 +7775,12 @@ public class CatalogOpExecutor {
* Update table properties to remove the COLUMN_STATS_ACCURATE entry if it exists.
*/
private void unsetTableColStats(org.apache.hadoop.hive.metastore.api.Table msTable,
- TblTransaction tblTxn) throws ImpalaRuntimeException{
+ TblTransaction tblTxn, EventSequence catalogTimeline)
+ throws ImpalaRuntimeException {
Map<String, String> params = msTable.getParameters();
if (params != null && params.containsKey(StatsSetupConst.COLUMN_STATS_ACCURATE)) {
params.remove(StatsSetupConst.COLUMN_STATS_ACCURATE);
- applyAlterTable(msTable, false, tblTxn);
+ applyAlterTable(msTable, false, tblTxn, catalogTimeline);
}
}
@@ -7672,8 +7791,9 @@ public class CatalogOpExecutor {
*/
private void unsetPartitionsColStats(org.apache.hadoop.hive.metastore.api.Table msTable,
List<org.apache.hadoop.hive.metastore.api.Partition> hmsPartitionsStatsUnset,
- TblTransaction tblTxn) throws ImpalaRuntimeException{
- try (MetaStoreClient msClient = catalog_.getMetaStoreClient()) {
+ TblTransaction tblTxn, EventSequence catalogTimeline)
+ throws ImpalaRuntimeException {
+ try (MetaStoreClient msClient = catalog_.getMetaStoreClient(catalogTimeline)) {
try {
if (tblTxn != null) {
MetastoreShim.alterPartitionsWithTransaction(
@@ -7683,6 +7803,7 @@ public class CatalogOpExecutor {
MetastoreShim.alterPartitions(msClient.getHiveClient(), msTable.getDbName(),
msTable.getTableName(), hmsPartitionsStatsUnset);
}
+ catalogTimeline.markEvent("Unset partition stats in Metastore");
} catch (TException te) {
throw new ImpalaRuntimeException(
String.format(HMS_RPC_ERROR_FORMAT_STR, "alter_partitions"), te);
diff --git a/fe/src/main/java/org/apache/impala/service/JniCatalog.java b/fe/src/main/java/org/apache/impala/service/JniCatalog.java
index 7eb0463f9..95541053b 100644
--- a/fe/src/main/java/org/apache/impala/service/JniCatalog.java
+++ b/fe/src/main/java/org/apache/impala/service/JniCatalog.java
@@ -91,8 +91,10 @@ import org.apache.impala.thrift.TUpdateTableUsageRequest;
import org.apache.impala.thrift.TGetAllHadoopConfigsResponse;
import org.apache.impala.util.AuthorizationUtil;
import org.apache.impala.util.CatalogOpUtil;
+import org.apache.impala.util.EventSequence;
import org.apache.impala.util.GlogAppender;
import org.apache.impala.util.MetaStoreUtil;
+import org.apache.impala.util.NoOpEventSequence;
import org.apache.impala.util.PatternMatcher;
import org.apache.impala.util.ThreadNameAnnotator;
import org.apache.impala.util.TUniqueIdUtil;
@@ -182,7 +184,7 @@ public class JniCatalog {
catalogMetastoreServer_.start();
try {
- catalog_.reset();
+ catalog_.reset(NoOpEventSequence.INSTANCE);
} catch (CatalogException e) {
LOG.error("Error initializing Catalog. Please run 'invalidate metadata'", e);
}
diff --git a/fe/src/main/java/org/apache/impala/service/KuduCatalogOpExecutor.java b/fe/src/main/java/org/apache/impala/service/KuduCatalogOpExecutor.java
index f725ab0a9..4f645e8bc 100644
--- a/fe/src/main/java/org/apache/impala/service/KuduCatalogOpExecutor.java
+++ b/fe/src/main/java/org/apache/impala/service/KuduCatalogOpExecutor.java
@@ -75,24 +75,15 @@ public class KuduCatalogOpExecutor {
private static final String CHECKED_KUDU_TABLE_EXISTENCE =
"Checked table existence in Kudu";
private static final String CREATED_KUDU_TABLE = "Created table in Kudu";
- private static final String GOT_KUDU_CLIENT = "Got Kudu client";
+ private static final String ALTERED_KUDU_TABLE = "Altered table in Kudu";
+ public static final String GOT_KUDU_CLIENT = "Got Kudu client";
private static final String GOT_KUDU_DDL_LOCK = "Got kuduDdlLock";
- private static final String OPENED_KUDU_TABLE = "Opened Kudu table";
+ public static final String OPENED_KUDU_TABLE = "Opened Kudu table";
private static final String POPULATED_COLS_FROM_KUDU =
"Populated external table cols from Kudu";
private static final Object kuduDdlLock_ = new Object();
- /**
- * Wrapper to get kudu client and mark the given 'catalogTimeline' when it finishes.
- */
- private static KuduClient getKuduClient(String masterHosts,
- EventSequence catalogTimeline) {
- KuduClient kudu = KuduUtil.getKuduClient(masterHosts);
- catalogTimeline.markEvent(GOT_KUDU_CLIENT);
- return kudu;
- }
-
/**
* Wrapper to check kudu table existence and mark the given 'catalogTimeline' when it
* finishes.
@@ -133,7 +124,7 @@ public class KuduCatalogOpExecutor {
LOG.trace(String.format("Creating table '%s' in master '%s'", kuduTableName,
masterHosts));
}
- KuduClient kudu = getKuduClient(masterHosts, catalogTimeline);
+ KuduClient kudu = KuduUtil.getKuduClient(masterHosts, catalogTimeline);
try {
// Acquire lock to protect table existence check and table creation, see IMPALA-8984
synchronized (kuduDdlLock_) {
@@ -329,7 +320,7 @@ public class KuduCatalogOpExecutor {
* kudu cluster for 'kudu_table_reserve_seconds'.
*/
public static void dropTable(org.apache.hadoop.hive.metastore.api.Table msTbl,
- boolean ifExists, int kudu_table_reserve_seconds)
+ boolean ifExists, int kudu_table_reserve_seconds, EventSequence catalogTimeline)
throws ImpalaRuntimeException, TableNotFoundException {
Preconditions.checkState(KuduTable.isSynchronizedTable(msTbl));
String tableName = msTbl.getParameters().get(KuduTable.KEY_TABLE_NAME);
@@ -338,13 +329,14 @@ public class KuduCatalogOpExecutor {
LOG.trace(String.format("Dropping table '%s' from master '%s'", tableName,
masterHosts));
}
- KuduClient kudu = KuduUtil.getKuduClient(masterHosts);
+ KuduClient kudu = KuduUtil.getKuduClient(masterHosts, catalogTimeline);
try {
Preconditions.checkState(!Strings.isNullOrEmpty(tableName));
// TODO: The IF EXISTS case should be handled by Kudu to ensure atomicity.
// (see KUDU-1710).
if (kudu.tableExists(tableName)) {
kudu.deleteTable(tableName, kudu_table_reserve_seconds);
+ catalogTimeline.markEvent("Deleted table in Kudu");
} else if (!ifExists) {
throw new TableNotFoundException(String.format(
"Table '%s' does not exist in Kudu master(s) '%s'.", tableName, masterHosts));
@@ -375,7 +367,7 @@ public class KuduCatalogOpExecutor {
LOG.trace(String.format("Loading schema of table '%s' from master '%s'",
kuduTableName, masterHosts));
}
- KuduClient kudu = getKuduClient(masterHosts, catalogTimeline);
+ KuduClient kudu = KuduUtil.getKuduClient(masterHosts, catalogTimeline);
try {
if (!checkTableExistence(kudu, kuduTableName, catalogTimeline)) {
throw new ImpalaRuntimeException(String.format("Table does not exist in Kudu: " +
@@ -437,19 +429,20 @@ public class KuduCatalogOpExecutor {
/**
* Renames a Kudu table.
*/
- public static void renameTable(KuduTable tbl, String newName)
- throws ImpalaRuntimeException {
+ public static void renameTable(KuduTable tbl, String newName,
+ EventSequence catalogTimeline) throws ImpalaRuntimeException {
Preconditions.checkState(!Strings.isNullOrEmpty(newName));
AlterTableOptions alterTableOptions = new AlterTableOptions();
alterTableOptions.renameTable(newName);
String errMsg = String.format("Error renaming Kudu table " +
"%s to %s", tbl.getKuduTableName(), newName);
- KuduClient client = KuduUtil.getKuduClient(tbl.getKuduMasterHosts());
+ KuduClient client = KuduUtil.getKuduClient(tbl.getKuduMasterHosts(), catalogTimeline);
try {
client.alterTable(tbl.getKuduTableName(), alterTableOptions);
if (!client.isAlterTableDone(newName)) {
throw new ImpalaRuntimeException(errMsg + ": Kudu operation timed out");
}
+ catalogTimeline.markEvent(ALTERED_KUDU_TABLE);
} catch (KuduException e) {
throw new ImpalaRuntimeException(errMsg, e);
}
@@ -480,7 +473,8 @@ public class KuduCatalogOpExecutor {
* Adds/drops a range partition.
*/
public static void addDropRangePartition(KuduTable tbl,
- TAlterTableAddDropRangePartitionParams params) throws ImpalaRuntimeException {
+ TAlterTableAddDropRangePartitionParams params, EventSequence catalogTimeline)
+ throws ImpalaRuntimeException {
TRangePartition rangePartition = params.getRange_partition_spec();
List<Pair<PartialRow, RangePartitionBound>> rangeBounds =
getRangePartitionBounds(rangePartition, tbl);
@@ -506,7 +500,7 @@ public class KuduCatalogOpExecutor {
"table %s", (type == TRangePartitionOperationType.ADD ? "adding" : "dropping"),
tbl.getName());
try {
- alterKuduTable(tbl, alterTableOptions, errMsg);
+ alterKuduTable(tbl, alterTableOptions, errMsg, catalogTimeline);
} catch (ImpalaRuntimeException e) {
if (!params.isIgnore_errors()) throw e;
}
@@ -555,28 +549,28 @@ public class KuduCatalogOpExecutor {
/**
* Adds a column to an existing Kudu table.
*/
- public static void addColumn(KuduTable tbl, List<TColumn> columns)
- throws ImpalaRuntimeException {
+ public static void addColumn(KuduTable tbl, List<TColumn> columns,
+ EventSequence catalogTimeline) throws ImpalaRuntimeException {
AlterTableOptions alterTableOptions = new AlterTableOptions();
for (TColumn column: columns) {
alterTableOptions.addColumn(createColumnSchema(column, false, false));
}
String errMsg = "Error adding columns to Kudu table " + tbl.getName();
- alterKuduTable(tbl, alterTableOptions, errMsg);
+ alterKuduTable(tbl, alterTableOptions, errMsg, catalogTimeline);
}
/**
* Drops a column from a Kudu table.
*/
- public static void dropColumn(KuduTable tbl, String colName)
- throws ImpalaRuntimeException {
+ public static void dropColumn(KuduTable tbl, String colName,
+ EventSequence catalogTimeline) throws ImpalaRuntimeException {
Preconditions.checkState(!Strings.isNullOrEmpty(colName));
KuduColumn col = (KuduColumn) tbl.getColumn(colName);
AlterTableOptions alterTableOptions = new AlterTableOptions();
alterTableOptions.dropColumn(col.getKuduName());
String errMsg = String.format("Error dropping column %s from " +
"Kudu table %s", colName, tbl.getName());
- alterKuduTable(tbl, alterTableOptions, errMsg);
+ alterKuduTable(tbl, alterTableOptions, errMsg, catalogTimeline);
}
/**
@@ -589,8 +583,8 @@ public class KuduCatalogOpExecutor {
* new rowsets as they are written out, and possibly to old rowsets if they are
* compacted into new rowsets depending on cost based decisions Kudu makes.
*/
- public static void alterColumn(KuduTable tbl, String colName, TColumn newCol)
- throws ImpalaRuntimeException {
+ public static void alterColumn(KuduTable tbl, String colName, TColumn newCol,
+ EventSequence catalogTimeline) throws ImpalaRuntimeException {
Preconditions.checkState(!Strings.isNullOrEmpty(colName));
Preconditions.checkNotNull(newCol);
Preconditions.checkState(!newCol.isIs_key());
@@ -634,11 +628,11 @@ public class KuduCatalogOpExecutor {
String errMsg = String.format(
"Error altering column %s in Kudu table %s", colName, tbl.getName());
- alterKuduTable(tbl, alterTableOptions, errMsg);
+ alterKuduTable(tbl, alterTableOptions, errMsg, catalogTimeline);
}
- public static void alterSetOwner(KuduTable tbl, String newOwner)
- throws ImpalaRuntimeException {
+ public static void alterSetOwner(KuduTable tbl, String newOwner,
+ EventSequence catalogTimeline) throws ImpalaRuntimeException {
// We still need to call alterKuduTable() even if tbl.getOwnerUser() equals
// 'newOwner'. It is possible that the owner of 'tbl' from Kudu's perspective is
// different than that from HMS' perspective, i.e., tbl.getOwnerUser(). Such a
@@ -649,7 +643,7 @@ public class KuduCatalogOpExecutor {
alterTableOptions.setOwner(newOwner);
String errMsg = String.format(
"Error setting the owner of Kudu table %s to %s", tbl.getName(), newOwner);
- alterKuduTable(tbl, alterTableOptions, errMsg);
+ alterKuduTable(tbl, alterTableOptions, errMsg, catalogTimeline);
}
/**
@@ -657,14 +651,15 @@ public class KuduCatalogOpExecutor {
* the alter table operation is finished or until the operation timeout is reached.
* Throws an ImpalaRuntimeException if the operation cannot be completed successfully.
*/
- public static void alterKuduTable(KuduTable tbl, AlterTableOptions ato, String errMsg)
- throws ImpalaRuntimeException {
- KuduClient client = KuduUtil.getKuduClient(tbl.getKuduMasterHosts());
+ public static void alterKuduTable(KuduTable tbl, AlterTableOptions ato, String errMsg,
+ EventSequence catalogTimeline) throws ImpalaRuntimeException {
+ KuduClient client = KuduUtil.getKuduClient(tbl.getKuduMasterHosts(), catalogTimeline);
try {
client.alterTable(tbl.getKuduTableName(), ato);
if (!client.isAlterTableDone(tbl.getKuduTableName())) {
throw new ImpalaRuntimeException(errMsg + ": Kudu operation timed out");
}
+ catalogTimeline.markEvent(ALTERED_KUDU_TABLE);
} catch (KuduException e) {
throw new ImpalaRuntimeException(errMsg, e);
}
diff --git a/fe/src/main/java/org/apache/impala/util/EventSequence.java b/fe/src/main/java/org/apache/impala/util/EventSequence.java
index 72b1126d9..b2739d1f6 100644
--- a/fe/src/main/java/org/apache/impala/util/EventSequence.java
+++ b/fe/src/main/java/org/apache/impala/util/EventSequence.java
@@ -41,6 +41,15 @@ public class EventSequence {
lastTime_ = startTime_;
}
+ /**
+ * Returns a new EventSequence instance that won't be used. Some code paths
+ * (e.g. event-processor) don't have catalog profiles so don't provide a timeline to
+ * update. Use this to avoid passing in a null value.
+ */
+ public static EventSequence getUnusedTimeline() {
+ return NoOpEventSequence.INSTANCE;
+ }
+
/**
* Saves an event at the current time with the given label.
* It returns the duration in nano seconds between the last and the current event.
diff --git a/fe/src/main/java/org/apache/impala/util/KuduUtil.java b/fe/src/main/java/org/apache/impala/util/KuduUtil.java
index ece4f3726..74940df45 100644
--- a/fe/src/main/java/org/apache/impala/util/KuduUtil.java
+++ b/fe/src/main/java/org/apache/impala/util/KuduUtil.java
@@ -18,6 +18,7 @@
package org.apache.impala.util;
import static java.lang.String.format;
+import static org.apache.impala.service.KuduCatalogOpExecutor.GOT_KUDU_CLIENT;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -98,6 +99,16 @@ public class KuduUtil {
return client;
}
+ /**
+ * Wrapper to get kudu client and mark the given 'catalogTimeline' when it finishes.
+ */
+ public static KuduClient getKuduClient(String masterHosts,
+ EventSequence catalogTimeline) {
+ KuduClient kudu = KuduUtil.getKuduClient(masterHosts);
+ catalogTimeline.markEvent(GOT_KUDU_CLIENT);
+ return kudu;
+ }
+
/**
* Creates a PartialRow from a list of range partition boundary values.
* 'rangePartitionColumns' must be specified in Kudu case.
diff --git a/fe/src/main/java/org/apache/impala/util/NoOpEventSequence.java b/fe/src/main/java/org/apache/impala/util/NoOpEventSequence.java
new file mode 100644
index 000000000..717eb57cb
--- /dev/null
+++ b/fe/src/main/java/org/apache/impala/util/NoOpEventSequence.java
@@ -0,0 +1,36 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you 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.
+
+package org.apache.impala.util;
+
+/**
+ * An EventSequence instance that won't be used. Some code paths (e.g. event-processor)
+ * don't have catalog profiles so don't provide a timeline to update. Use this to avoid
+ * passing in a null value.
+ */
+public class NoOpEventSequence extends EventSequence {
+
+ public static final NoOpEventSequence INSTANCE = new NoOpEventSequence();
+
+ public NoOpEventSequence() {
+ super("unused");
+ }
+
+ public long markEvent(String label) {
+ return 0;
+ }
+}
diff --git a/fe/src/test/java/org/apache/impala/catalog/CatalogTest.java b/fe/src/test/java/org/apache/impala/catalog/CatalogTest.java
index d301e20a1..63e6ed181 100644
--- a/fe/src/test/java/org/apache/impala/catalog/CatalogTest.java
+++ b/fe/src/test/java/org/apache/impala/catalog/CatalogTest.java
@@ -68,6 +68,7 @@ import org.apache.impala.thrift.TPrivilege;
import org.apache.impala.thrift.TPrivilegeLevel;
import org.apache.impala.thrift.TPrivilegeScope;
import org.apache.impala.thrift.TTableName;
+import org.apache.impala.util.NoOpEventSequence;
import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
@@ -364,7 +365,7 @@ public class CatalogTest {
stats.reset();
catalog_.invalidateTable(new TTableName("functional", "alltypes"),
/*tblWasRemoved=*/new Reference<Boolean>(),
- /*dbWasAdded=*/new Reference<Boolean>());
+ /*dbWasAdded=*/new Reference<Boolean>(), NoOpEventSequence.INSTANCE);
HdfsTable table = (HdfsTable)catalog_.getOrLoadTable("functional", "AllTypes",
"test", null);
@@ -390,7 +391,7 @@ public class CatalogTest {
// Now test REFRESH on the table...
stats.reset();
- catalog_.reloadTable(table, "test");
+ catalog_.reloadTable(table, "test", NoOpEventSequence.INSTANCE);
// Again, we expect only one getFileStatus call, for the top-level directory.
assertEquals(1L, (long)opsCounts.getLong(GET_FILE_STATUS));
@@ -409,7 +410,7 @@ public class CatalogTest {
new TPartitionKeyValue("year", "2010"),
new TPartitionKeyValue("month", "10"));
catalog_.reloadPartition(table, partitionSpec, new Reference<>(false),
- CatalogObject.ThriftObjectType.NONE, "test");
+ CatalogObject.ThriftObjectType.NONE, "test", NoOpEventSequence.INSTANCE);
assertEquals(0L, (long)opsCounts.getLong(GET_FILE_BLOCK_LOCS));
// Loading or reloading an unpartitioned table with some files in it should not make
@@ -419,7 +420,7 @@ public class CatalogTest {
"functional", "alltypesaggmultifilesnopart", "test", null);
assertEquals(0L, (long)opsCounts.getLong(GET_FILE_BLOCK_LOCS));
stats.reset();
- catalog_.reloadTable(unpartTable, "test");
+ catalog_.reloadTable(unpartTable, "test", NoOpEventSequence.INSTANCE);
assertEquals(0L, (long)opsCounts.getLong(GET_FILE_BLOCK_LOCS));
// Simulate an empty partition, which will trigger the full
@@ -432,7 +433,7 @@ public class CatalogTest {
table.updatePartition(partBuilder);
stats.reset();
catalog_.reloadPartition(table, partitionSpec, new Reference<>(false),
- CatalogObject.ThriftObjectType.NONE, "test");
+ CatalogObject.ThriftObjectType.NONE, "test", NoOpEventSequence.INSTANCE);
// Should not scan the directory file-by-file, should use a single
// listLocatedStatus() to get the whole directory (partition)
@@ -736,8 +737,8 @@ public class CatalogTest {
// Partitioned table with stats. Invalidate the table prior to fetching.
Reference<Boolean> tblWasRemoved = new Reference<Boolean>();
Reference<Boolean> dbWasAdded = new Reference<Boolean>();
- catalog_.invalidateTable(
- new TTableName("functional", "alltypesagg"), tblWasRemoved, dbWasAdded);
+ catalog_.invalidateTable(new TTableName("functional", "alltypesagg"),
+ tblWasRemoved, dbWasAdded, NoOpEventSequence.INSTANCE);
expectStatistics("functional", "alltypesagg", 11);
// Unpartitioned table with no stats.
diff --git a/fe/src/test/java/org/apache/impala/catalog/CatalogdTableInvalidatorTest.java b/fe/src/test/java/org/apache/impala/catalog/CatalogdTableInvalidatorTest.java
index e6fd05544..2a2c0e7b1 100644
--- a/fe/src/test/java/org/apache/impala/catalog/CatalogdTableInvalidatorTest.java
+++ b/fe/src/test/java/org/apache/impala/catalog/CatalogdTableInvalidatorTest.java
@@ -21,6 +21,7 @@ import com.google.common.base.Ticker;
import org.apache.impala.common.Reference;
import org.apache.impala.testutil.CatalogServiceTestCatalog;
import org.apache.impala.thrift.TTableName;
+import org.apache.impala.util.NoOpEventSequence;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
@@ -56,7 +57,8 @@ public class CatalogdTableInvalidatorTest {
Reference<Boolean> dbWasAdded = new Reference<>();
String dbName = "functional";
String tblName = "alltypes";
- catalog_.invalidateTable(new TTableName(dbName, tblName), tblWasRemoved, dbWasAdded);
+ catalog_.invalidateTable(new TTableName(dbName, tblName), tblWasRemoved, dbWasAdded,
+ NoOpEventSequence.INSTANCE);
MockTicker ticker = new MockTicker();
CatalogdTableInvalidator.TIME_SOURCE = ticker;
catalog_.setCatalogdTableInvalidator(
diff --git a/fe/src/test/java/org/apache/impala/catalog/PartialCatalogInfoWriteIdTest.java b/fe/src/test/java/org/apache/impala/catalog/PartialCatalogInfoWriteIdTest.java
index 9e332052d..ee3b1ad93 100644
--- a/fe/src/test/java/org/apache/impala/catalog/PartialCatalogInfoWriteIdTest.java
+++ b/fe/src/test/java/org/apache/impala/catalog/PartialCatalogInfoWriteIdTest.java
@@ -43,6 +43,8 @@ import org.apache.impala.thrift.TTable;
import org.apache.impala.thrift.TTableInfoSelector;
import org.apache.impala.thrift.TTableName;
import org.apache.impala.util.AcidUtils;
+import org.apache.impala.util.EventSequence;
+import org.apache.impala.util.NoOpEventSequence;
import org.apache.thrift.TDeserializer;
import org.apache.thrift.TException;
import org.apache.thrift.TSerializer;
@@ -121,7 +123,7 @@ public class PartialCatalogInfoWriteIdTest {
st.stop().elapsed(TimeUnit.MILLISECONDS));
client.close();
}
- catalog_.reset();
+ catalog_.reset(NoOpEventSequence.INSTANCE);
}
private static String getTblProperties() {
@@ -215,8 +217,8 @@ public class PartialCatalogInfoWriteIdTest {
ValidWriteIdList validWriteIdList = getValidWriteIdList(testDbName, testTblName);
// now insert into the table to advance the writeId
executeHiveSql("insert into " + getTestTblName() + " values (2)");
- catalog_.invalidateTable(new TTableName(testDbName, testTblName), new Reference<>()
- , new Reference<>());
+ catalog_.invalidateTable(new TTableName(testDbName, testTblName), new Reference<>(),
+ new Reference<>(), NoOpEventSequence.INSTANCE);
Table tblAfterReload = catalog_.getOrLoadTable(testDbName, testTblName, "test", null);
long tblVersion = tblAfterReload.getCatalogVersion();
// issue a request which is older than what we have in catalog
@@ -701,7 +703,7 @@ public class PartialCatalogInfoWriteIdTest {
+ "functional_orc_def.alltypes");
executeHiveSql("delete from " + getTestFullAcidTblName()
+ " where id % 2 = 0");
- catalog_.reset();
+ catalog_.reset(NoOpEventSequence.INSTANCE);
Table tbl = catalog_.getOrLoadTable(testDbName, testAcidTblName, "test", null);
Assert.assertFalse("Table must be loaded", tbl instanceof IncompleteTable);
ValidWriteIdList olderWriteIdList = getValidWriteIdList(testDbName, testAcidTblName);
@@ -886,7 +888,7 @@ public class PartialCatalogInfoWriteIdTest {
private void invalidateTbl(String db, String tbl) throws CatalogException {
catalog_.invalidateTable(new TTableName(db, tbl), new Reference<>(),
- new Reference<>());
+ new Reference<>(), NoOpEventSequence.INSTANCE);
Assert.assertTrue("Table must not be loaded",
catalog_.getTable(db, tbl) instanceof IncompleteTable);
}
diff --git a/fe/src/test/java/org/apache/impala/catalog/events/EventsProcessorStressTest.java b/fe/src/test/java/org/apache/impala/catalog/events/EventsProcessorStressTest.java
index da3f9c951..611fc84a0 100644
--- a/fe/src/test/java/org/apache/impala/catalog/events/EventsProcessorStressTest.java
+++ b/fe/src/test/java/org/apache/impala/catalog/events/EventsProcessorStressTest.java
@@ -30,6 +30,8 @@ import org.apache.impala.catalog.CatalogServiceCatalog;
import org.apache.impala.catalog.MetaStoreClientPool.MetaStoreClient;
import org.apache.impala.catalog.events.MetastoreEventsProcessor.EventProcessorStatus;
import org.apache.impala.service.CatalogOpExecutor;
+import org.apache.impala.util.EventSequence;
+import org.apache.impala.util.NoOpEventSequence;
import org.apache.impala.util.RandomHiveQueryRunner;
import org.apache.impala.common.Pair;
import org.apache.impala.compat.MetastoreShim;
@@ -162,7 +164,8 @@ public class EventsProcessorStressTest {
PatternMatcher.MATCHER_MATCH_ALL);
for (String tbl : tablenames) {
catalog_.reloadTable(catalog_.getTable(dbName, tbl), "test refresh "
- + "operation for events stress test");
+ + "operation for events stress test",
+ NoOpEventSequence.INSTANCE);
}
// wait for a random duration between 0 and 3 seconds. We want the refresh
// clients to aggressive than the event polling threads
diff --git a/fe/src/test/java/org/apache/impala/catalog/events/MetastoreEventsProcessorTest.java b/fe/src/test/java/org/apache/impala/catalog/events/MetastoreEventsProcessorTest.java
index d13070593..6820292e7 100644
--- a/fe/src/test/java/org/apache/impala/catalog/events/MetastoreEventsProcessorTest.java
+++ b/fe/src/test/java/org/apache/impala/catalog/events/MetastoreEventsProcessorTest.java
@@ -165,7 +165,9 @@ import org.apache.impala.thrift.TTypeNode;
import org.apache.impala.thrift.TTypeNodeType;
import org.apache.impala.thrift.TUpdateCatalogRequest;
import org.apache.impala.thrift.TUpdatedPartition;
+import org.apache.impala.util.EventSequence;
import org.apache.impala.util.MetaStoreUtil;
+import org.apache.impala.util.NoOpEventSequence;
import org.apache.thrift.TException;
import org.junit.After;
import org.junit.AfterClass;
@@ -907,8 +909,9 @@ public class MetastoreEventsProcessorTest {
multiInsertTbl.getFileSystem(),
new Path(multiInsertTbl.getHdfsBaseDir() + "/year=2009/month=2"), true, null);
// load the created tables
- catalog_.reloadTable(multiInsertTbl, "test");
- catalog_.reloadTable(insertTbl, "test");
+ EventSequence catalogTimeline = NoOpEventSequence.INSTANCE;
+ catalog_.reloadTable(multiInsertTbl, "test", catalogTimeline);
+ catalog_.reloadTable(insertTbl, "test", catalogTimeline);
eventsProcessor_.processEvents();
}
@@ -1482,7 +1485,7 @@ public class MetastoreEventsProcessorTest {
public void testEventProcessingAfterReset() throws ImpalaException {
assertEquals(EventProcessorStatus.ACTIVE, eventsProcessor_.getStatus());
long syncedIdBefore = eventsProcessor_.getLastSyncedEventId();
- catalog_.reset();
+ catalog_.reset(NoOpEventSequence.INSTANCE);
assertEquals(EventProcessorStatus.ACTIVE, eventsProcessor_.getStatus());
// nothing changed so event id remains the same
assertEquals(syncedIdBefore, eventsProcessor_.getLastSyncedEventId());
@@ -1739,7 +1742,8 @@ public class MetastoreEventsProcessorTest {
tblTransition.second);
if (doCreateDrop) {
catalog_.invalidateTable(new TTableName(TEST_DB_NAME, testTblName),
- new Reference<>(), new Reference<>());
+ new Reference<>(), new Reference<>(),
+ NoOpEventSequence.INSTANCE);
dropTableFromImpala(TEST_DB_NAME, testTblName);
createTableFromImpala(TEST_DB_NAME, testTblName, null, false);
loadTable(TEST_DB_NAME, testTblName);
@@ -1817,7 +1821,7 @@ public class MetastoreEventsProcessorTest {
System.getProperty("java.io.tmpdir"), new MetaStoreClientPool(0, 0));
cs.setAuthzManager(new NoopAuthorizationManager());
cs.setMetastoreEventProcessor(NoOpEventProcessor.getInstance());
- cs.reset();
+ cs.reset(NoOpEventSequence.INSTANCE);
} catch (ImpalaException e) {
throw new IllegalStateException(e.getMessage(), e);
}
@@ -2999,14 +3003,18 @@ public class MetastoreEventsProcessorTest {
}
/**
- * Some of the the alter table events doesn't require to reload file metadata, this
+ * Some of the alter table events doesn't require to reload file metadata, this
* test asserts that file metadata is not reloaded for such alter table events
*/
@Test
public void testAlterTableNoFileMetadataReload() throws Exception {
createDatabase(TEST_DB_NAME, null);
final String testTblName = "testAlterTableNoFileMetadataReload";
+ // Create a non-empty partitioned table.
createTable(testTblName, true);
+ List<List<String>> partVals = new ArrayList<>();
+ partVals.add(Arrays.asList("1"));
+ addPartitions(TEST_DB_NAME, testTblName, partVals);
eventsProcessor_.processEvents();
// load the table first
loadTable(testTblName);
@@ -3201,7 +3209,7 @@ public class MetastoreEventsProcessorTest {
catalog_.getLock().writeLock().unlock();
try {
tbl.reloadPartitions(metaStoreClient.getHiveClient(), mp,
- FileMetadataLoadOpts.LOAD_IF_SD_CHANGED);
+ FileMetadataLoadOpts.LOAD_IF_SD_CHANGED, NoOpEventSequence.INSTANCE);
} finally {
if (tbl.isWriteLockedByCurrentThread()) {
tbl.releaseWriteLock();
@@ -3463,7 +3471,7 @@ public class MetastoreEventsProcessorTest {
testTbl = (HdfsTable) catalog_.getOrLoadTable(TEST_DB_NAME, testUnpartTblName,
"test", null);
lastSyncEventIdBefore = testTbl.getLastRefreshEventId();
- catalog_.reloadTable(testTbl, "test");
+ catalog_.reloadTable(testTbl, "test", NoOpEventSequence.INSTANCE);
eventsProcessor_.processEvents();
assertEquals(testTbl.getLastRefreshEventId(), eventsProcessor_.getCurrentEventId());
assertTrue(testTbl.getLastRefreshEventId() > lastSyncEventIdBefore);
diff --git a/fe/src/test/java/org/apache/impala/common/FrontendFixture.java b/fe/src/test/java/org/apache/impala/common/FrontendFixture.java
index 7daba7ad7..56a9ac91b 100644
--- a/fe/src/test/java/org/apache/impala/common/FrontendFixture.java
+++ b/fe/src/test/java/org/apache/impala/common/FrontendFixture.java
@@ -60,6 +60,7 @@ import org.apache.impala.thrift.TFunctionBinaryType;
import org.apache.impala.thrift.TQueryCtx;
import org.apache.impala.thrift.TQueryOptions;
import org.apache.impala.util.EventSequence;
+import org.apache.impala.util.NoOpEventSequence;
import com.google.common.base.Joiner;
import com.google.common.base.Preconditions;
@@ -215,7 +216,7 @@ public class FrontendFixture {
}
try {
KuduTable kuduTable = (KuduTable) dummyTable;
- kuduTable.loadSchemaFromKudu();
+ kuduTable.loadSchemaFromKudu(NoOpEventSequence.INSTANCE);
} catch (ImpalaRuntimeException e) {
e.printStackTrace();
fail("Failed to add test table:\n" + createTableSql);
diff --git a/fe/src/test/java/org/apache/impala/testutil/CatalogServiceTestCatalog.java b/fe/src/test/java/org/apache/impala/testutil/CatalogServiceTestCatalog.java
index e91678b3a..04c55f2a2 100644
--- a/fe/src/test/java/org/apache/impala/testutil/CatalogServiceTestCatalog.java
+++ b/fe/src/test/java/org/apache/impala/testutil/CatalogServiceTestCatalog.java
@@ -34,6 +34,7 @@ import org.apache.impala.common.ImpalaException;
import org.apache.impala.hive.executor.TestHiveJavaFunctionFactory;
import org.apache.impala.service.CatalogOpExecutor;
import org.apache.impala.service.FeSupport;
+import org.apache.impala.util.NoOpEventSequence;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -92,7 +93,7 @@ public class CatalogServiceTestCatalog extends CatalogServiceCatalog {
new TestHiveJavaFunctionFactory()));
cs.setEventFactoryForSyncToLatestEvent(
new EventFactoryForSyncToLatestEvent(cs.getCatalogOpExecutor()));
- cs.reset();
+ cs.reset(NoOpEventSequence.INSTANCE);
} catch (ImpalaException e) {
throw new IllegalStateException(e.getMessage(), e);
}
@@ -121,7 +122,7 @@ public class CatalogServiceTestCatalog extends CatalogServiceCatalog {
new TestHiveJavaFunctionFactory()));
cs.setEventFactoryForSyncToLatestEvent(
new EventFactoryForSyncToLatestEvent(cs.getCatalogOpExecutor()));
- cs.reset();
+ cs.reset(NoOpEventSequence.INSTANCE);
return cs;
}
diff --git a/fe/src/test/java/org/apache/impala/testutil/ImpaladTestCatalog.java b/fe/src/test/java/org/apache/impala/testutil/ImpaladTestCatalog.java
index 6a58965c4..95c9a10ab 100644
--- a/fe/src/test/java/org/apache/impala/testutil/ImpaladTestCatalog.java
+++ b/fe/src/test/java/org/apache/impala/testutil/ImpaladTestCatalog.java
@@ -34,6 +34,7 @@ import org.apache.impala.catalog.Table;
import org.apache.impala.catalog.User;
import org.apache.impala.thrift.TPrivilege;
import org.apache.impala.thrift.TUniqueId;
+import org.apache.impala.util.NoOpEventSequence;
import org.apache.impala.util.PatternMatcher;
import java.util.HashSet;
@@ -110,7 +111,9 @@ public class ImpaladTestCatalog extends ImpaladCatalog {
/**
* Reloads all metadata from the source catalog.
*/
- public void reset() throws CatalogException { srcCatalog_.reset(); }
+ public void reset() throws CatalogException {
+ srcCatalog_.reset(NoOpEventSequence.INSTANCE);
+ }
/**
* Returns the Table for the given name, loading the table's metadata if necessary.
diff --git a/tests/query_test/test_observability.py b/tests/query_test/test_observability.py
index 443626110..b11453585 100644
--- a/tests/query_test/test_observability.py
+++ b/tests/query_test/test_observability.py
@@ -440,14 +440,34 @@ class TestObservability(ImpalaTestSuite):
r'Query Timeline:',
r'Planning finished'
]
- # Events for DDLs. Currently just CreateTable has them.
- ddl_event_regexes = [
+ # Events for CreateTable DDLs.
+ create_table_ddl_event_regexes = [
r'Catalog Server Operation:',
r'Got metastoreDdlLock:',
r'Created table in Metastore:',
r'Created table in catalog cache:',
r'DDL finished:',
]
+ # Events for AlterTable DDLs.
+ alter_table_ddl_event_regexes = [
+ r'Catalog Server Operation:',
+ r'Got catalog version read lock:',
+ r'Got catalog version write lock and table write lock:',
+ r'Altered table in Metastore:',
+ r'Fetched table from Metastore:',
+ r'Loaded table schema:',
+ r'DDL finished:'
+ ]
+ # Events for LOAD statement.
+ load_data_ddl_event_regexes = [
+ r'Catalog Server Operation:',
+ r'Got catalog version read lock:',
+ r'Got catalog version write lock and table write lock:',
+ r'Fired Metastore events:',
+ r'Fetched table from Metastore:',
+ r'Loaded file metadata for 1 partitions:',
+ r'Finished updateCatalog request:'
+ ]
# queries that explore different code paths in Frontend compilation
queries = [
'create table if not exists impala_6568 (i int)',
@@ -465,7 +485,13 @@ class TestObservability(ImpalaTestSuite):
# Verify catalogOp timeline
if query.startswith("create table"):
self.__verify_profile_contains_every_event(
- ddl_event_regexes, runtime_profile, query)
+ create_table_ddl_event_regexes, runtime_profile, query)
+ elif query.startswith("alter table"):
+ self.__verify_profile_contains_every_event(
+ alter_table_ddl_event_regexes, runtime_profile, query)
+ elif query.startswith("load data"):
+ self.__verify_profile_contains_every_event(
+ load_data_ddl_event_regexes, runtime_profile, query)
def __verify_profile_contains_every_event(self, event_regexes, runtime_profile, query):
"""Test that all the expected events show up in a given query profile."""
@@ -479,7 +505,7 @@ class TestObservability(ImpalaTestSuite):
labels of HMS events are not used so this test is expected to pass with or without
event processor enabled"""
# Create normal table
- stmt = "create table %s.t1(id int)" % unique_database
+ stmt = "create table %s.t1(id int) partitioned by (p int)" % unique_database
self.__verify_event_labels_in_profile(stmt, [
"Got metastoreDdlLock",
"Got Metastore client",
@@ -512,6 +538,41 @@ class TestObservability(ImpalaTestSuite):
"Created table in catalog cache",
"DDL finished",
])
+ # INSERT into table
+ stmt = "insert into %s.t1 partition(p) values (0,0), (1,1)" % unique_database
+ self.__verify_event_labels_in_profile(stmt, [
+ "Got Metastore client",
+ "Added 2 partitions in Metastore",
+ "Loaded file metadata for 2 partitions",
+ "Finished updateCatalog request"
+ ])
+ # Compute stats
+ stmt = "compute stats %s.t1" % unique_database
+ self.__verify_event_labels_in_profile(stmt, [
+ "Got Metastore client",
+ "Updated column stats",
+ "Altered 2 partitions in Metastore",
+ "Altered table in Metastore",
+ "Fetched table from Metastore",
+ "Loaded file metadata for 2 partitions",
+ "DDL finished"
+ ])
+ # REFRESH
+ stmt = "refresh %s.t1" % unique_database
+ self.__verify_event_labels_in_profile(stmt, [
+ "Got Metastore client",
+ "Fetched table from Metastore",
+ "Loaded file metadata for 2 partitions",
+ "Finished resetMetadata request"
+ ])
+ # Drop table
+ stmt = "drop table %s.t1" % unique_database
+ self.__verify_event_labels_in_profile(stmt, [
+ "Got Metastore client",
+ "Dropped table in Metastore",
+ "Deleted table in catalog cache",
+ "DDL finished"
+ ])
def __verify_event_labels_in_profile(self, stmt, event_labels):
profile = self.execute_query(stmt).runtime_profile
(impala) 04/04: IMPALA-12923: Fix header alignment during horizontal scrolling in query timeline
Posted by st...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
stigahuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git
commit 99c5b93272fcce2ca6210bfafd6453423bdce4c8
Author: Surya Hebbar <sh...@cloudera.com>
AuthorDate: Wed Mar 20 21:42:33 2024 +0530
IMPALA-12923: Fix header alignment during horizontal scrolling in query timeline
On horizontally scrolling the query timeline after zooming, the controls
and navigation bar at the top of the page move away from the visibility
area. This makes it difficult to use the controls while scrolling.
The controls and navigation bar now stay within the visibility area even
after scrolling horizontally, allowing for easier navigation.
Hovering on the edges to scroll horizontally is also supported as before.
Change-Id: Ib3b248554ba32766c29faf91c791f2dbbd20641e
Reviewed-on: http://gerrit.cloudera.org:8080/21173
Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
www/query_timeline.tmpl | 56 +++++++++++-----------
www/scripts/query_timeline/fragment_diagram.js | 8 ++--
.../query_timeline/fragment_metrics_diagram.js | 2 +-
.../query_timeline/host_utilization_diagram.js | 2 +-
4 files changed, 35 insertions(+), 33 deletions(-)
diff --git a/www/query_timeline.tmpl b/www/query_timeline.tmpl
index 8288e5349..900631a38 100644
--- a/www/query_timeline.tmpl
+++ b/www/query_timeline.tmpl
@@ -125,33 +125,35 @@ g.plan_node:active {
</div>
</div>
-<div id="timing_diagram" style="border:1px solid #c3c3c3;">
- <div style="border:1px solid #c3c3c3;">
- <svg id="phases_header"></svg>
- </div>
- <div style="border:1px solid #c3c3c3; overflow-y:scroll; overflow-x:hidden;">
- <svg id="fragment_diagram"></svg>
- </div>
- <div style="border:1px solid #c3c3c3;">
- <svg id="timeticks_footer"></svg>
+<span id="scrollable_screen" style="display: inline-block; width: 100vw; overflow-x: scroll;">
+ <div id="timing_diagram" style="border:1px solid #c3c3c3;">
+ <div style="border:1px solid #c3c3c3;">
+ <svg id="phases_header"></svg>
+ </div>
+ <div style="border:1px solid #c3c3c3; overflow-y:scroll; overflow-x:hidden;">
+ <svg id="fragment_diagram"></svg>
+ </div>
+ <div style="border:1px solid #c3c3c3;">
+ <svg id="timeticks_footer"></svg>
+ </div>
</div>
-</div>
-<div id="host_utilization_wrapper">
- <img id="host_utilization_resize_bar" src="www/icons/drag_handle.png" draggable="false"/>
- <input id="host_utilization_close_btn" class="btn btn-primary btn-sm" type="button"
- value="X" data-dismiss="modal"/>
- <div id="host_utilization_diagram">
- <!--Utilization metrics is not available. Please make sure to set query option
- RESOURCE_TRACE_RATIO=true.-->
+ <div id="host_utilization_wrapper">
+ <img id="host_utilization_resize_bar" src="www/icons/drag_handle.png" draggable="false"/>
+ <input id="host_utilization_close_btn" class="btn btn-primary btn-sm" type="button"
+ value="X" data-dismiss="modal"/>
+ <div id="host_utilization_diagram">
+ <!--Utilization metrics is not available. Please make sure to set query option
+ RESOURCE_TRACE_RATIO=true.-->
+ </div>
</div>
-</div>
-<div id="fragment_metrics_wrapper">
- <img id="fragment_metrics_resize_bar" src="www/icons/drag_handle.png" draggable="false"/>
- <input id="fragment_metrics_close_btn" class="btn btn-primary btn-sm" type="button"
- value="X" data-dismiss="modal"/>
- <div id="fragment_metrics_diagram">
+ <div id="fragment_metrics_wrapper">
+ <img id="fragment_metrics_resize_bar" src="www/icons/drag_handle.png" draggable="false"/>
+ <input id="fragment_metrics_close_btn" class="btn btn-primary btn-sm" type="button"
+ value="X" data-dismiss="modal"/>
+ <div id="fragment_metrics_diagram">
+ </div>
</div>
-</div>
+</span>
{{/plan_metadata_unavailable}}
@@ -241,13 +243,13 @@ if (window.location.search.includes("imported")) {
}
}
-window.addEventListener('mousemove', function(e) {
+scrollable_screen.addEventListener('mousemove', function(e) {
var scroll_margin = window.innerWidth / 10;
var scroll_amount = window.innerWidth / 3;
if (e.clientX <= scroll_margin) {
- window.scrollBy({left : - scroll_amount, behavior : "smooth"});
+ scrollable_screen.scrollBy({left : - scroll_amount, behavior : "smooth"});
} else if (e.clientX >= window.innerWidth - scroll_margin) {
- window.scrollBy({left : + scroll_amount, behavior : "smooth"});
+ scrollable_screen.scrollBy({left : + scroll_amount, behavior : "smooth"});
}
});
diff --git a/www/scripts/query_timeline/fragment_diagram.js b/www/scripts/query_timeline/fragment_diagram.js
index 65506c771..1d71c7717 100644
--- a/www/scripts/query_timeline/fragment_diagram.js
+++ b/www/scripts/query_timeline/fragment_diagram.js
@@ -555,7 +555,7 @@ export function setTimingDiagramDimensions(ignored_arg) {
fragment_diagram.parentElement.style.width = `${diagram_width}px`;
phases_header.parentElement.style.width = `${diagram_width}px`;
timeticks_footer.parentElement.style.width = `${diagram_width}px`;
- timing_diagram.parentElement.style.width = `${diagram_width}px`;
+ timing_diagram.style.width = `${diagram_width}px`;
fragment_diagram.style.width = `${diagram_width}px`;
phases_header.style.width = `${diagram_width}px`;
@@ -578,12 +578,12 @@ fragment_diagram.addEventListener('mouseout', function(e) {
});
fragment_diagram.addEventListener('mousemove', function(e) {
- if (e.pageX >= name_width && e.pageX <= name_width + chart_width){
+ if (e.clientX + scrollable_screen.scrollLeft >= name_width && e.clientX + scrollable_screen.scrollLeft <= name_width + chart_width){
removeChildIfExists(fragment_diagram, timestamp_gridline);
- timestamp_gridline = getSvgLine(stroke_fill_colors.black, e.pageX, 0, e.pageX,
+ timestamp_gridline = getSvgLine(stroke_fill_colors.black, e.clientX + scrollable_screen.scrollLeft, 0, e.clientX + scrollable_screen.scrollLeft,
parseInt(fragment_diagram.style.height));
fragment_diagram.appendChild(timestamp_gridline);
- var gridline_time = ((maxts * (e.pageX - name_width) / chart_width) / 1e9);
+ var gridline_time = ((maxts * (e.clientX + scrollable_screen.scrollLeft - name_width) / chart_width) / 1e9);
showTooltip(host_utilization_chart, gridline_time);
showTooltip(fragment_metrics_chart, gridline_time);
fragment_diagram_title.textContent = gridline_time.toFixed(decimals) + " s";
diff --git a/www/scripts/query_timeline/fragment_metrics_diagram.js b/www/scripts/query_timeline/fragment_metrics_diagram.js
index bb6af59f2..b191dfbc7 100644
--- a/www/scripts/query_timeline/fragment_metrics_diagram.js
+++ b/www/scripts/query_timeline/fragment_metrics_diagram.js
@@ -155,7 +155,7 @@ export function getFragmentMetricsWrapperHeight() {
export function toogleFragmentMetricsVisibility() {
if (fragment_id_selections.size > 0 && fragment_metrics_parse_successful) {
- fragment_metrics_wrapper.style.display = "initial";
+ fragment_metrics_wrapper.style.display = "inline-block";
} else {
fragment_metrics_wrapper.style.display = "none";
}
diff --git a/www/scripts/query_timeline/host_utilization_diagram.js b/www/scripts/query_timeline/host_utilization_diagram.js
index bffd4987e..2463aee76 100644
--- a/www/scripts/query_timeline/host_utilization_diagram.js
+++ b/www/scripts/query_timeline/host_utilization_diagram.js
@@ -197,7 +197,7 @@ export function resetUtilizationHeight() {
export function toogleUtilizationVisibility() {
if (utilization_metrics_parse_successful && host_utilization_visible) {
- host_utilization_wrapper.style.display = "initial";
+ host_utilization_wrapper.style.display = "inline-block";
} else {
host_utilization_wrapper.style.display = "none";
}