Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HIVE-24179: Memory leak in HS2 DbTxnManager when compiling SHOW LOCKS statement #1509

Merged
merged 1 commit into from
Nov 13, 2020

Conversation

zabetak
Copy link
Contributor

@zabetak zabetak commented Sep 18, 2020

What changes were proposed in this pull request?

  1. Avoid multiple shutdown hooks for the same threadpool in DbTxnManager
  2. Close new HiveTxnManager in ShowLocksAnalyzer to release resources

Why are the changes needed?

Avoid the memory leak when executing SHOW LOCKS statements and simplify code.

Does this PR introduce any user-facing change?

No

How was this patch tested?

mvn test -pl itests/hive-unit -Dtest=TestDbTxnManagerMemoryLeak -Pitests

If it finishes then there is no memory leak, otherwise most of the time you get an OutOfMemoryError.
See the JIRA case for more details.

The commit with the test is not meant to be merged into master

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, don't forget to exclude the test.

… statement

1. Avoid multiple shutdown hooks for the same threadpool in DbTxnManager.

Enforce unique initialization and shutdown of the thread pool. Apart
from the apparent memory leak there is no need to register a shutdown
hook for the executor service multiple times. It wastes memory,
complicates code, and serves no purpose.

Change initHeartbeatExecutorService to synchronized putting the class
lock in the whole method. Mixing instance and class locks is confusing
and does not offer any particular benefit.

2. Avoid HiveTxnManager instantiation in lock analyzers.

A transaction manager should already exist inside the
analyzer before calling the analyze method. There is no need to create a
new one just to obtain the useNewShowLocksFormat boolean indicator.
@jcamachor jcamachor merged commit 8e7b8f8 into apache:master Nov 13, 2020
szehon-ho pushed a commit to szehon-ho/hive that referenced this pull request Nov 25, 2020
… statement (Stamatis Zampetakis, reviewed by Denys Kuzmenko, Jesus Camacho Rodriguez)

1. Avoid multiple shutdown hooks for the same threadpool in DbTxnManager.

Enforce unique initialization and shutdown of the thread pool. Apart
from the apparent memory leak there is no need to register a shutdown
hook for the executor service multiple times. It wastes memory,
complicates code, and serves no purpose.

Change initHeartbeatExecutorService to synchronized putting the class
lock in the whole method. Mixing instance and class locks is confusing
and does not offer any particular benefit.

2. Avoid HiveTxnManager instantiation in lock analyzers.

A transaction manager should already exist inside the
analyzer before calling the analyze method. There is no need to create a
new one just to obtain the useNewShowLocksFormat boolean indicator.


Closes apache#1509
mr3project pushed a commit to mr3project/hive-mr3 that referenced this pull request Sep 24, 2023
… statement (Stamatis Zampetakis, reviewed by Denys Kuzmenko, Jesus Camacho Rodriguez)

1. Avoid multiple shutdown hooks for the same threadpool in DbTxnManager.

Enforce unique initialization and shutdown of the thread pool. Apart
from the apparent memory leak there is no need to register a shutdown
hook for the executor service multiple times. It wastes memory,
complicates code, and serves no purpose.

Change initHeartbeatExecutorService to synchronized putting the class
lock in the whole method. Mixing instance and class locks is confusing
and does not offer any particular benefit.

2. Avoid HiveTxnManager instantiation in lock analyzers.

A transaction manager should already exist inside the
analyzer before calling the analyze method. There is no need to create a
new one just to obtain the useNewShowLocksFormat boolean indicator.

Closes apache/hive#1509
mr3project pushed a commit to mr3project/hive-mr3 that referenced this pull request Oct 2, 2023
… statement (Stamatis Zampetakis, reviewed by Denys Kuzmenko, Jesus Camacho Rodriguez)

1. Avoid multiple shutdown hooks for the same threadpool in DbTxnManager.

Enforce unique initialization and shutdown of the thread pool. Apart
from the apparent memory leak there is no need to register a shutdown
hook for the executor service multiple times. It wastes memory,
complicates code, and serves no purpose.

Change initHeartbeatExecutorService to synchronized putting the class
lock in the whole method. Mixing instance and class locks is confusing
and does not offer any particular benefit.

2. Avoid HiveTxnManager instantiation in lock analyzers.

A transaction manager should already exist inside the
analyzer before calling the analyze method. There is no need to create a
new one just to obtain the useNewShowLocksFormat boolean indicator.

Closes apache/hive#1509
mr3project pushed a commit to mr3project/hive-mr3 that referenced this pull request Nov 7, 2023
… statement (Stamatis Zampetakis, reviewed by Denys Kuzmenko, Jesus Camacho Rodriguez)

1. Avoid multiple shutdown hooks for the same threadpool in DbTxnManager.

Enforce unique initialization and shutdown of the thread pool. Apart
from the apparent memory leak there is no need to register a shutdown
hook for the executor service multiple times. It wastes memory,
complicates code, and serves no purpose.

Change initHeartbeatExecutorService to synchronized putting the class
lock in the whole method. Mixing instance and class locks is confusing
and does not offer any particular benefit.

2. Avoid HiveTxnManager instantiation in lock analyzers.

A transaction manager should already exist inside the
analyzer before calling the analyze method. There is no need to create a
new one just to obtain the useNewShowLocksFormat boolean indicator.

Closes apache/hive#1509
mr3project pushed a commit to mr3project/hive-mr3 that referenced this pull request Dec 4, 2023
… statement (Stamatis Zampetakis, reviewed by Denys Kuzmenko, Jesus Camacho Rodriguez)

1. Avoid multiple shutdown hooks for the same threadpool in DbTxnManager.

Enforce unique initialization and shutdown of the thread pool. Apart
from the apparent memory leak there is no need to register a shutdown
hook for the executor service multiple times. It wastes memory,
complicates code, and serves no purpose.

Change initHeartbeatExecutorService to synchronized putting the class
lock in the whole method. Mixing instance and class locks is confusing
and does not offer any particular benefit.

2. Avoid HiveTxnManager instantiation in lock analyzers.

A transaction manager should already exist inside the
analyzer before calling the analyze method. There is no need to create a
new one just to obtain the useNewShowLocksFormat boolean indicator.

Closes apache/hive#1509
mr3project pushed a commit to mr3project/hive-mr3 that referenced this pull request Dec 9, 2023
… statement (Stamatis Zampetakis, reviewed by Denys Kuzmenko, Jesus Camacho Rodriguez)

1. Avoid multiple shutdown hooks for the same threadpool in DbTxnManager.

Enforce unique initialization and shutdown of the thread pool. Apart
from the apparent memory leak there is no need to register a shutdown
hook for the executor service multiple times. It wastes memory,
complicates code, and serves no purpose.

Change initHeartbeatExecutorService to synchronized putting the class
lock in the whole method. Mixing instance and class locks is confusing
and does not offer any particular benefit.

2. Avoid HiveTxnManager instantiation in lock analyzers.

A transaction manager should already exist inside the
analyzer before calling the analyze method. There is no need to create a
new one just to obtain the useNewShowLocksFormat boolean indicator.

Closes apache/hive#1509
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants