Skip to content

Add ability to disable batch fetch tables and views from HMS#18274

Merged
kokosing merged 2 commits intotrinodb:masterfrom
huberty89:huberty89/batch-metadata-fetch-switch
Aug 28, 2023
Merged

Add ability to disable batch fetch tables and views from HMS#18274
kokosing merged 2 commits intotrinodb:masterfrom
huberty89:huberty89/batch-metadata-fetch-switch

Conversation

@huberty89
Copy link
Copy Markdown
Contributor

@huberty89 huberty89 commented Jul 13, 2023

Description

Look like previously introducing batching is not supported well by old versions of HMS, more in a linked issue

Additional context and related issues

Fixes #18111 introduced after #17127

Release notes

( ) This is not user-visible or docs only and no release notes are required.
( ) Release notes are required, please propose a release note for me.
(x) Release notes are required, with the following suggested text:

# Hive
* Add config property for disabling batch metadata fetch from HMS. ({issue}`18111`)

@huberty89
Copy link
Copy Markdown
Contributor Author

Not sure where should I add a test to verify if setting new config property make an effect + if current place is the right place.

@huberty89 huberty89 force-pushed the huberty89/batch-metadata-fetch-switch branch 2 times, most recently from 5ee36fd to ef8d13d Compare July 13, 2023 10:31
@github-actions github-actions bot added tests:hive hive Hive connector labels Jul 13, 2023
@huberty89 huberty89 force-pushed the huberty89/batch-metadata-fetch-switch branch from ef8d13d to db3c754 Compare July 13, 2023 13:25
Comment thread plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveConfig.java Outdated
Copy link
Copy Markdown
Member

@kokosing kokosing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some test?

Comment thread plugin/trino-hive/src/main/java/io/trino/plugin/hive/HiveConfig.java Outdated
@huberty89 huberty89 force-pushed the huberty89/batch-metadata-fetch-switch branch from db3c754 to 1884958 Compare July 27, 2023 10:32
@huberty89
Copy link
Copy Markdown
Contributor Author

Some test?

Added TestThriftBatchFetchSwitch

@Praveen2112
Copy link
Copy Markdown
Member

Apart from disabling it - can we have a fallback mechanism if the query failed during bulkload api ?

@huberty89
Copy link
Copy Markdown
Contributor Author

Apart from disabling it - can we have a fallback mechanism if the query failed during bulkload api ?

@Praveen2112 on specific exception or all? Also there should be some recovery after some time?

@huberty89 huberty89 force-pushed the huberty89/batch-metadata-fetch-switch branch 2 times, most recently from ffc0105 to c9cd823 Compare July 28, 2023 14:12
@huberty89
Copy link
Copy Markdown
Contributor Author

huberty89 commented Jul 28, 2023

@Praveen2112 @findepi @kokosing I moved config property, add a tests and in case of thrift transport error I do a fallback to old mechanism. Please review

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this test. You are testing the mock here.

How about using some TestHiveWithDisabledBatchFecthConnectorSmokeTest for this?

Copy link
Copy Markdown
Contributor Author

@huberty89 huberty89 Jul 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this test. You are testing the mock here.

I'm only provide fake ThriftMetastoreClient (I saw this pattern in few tests) to get the expected behavior so I can test (ThriftHiveMetastore) if new added config property works.

I like new name, I will apply it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could write test which runs real HMS and create more than 100 schemas/tables but this test would be slow + I have to run HMS in specific version which has a mentioned bug.

@huberty89 huberty89 force-pushed the huberty89/batch-metadata-fetch-switch branch from c9cd823 to 387c22a Compare August 2, 2023 10:47
@huberty89 huberty89 requested a review from kokosing August 2, 2023 10:49
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use io.trino.plugin.hive.metastore.thrift.ThriftHiveMetastoreClient#alternativeCall for that?

Please mention in the message that there will be a fallback to a different method to retrieve the information.

I guess HMS is not going to change so we should not repeat calling wrong API for the next request again.

Copy link
Copy Markdown
Contributor Author

@huberty89 huberty89 Aug 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if that easy, in that case I have to recreate and duplicate logic from:

io.trino.plugin.hive.HiveMetadata#listTables
io.trino.plugin.hive.HiveMetadata#listViews
io.trino.plugin.hive.HiveMetadata#listSchemaNames

Edit: hold on, I need to very this ^

I guess HMS is not going to change so we should not repeat calling wrong API for the next request again.

From https://issues.apache.org/jira/browse/HIVE-21028 it looks like particular problem was related to race condition, this is how author of the fix reproduce it locally:

I have manually tested this by slowing down the get_table_meta call and then dropping the database from another HMS.

So even with old version of HMS this should work in most of the cases.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or should we retry on a specific exception type ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue looks like a transient one so we could retry the next time

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or should we retry on a specific exception type ?

I think there is not specific exception, just network related error:

Caused by: org.apache.thrift.transport.TTransportException: ip-10-210-216-228.ap-northeast-2.compute.internal:9083: Socket is closed by peer.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kokosing @Praveen2112 I try to implement this using alternativeCall. The implementation itself is trivial, but writing a tests for that is challenging. In that case I have to refactor ThriftHiveMetastoreClient so ThriftHiveMetastore.Iface(client) could be provided from outside but later creating test implementation of ThriftHiveMetastore.Iface with 211 methods is not easy to read.

@heechan3006
Copy link
Copy Markdown
Contributor

@huberty89 Is this ready for merging?

Copy link
Copy Markdown
Member

@Praveen2112 Praveen2112 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Post applying @kokosing & @ksobolew 's pending comments

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or should we retry on a specific exception type ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue looks like a transient one so we could retry the next time

Copy link
Copy Markdown
Member

@kokosing kokosing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM % remaining comments

@huberty89 huberty89 force-pushed the huberty89/batch-metadata-fetch-switch branch from 387c22a to 8da5e17 Compare August 23, 2023 12:17
Hubert Łojek added 2 commits August 23, 2023 19:36
For older versions of HMS fetching all tables and all views
may end up in failure.
https://issues.apache.org/jira/browse/HIVE-21028

In such case we need to use previous mechanism and fetch
tables/views from each schema separately
@huberty89 huberty89 force-pushed the huberty89/batch-metadata-fetch-switch branch from 8da5e17 to 4979b15 Compare August 23, 2023 17:45
@kokosing kokosing merged commit 15c5b74 into trinodb:master Aug 28, 2023
@kokosing
Copy link
Copy Markdown
Member

Thank you!

@github-actions github-actions bot added this to the 426 milestone Aug 28, 2023
@colebow
Copy link
Copy Markdown
Member

colebow commented Aug 30, 2023

Added docs in #18870 - but in the future, please make sure new configuration properties are documented when you add them @huberty89

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed hive Hive connector

Development

Successfully merging this pull request may close these issues.

Fetching all hive metadata failed issues

7 participants