Skip to content

Conversation

@wecharyu
Copy link
Contributor

What changes were proposed in this pull request?

Currently HiveMetaStoreClient use CLIENT_SOCKET_TIMEOUT as both socket timeout and connection timeout, we want to introduce a new HiveMetaStoreClient config for connection timeout:

    CLIENT_CONNECTION_TIMEOUT("metastore.client.connection.timeout", "hive.metastore.client.connection.timeout", 10,
            TimeUnit.SECONDS, "MetaStore Client connection timeout in seconds"),

Why are the changes needed?

  1. achieve a more flexible config for client socket timeout and connection timeout.
  2. we can use a smaller connection timeout to fail-fast reconnect to another HMS server.

Does this PR introduce any user-facing change?

Yes, user can set the client connection timeout by this conf.

How was this patch tested?

Add a unit test.

public static void setUp() throws Exception {
@Before
public void setUp() throws Exception {
HMSHandler.testTimeoutEnabled = true;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nit: This test code hacks HMSHandler class, I will refactor this in a new PR.

Copy link
Member

Choose a reason for hiding this comment

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

do we need to repeat the whole setup for every test or it's possible to extract just the HMSHandler part?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addressed! Have separated the start of MetaStore Server into a BeforeClass method.

@pan3793
Copy link
Member

pan3793 commented Mar 24, 2023

A similar PR #3379 for JDBC thrift client, IMO the connection timeout is quite important, please help reopen the closed PR if any committer think it's useful.

"has an infinite lifetime."),
CLIENT_SOCKET_TIMEOUT("metastore.client.socket.timeout", "hive.metastore.client.socket.timeout", 600,
TimeUnit.SECONDS, "MetaStore Client socket timeout in seconds"),
CLIENT_CONNECTION_TIMEOUT("metastore.client.connection.timeout", "hive.metastore.client.connection.timeout", 10,
Copy link
Member

Choose a reason for hiding this comment

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

It makes sense to set connection timeout a small value, because generally, establish the connection is quick, and small timeout make it quick failover if one HMS is down, but it silent changes the default behavior, I'm not sure if such change is acceptable in Hive community

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch, if there is any concern I will keep the default connection timeout value same as socket timeout.

Copy link
Member

@deniskuzZ deniskuzZ Apr 24, 2023

Choose a reason for hiding this comment

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

@wecharyu, won't be socketTimeout = connectTimeout if not explicitly set?

public TSocket(TConfiguration config, String host, int port, int timeout)  {
    this(config, host, port, timeout, timeout);
  }
public TSocket(TConfiguration config, String host, int port, int socketTimeout, int connectTimeout)  {}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I have changed the default connectionTimeout to be the same as socketTimeout. But IMHO it's not a good practice because if we set socketTimeout and not set connectionTimeout, the default long time will be gained for connection, I think we should change the behavior by default where socketTimeout = connectionTimeout.

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 3 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@wecharyu
Copy link
Contributor Author

@ayushtkn @deniskuzZ @kasakrisz: Could you help review this PR?

@wecharyu
Copy link
Contributor Author

wecharyu commented Apr 8, 2023

@zabetak @dengzhhu653: Could you also take a look?

try {
client.createDatabase(db);
} catch (MetaException e) {
} catch (Exception e) {
Copy link
Member

Choose a reason for hiding this comment

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

why is this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because we have changed to use the remote MetaStore server in this test class, so the timeout exception was wrapped in TTransportException rather than MetaException.

Copy link
Member

@deniskuzZ deniskuzZ left a comment

Choose a reason for hiding this comment

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

LGTM, some minor comments

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
No Duplication information No Duplication information

Copy link
Member

@deniskuzZ deniskuzZ left a comment

Choose a reason for hiding this comment

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

+1

@deniskuzZ deniskuzZ merged commit e413b44 into apache:master May 3, 2023
yeahyung pushed a commit to yeahyung/hive that referenced this pull request Jul 20, 2023
tarak271 pushed a commit to tarak271/hive-1 that referenced this pull request Dec 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants